From 0f17aff8fd7fab1433f6b18e6d2265af796694e7 Mon Sep 17 00:00:00 2001 From: yhh <359807859@qq.com> Date: Mon, 23 Nov 2020 16:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/egretProperties.json | 43 - demo/favicon.ico | Bin 4286 -> 0 bytes demo/index.html | 95 - demo/libs/exml.e.d.ts | 52 - demo/libs/fairygui/fairygui.d.ts | 2444 -- demo/libs/fairygui/fairygui.js | 19026 ------------ demo/libs/fairygui/fairygui.min.js | 1 - demo/libs/framework/framework.d.ts | 2638 -- demo/libs/framework/framework.js | 11788 ------- demo/libs/framework/framework.min.js | 1 - .../libs/framework_tiled/framework_tiled.d.ts | 357 - demo/libs/framework_tiled/framework_tiled.js | 1575 - .../framework_tiled/framework_tiled.min.js | 1 - .../modules/assetsmanager/assetsmanager.d.ts | 1522 - .../modules/assetsmanager/assetsmanager.js | 2992 -- .../assetsmanager/assetsmanager.min.js | 1 - .../libs/modules/dragonBones/dragonBones.d.ts | 8471 ----- demo/libs/modules/dragonBones/dragonBones.js | 18213 ----------- .../modules/dragonBones/dragonBones.min.js | 1 - demo/libs/modules/egret/egret.d.ts | 15371 --------- demo/libs/modules/egret/egret.js | 25845 ---------------- demo/libs/modules/egret/egret.min.js | 7 - demo/libs/modules/egret/egret.web.js | 9806 ------ demo/libs/modules/egret/egret.web.min.js | 5 - demo/libs/modules/eui/eui.d.ts | 15047 --------- demo/libs/modules/eui/eui.js | 25655 --------------- demo/libs/modules/eui/eui.min.js | 7 - demo/libs/modules/game/game.d.ts | 2502 -- demo/libs/modules/game/game.js | 4818 --- demo/libs/modules/game/game.min.js | 2 - demo/libs/modules/promise/promise.js | 1162 - demo/libs/modules/promise/promise.min.js | 1 - demo/libs/modules/tween/tween.d.ts | 1350 - demo/libs/modules/tween/tween.js | 2095 -- demo/libs/modules/tween/tween.min.js | 1 - demo/manifest.json | 53 - demo/resource/characters/1.png | Bin 1207 -> 0 bytes demo/resource/characters/2.png | Bin 1439 -> 0 bytes demo/resource/characters/3.png | Bin 1542 -> 0 bytes demo/resource/characters/4.png | Bin 1545 -> 0 bytes demo/resource/characters/5.png | Bin 1311 -> 0 bytes demo/resource/characters/6.png | Bin 1279 -> 0 bytes demo/resource/default.res.json | 126 - demo/resource/default.thm.json | 34 - demo/resource/fgui/common.zip | Bin 470 -> 0 bytes demo/resource/fgui/loading.zip | Bin 919 -> 0 bytes demo/resource/fgui/sc.zip | Bin 2793 -> 0 bytes demo/resource/preload/bg.png | Bin 2875 -> 0 bytes demo/resource/preload/bgNorm.png | Bin 22588 -> 0 bytes demo/resource/preload/cabbage.png | Bin 4595 -> 0 bytes demo/resource/preload/caveman/caveman.png | Bin 11371 -> 0 bytes demo/resource/preload/caveman/tiledMap.json | 193 - demo/resource/preload/caveman/tileset.png | Bin 1055 -> 0 bytes demo/resource/preload/moon.png | Bin 770 -> 0 bytes demo/resource/preload/moonNorm.png | Bin 19698 -> 0 bytes demo/resource/preload/ninja/tilemap.json | 370 - demo/resource/preload/ninja/tileset.png | Bin 88026 -> 0 bytes demo/resource/preload/orange.png | Bin 5988 -> 0 bytes demo/resource/preload/orangeNorm.png | Bin 47027 -> 0 bytes .../preload/orthogonal/buch-outdoor.png | Bin 12951 -> 0 bytes .../orthogonal/orthogonal-outside.json | 1328 - demo/resource/preload/plume.png | Bin 1138 -> 0 bytes demo/scripts/api.d.ts | 452 - demo/scripts/baidugame/baidugame.ts | 82 - demo/scripts/bricks/bricks.ts | 64 - demo/scripts/config.android.ts | 52 - demo/scripts/config.baidugame.ts | 63 - demo/scripts/config.bricks.ts | 55 - demo/scripts/config.ios.ts | 52 - demo/scripts/config.mygame.ts | 63 - demo/scripts/config.oppogame.ts | 62 - demo/scripts/config.qgame.ts | 62 - demo/scripts/config.qqgame.ts | 65 - demo/scripts/config.ts | 95 - demo/scripts/config.vivogame.ts | 62 - demo/scripts/config.wxgame.ts | 65 - demo/scripts/mygame/mygame.ts | 82 - demo/scripts/myplugin.ts | 17 - demo/scripts/node.d.ts | 4209 --- demo/scripts/oppogame/oppogame.ts | 90 - demo/scripts/qgame/qgame.ts | 90 - demo/scripts/qqgame/qqgame.ts | 118 - demo/scripts/tsconfig.json | 50 - demo/scripts/vivogame/vivogame.ts | 126 - demo/scripts/wxgame/wxgame.ts | 149 - demo/src/AssetAdapter.ts | 56 - demo/src/Fgui/common/UI_com_tips.ts | 19 - demo/src/Fgui/common/commonBinder.ts | 10 - demo/src/Fgui/loading/UI_View_loading.ts | 21 - demo/src/Fgui/loading/loadingBinder.ts | 10 - demo/src/Fgui/sc/UI_View_sc.ts | 21 - demo/src/Fgui/sc/UI_btn_sc.ts | 19 - demo/src/Fgui/sc/UI_combo_sc_popup.ts | 19 - demo/src/Fgui/sc/scBinder.ts | 12 - demo/src/Main.ts | 70 - demo/src/Platform.ts | 41 - demo/src/SampleHelpers/SampleScene.ts | 27 - .../AnimatedTiles/AnimatedTilesScene.ts | 21 - demo/src/Scenes/EmptyScene/BasicScene.ts | 27 - demo/src/Scenes/GOAP/GoapScene.ts | 117 - demo/src/Scenes/LineCasting/LineCaster.ts | 89 - .../Scenes/LineCasting/LineCastingScene.ts | 25 - .../src/Scenes/NinjaAdventure/CameraBounds.ts | 37 - .../FireballProjectileController.ts | 28 - demo/src/Scenes/NinjaAdventure/Ninja.ts | 145 - .../NinjaAdventure/NinjaAdventureScene.ts | 89 - .../NinjaAdventure/ProjectileHitDetector.ts | 30 - demo/src/ThemeAdapter.ts | 97 - demo/src/UI/PopManager.ts | 25 - demo/src/UI/loading/LoadingControl.ts | 27 - demo/src/UI/loading/LoadingEvents.ts | 5 - demo/src/UI/loading/LoadingView.ts | 59 - demo/src/UI/mvc/BaseView.ts | 101 - demo/src/UI/mvc/EventManager.ts | 104 - demo/src/UI/mvc/Extension.ts | 389 - demo/src/UI/mvc/FguiUtils.ts | 25 - demo/src/UI/mvc/LayerManager.ts | 46 - demo/src/UI/mvc/ViewManager.ts | 125 - demo/src/UI/sc/ScControl.ts | 27 - demo/src/UI/sc/ScEvents.ts | 5 - demo/src/UI/sc/ScView.ts | 82 - demo/template/runtime/native_loader.js | 8 - demo/template/runtime/native_require.js | 53 - demo/template/runtime/runtime_loader.js | 8 - demo/template/web/index.html | 96 - demo/tsconfig.json | 20 - demo/wingProperties.json | 9 - demo_fgui/.objs/fonts.json | 0 demo_fgui/.objs/metas/m4sln17a/k7mf0.info | 1 - demo_fgui/.objs/workspace.json | 23 - demo_fgui/assets/common/com_tips.xml | 12 - demo_fgui/assets/common/package.xml | 7 - demo_fgui/assets/loading/View_loading.xml | 12 - demo_fgui/assets/loading/package.xml | 8 - demo_fgui/assets/loading/组件/pg_loading.xml | 10 - demo_fgui/assets/sc/View_sc.xml | 10 - demo_fgui/assets/sc/package.xml | 12 - demo_fgui/assets/sc/组件/btn_sc.xml | 22 - demo_fgui/assets/sc/组件/combo_sc.xml | 22 - demo_fgui/assets/sc/组件/combo_sc_item.xml | 18 - demo_fgui/assets/sc/组件/combo_sc_popup.xml | 12 - demo_fgui/assets/sc/资源/cabbage.png | Bin 4595 -> 0 bytes demo_fgui/demo_fgui.fairy | 2 - demo_fgui/settings/Adaptation.json | 8 - demo_fgui/settings/Common.json | 24 - demo_fgui/settings/CustomProperties.json | 1 - demo_fgui/settings/Publish.json | 35 - demo_fgui/settings/i18n.json | 3 - source/gulpfile.js | 2 +- 149 files changed, 1 insertion(+), 183711 deletions(-) delete mode 100644 demo/egretProperties.json delete mode 100644 demo/favicon.ico delete mode 100644 demo/index.html delete mode 100644 demo/libs/exml.e.d.ts delete mode 100644 demo/libs/fairygui/fairygui.d.ts delete mode 100644 demo/libs/fairygui/fairygui.js delete mode 100644 demo/libs/fairygui/fairygui.min.js delete mode 100644 demo/libs/framework/framework.d.ts delete mode 100644 demo/libs/framework/framework.js delete mode 100644 demo/libs/framework/framework.min.js delete mode 100644 demo/libs/framework_tiled/framework_tiled.d.ts delete mode 100644 demo/libs/framework_tiled/framework_tiled.js delete mode 100644 demo/libs/framework_tiled/framework_tiled.min.js delete mode 100644 demo/libs/modules/assetsmanager/assetsmanager.d.ts delete mode 100644 demo/libs/modules/assetsmanager/assetsmanager.js delete mode 100644 demo/libs/modules/assetsmanager/assetsmanager.min.js delete mode 100644 demo/libs/modules/dragonBones/dragonBones.d.ts delete mode 100644 demo/libs/modules/dragonBones/dragonBones.js delete mode 100644 demo/libs/modules/dragonBones/dragonBones.min.js delete mode 100644 demo/libs/modules/egret/egret.d.ts delete mode 100644 demo/libs/modules/egret/egret.js delete mode 100644 demo/libs/modules/egret/egret.min.js delete mode 100644 demo/libs/modules/egret/egret.web.js delete mode 100644 demo/libs/modules/egret/egret.web.min.js delete mode 100644 demo/libs/modules/eui/eui.d.ts delete mode 100644 demo/libs/modules/eui/eui.js delete mode 100644 demo/libs/modules/eui/eui.min.js delete mode 100644 demo/libs/modules/game/game.d.ts delete mode 100644 demo/libs/modules/game/game.js delete mode 100644 demo/libs/modules/game/game.min.js delete mode 100644 demo/libs/modules/promise/promise.js delete mode 100644 demo/libs/modules/promise/promise.min.js delete mode 100644 demo/libs/modules/tween/tween.d.ts delete mode 100644 demo/libs/modules/tween/tween.js delete mode 100644 demo/libs/modules/tween/tween.min.js delete mode 100644 demo/manifest.json delete mode 100644 demo/resource/characters/1.png delete mode 100644 demo/resource/characters/2.png delete mode 100644 demo/resource/characters/3.png delete mode 100644 demo/resource/characters/4.png delete mode 100644 demo/resource/characters/5.png delete mode 100644 demo/resource/characters/6.png delete mode 100644 demo/resource/default.res.json delete mode 100644 demo/resource/default.thm.json delete mode 100644 demo/resource/fgui/common.zip delete mode 100644 demo/resource/fgui/loading.zip delete mode 100644 demo/resource/fgui/sc.zip delete mode 100644 demo/resource/preload/bg.png delete mode 100644 demo/resource/preload/bgNorm.png delete mode 100644 demo/resource/preload/cabbage.png delete mode 100644 demo/resource/preload/caveman/caveman.png delete mode 100644 demo/resource/preload/caveman/tiledMap.json delete mode 100644 demo/resource/preload/caveman/tileset.png delete mode 100644 demo/resource/preload/moon.png delete mode 100644 demo/resource/preload/moonNorm.png delete mode 100644 demo/resource/preload/ninja/tilemap.json delete mode 100644 demo/resource/preload/ninja/tileset.png delete mode 100644 demo/resource/preload/orange.png delete mode 100644 demo/resource/preload/orangeNorm.png delete mode 100644 demo/resource/preload/orthogonal/buch-outdoor.png delete mode 100644 demo/resource/preload/orthogonal/orthogonal-outside.json delete mode 100644 demo/resource/preload/plume.png delete mode 100644 demo/scripts/api.d.ts delete mode 100644 demo/scripts/baidugame/baidugame.ts delete mode 100644 demo/scripts/bricks/bricks.ts delete mode 100644 demo/scripts/config.android.ts delete mode 100644 demo/scripts/config.baidugame.ts delete mode 100644 demo/scripts/config.bricks.ts delete mode 100644 demo/scripts/config.ios.ts delete mode 100644 demo/scripts/config.mygame.ts delete mode 100644 demo/scripts/config.oppogame.ts delete mode 100644 demo/scripts/config.qgame.ts delete mode 100644 demo/scripts/config.qqgame.ts delete mode 100644 demo/scripts/config.ts delete mode 100644 demo/scripts/config.vivogame.ts delete mode 100644 demo/scripts/config.wxgame.ts delete mode 100644 demo/scripts/mygame/mygame.ts delete mode 100644 demo/scripts/myplugin.ts delete mode 100644 demo/scripts/node.d.ts delete mode 100644 demo/scripts/oppogame/oppogame.ts delete mode 100644 demo/scripts/qgame/qgame.ts delete mode 100644 demo/scripts/qqgame/qqgame.ts delete mode 100644 demo/scripts/tsconfig.json delete mode 100644 demo/scripts/vivogame/vivogame.ts delete mode 100644 demo/scripts/wxgame/wxgame.ts delete mode 100644 demo/src/AssetAdapter.ts delete mode 100644 demo/src/Fgui/common/UI_com_tips.ts delete mode 100644 demo/src/Fgui/common/commonBinder.ts delete mode 100644 demo/src/Fgui/loading/UI_View_loading.ts delete mode 100644 demo/src/Fgui/loading/loadingBinder.ts delete mode 100644 demo/src/Fgui/sc/UI_View_sc.ts delete mode 100644 demo/src/Fgui/sc/UI_btn_sc.ts delete mode 100644 demo/src/Fgui/sc/UI_combo_sc_popup.ts delete mode 100644 demo/src/Fgui/sc/scBinder.ts delete mode 100644 demo/src/Main.ts delete mode 100644 demo/src/Platform.ts delete mode 100644 demo/src/SampleHelpers/SampleScene.ts delete mode 100644 demo/src/Scenes/AnimatedTiles/AnimatedTilesScene.ts delete mode 100644 demo/src/Scenes/EmptyScene/BasicScene.ts delete mode 100644 demo/src/Scenes/GOAP/GoapScene.ts delete mode 100644 demo/src/Scenes/LineCasting/LineCaster.ts delete mode 100644 demo/src/Scenes/LineCasting/LineCastingScene.ts delete mode 100644 demo/src/Scenes/NinjaAdventure/CameraBounds.ts delete mode 100644 demo/src/Scenes/NinjaAdventure/FireballProjectileController.ts delete mode 100644 demo/src/Scenes/NinjaAdventure/Ninja.ts delete mode 100644 demo/src/Scenes/NinjaAdventure/NinjaAdventureScene.ts delete mode 100644 demo/src/Scenes/NinjaAdventure/ProjectileHitDetector.ts delete mode 100644 demo/src/ThemeAdapter.ts delete mode 100644 demo/src/UI/PopManager.ts delete mode 100644 demo/src/UI/loading/LoadingControl.ts delete mode 100644 demo/src/UI/loading/LoadingEvents.ts delete mode 100644 demo/src/UI/loading/LoadingView.ts delete mode 100644 demo/src/UI/mvc/BaseView.ts delete mode 100644 demo/src/UI/mvc/EventManager.ts delete mode 100644 demo/src/UI/mvc/Extension.ts delete mode 100644 demo/src/UI/mvc/FguiUtils.ts delete mode 100644 demo/src/UI/mvc/LayerManager.ts delete mode 100644 demo/src/UI/mvc/ViewManager.ts delete mode 100644 demo/src/UI/sc/ScControl.ts delete mode 100644 demo/src/UI/sc/ScEvents.ts delete mode 100644 demo/src/UI/sc/ScView.ts delete mode 100644 demo/template/runtime/native_loader.js delete mode 100644 demo/template/runtime/native_require.js delete mode 100644 demo/template/runtime/runtime_loader.js delete mode 100644 demo/template/web/index.html delete mode 100644 demo/tsconfig.json delete mode 100644 demo/wingProperties.json delete mode 100644 demo_fgui/.objs/fonts.json delete mode 100644 demo_fgui/.objs/metas/m4sln17a/k7mf0.info delete mode 100644 demo_fgui/.objs/workspace.json delete mode 100644 demo_fgui/assets/common/com_tips.xml delete mode 100644 demo_fgui/assets/common/package.xml delete mode 100644 demo_fgui/assets/loading/View_loading.xml delete mode 100644 demo_fgui/assets/loading/package.xml delete mode 100644 demo_fgui/assets/loading/组件/pg_loading.xml delete mode 100644 demo_fgui/assets/sc/View_sc.xml delete mode 100644 demo_fgui/assets/sc/package.xml delete mode 100644 demo_fgui/assets/sc/组件/btn_sc.xml delete mode 100644 demo_fgui/assets/sc/组件/combo_sc.xml delete mode 100644 demo_fgui/assets/sc/组件/combo_sc_item.xml delete mode 100644 demo_fgui/assets/sc/组件/combo_sc_popup.xml delete mode 100644 demo_fgui/assets/sc/资源/cabbage.png delete mode 100644 demo_fgui/demo_fgui.fairy delete mode 100644 demo_fgui/settings/Adaptation.json delete mode 100644 demo_fgui/settings/Common.json delete mode 100644 demo_fgui/settings/CustomProperties.json delete mode 100644 demo_fgui/settings/Publish.json delete mode 100644 demo_fgui/settings/i18n.json diff --git a/demo/egretProperties.json b/demo/egretProperties.json deleted file mode 100644 index f630de52..00000000 --- a/demo/egretProperties.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "engineVersion": "5.2.33", - "compilerVersion": "5.2.33", - "template": {}, - "target": { - "current": "web" - }, - "modules": [ - { - "name": "egret" - }, - { - "name": "eui" - }, - { - "name": "assetsmanager" - }, - { - "name": "game" - }, - { - "name": "tween" - }, - { - "name": "promise" - }, - { - "name": "dragonBones" - }, - { - "name": "fairygui", - "path": "./libs/fairygui" - }, - { - "name": "framework", - "path": "./libs/framework" - }, - { - "name": "framework_tiled", - "path": "./libs/framework_tiled" - } - ] -} \ No newline at end of file diff --git a/demo/favicon.ico b/demo/favicon.ico deleted file mode 100644 index e4ec42cb797707ba45b119ae96019d21414c0f3a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4286 zcmcgwM@wZ(5WeppywzLJ^8E}&Q80iYqKG0cL|iC{x-()xR8-7jT!^TkqM+!)grb58 z^TM11=A6H|UqKyuT#eo{Q_{EUboZ&Rs=K)FXSBiO!!Uu`1rv4`#UZ#FR{PBkK^NGoSdBC@bD1#_xCc!@jpe1-{0SlzP>(e zY;0g@X$jTU)#&Z*6@1QN`xB(P-`?IZH#dj7yF0-e85zOa+M38ZNAdMpx%PjDs}6Fm z^Y->OUSD6ax3`DM$w>>})Xlk1PfvJwcyM`LOnl0ZkB?YcS;5Q83tC%SEqsnCQLd<{ zKzVsNE-o&#`&;}oKA+Fd&M-SWi-v{Du#xJWX|*Rvt{SEj4)nOtl{Bd zWMpJueSO`ELGBOR>gp8yg#w{7n3tn;R=Gzlv$jS6q!BJ~Q?@J3A!@vku(e z-U=4ig#FBu=6qA%S7pT~XI$yt`uO-r>}h;+oOP+az5N$#_J4;=T*}O2X=!N^XRL!A z9UUU`ym6fV(l*w_&+mQ}U*D%rHrC$6#6;BA)>`?F`yC%2FMXV|yu6H^ogK^fuVR|> z6`!2-J|ZFletv#ZcXe!WaS7VnAGfeM#}!fx*06+x1h~1mAuupd&XD8B`T4oE*SovBlHa)JtVgb5n(IYf#Alt) z&CQi{_V)HhV`HP0PdUyrP8-#4Q->?E;!jLWNDi&5tCL#7^)4$b18X1mpY|y>xm`qE zJj=emzKD#Blw8jG!j_kpC;NSUefEg&F3&ObTtI69`>E=*I8 z>LzC#@>|2*-Cc4G76v z^^JBg4i**`5E>ea=H_Okr>D!=*Ka?ymE0BL`}CK!g!iegt}gk;YANJ>hQnoB!% wUF^c9-KH-3&$>bzrl+S-Qc@!KEOTAV`IPM@>SUa;_M5nN;e7soz~6rU32Htf$^ZZW diff --git a/demo/index.html b/demo/index.html deleted file mode 100644 index 3f4f4d67..00000000 --- a/demo/index.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - Egret - - - - - - - - - - -
-
- - - - \ No newline at end of file diff --git a/demo/libs/exml.e.d.ts b/demo/libs/exml.e.d.ts deleted file mode 100644 index 7849d520..00000000 --- a/demo/libs/exml.e.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -declare module skins{ - class ButtonSkin extends eui.Skin{ - } -} -declare module skins{ - class CheckBoxSkin extends eui.Skin{ - } -} -declare module skins{ - class HScrollBarSkin extends eui.Skin{ - } -} -declare module skins{ - class HSliderSkin extends eui.Skin{ - } -} -declare module skins{ - class ItemRendererSkin extends eui.Skin{ - } -} -declare module skins{ - class PanelSkin extends eui.Skin{ - } -} -declare module skins{ - class ProgressBarSkin extends eui.Skin{ - } -} -declare module skins{ - class RadioButtonSkin extends eui.Skin{ - } -} -declare module skins{ - class ScrollerSkin extends eui.Skin{ - } -} -declare module skins{ - class TextInputSkin extends eui.Skin{ - } -} -declare module skins{ - class ToggleSwitchSkin extends eui.Skin{ - } -} -declare module skins{ - class VScrollBarSkin extends eui.Skin{ - } -} -declare module skins{ - class VSliderSkin extends eui.Skin{ - } -} diff --git a/demo/libs/fairygui/fairygui.d.ts b/demo/libs/fairygui/fairygui.d.ts deleted file mode 100644 index a92150a9..00000000 --- a/demo/libs/fairygui/fairygui.d.ts +++ /dev/null @@ -1,2444 +0,0 @@ -declare module fgui { - class AsyncOperation { - callback: (obj: GObject) => void; - callbackObj: any; - private _itemList; - private _objectPool; - private _index; - constructor(); - createObject(pkgName: string, resName: string): void; - createObjectFromURL(url: string): void; - cancel(): void; - private internalCreateObject; - private collectComponentChildren; - private collectListChildren; - private run; - } -} -declare module fgui { - class Controller extends egret.EventDispatcher { - private _selectedIndex; - private _previousIndex; - private _pageIds; - private _pageNames; - private _actions?; - name: string; - parent: GComponent; - autoRadioGroupDepth?: boolean; - changing: boolean; - constructor(); - dispose(): void; - selectedIndex: number; - setSelectedIndex(value: number): void; - readonly previsousIndex: number; - selectedPage: string; - setSelectedPage(value: string): void; - readonly previousPage: string; - readonly pageCount: number; - getPageName(index: number): string; - addPage(name?: string): void; - addPageAt(name: string, index: number): void; - removePage(name: string): void; - removePageAt(index?: number): void; - clearPages(): void; - hasPage(aName: string): boolean; - getPageIndexById(aId: string): number; - getPageIdByName(aName: string): string; - getPageNameById(aId: string): string; - getPageId(index?: number): string; - selectedPageId: string; - oppositePageId: string; - readonly previousPageId: string; - runActions(): void; - setup(buffer: ByteBuffer): void; - } -} -declare module fgui { - class DragDropManager { - private _agent; - private _sourceData; - private static _inst; - static readonly inst: DragDropManager; - constructor(); - readonly dragAgent: GObject; - readonly dragging: boolean; - startDrag(source: GObject, icon: string, sourceData?: any, touchPointID?: number): void; - cancel(): void; - private __dragEnd; - } -} -declare module fgui { - enum ButtonMode { - Common = 0, - Check = 1, - Radio = 2 - } - enum AutoSizeType { - None = 0, - Both = 1, - Height = 2 - } - enum AlignType { - Left = 0, - Center = 1, - Right = 2 - } - enum VertAlignType { - Top = 0, - Middle = 1, - Bottom = 2 - } - enum LoaderFillType { - None = 0, - Scale = 1, - ScaleMatchHeight = 2, - ScaleMatchWidth = 3, - ScaleFree = 4, - ScaleNoBorder = 5 - } - enum ListLayoutType { - SingleColumn = 0, - SingleRow = 1, - FlowHorizontal = 2, - FlowVertical = 3, - Pagination = 4 - } - enum ListSelectionMode { - Single = 0, - Multiple = 1, - Multiple_SingleClick = 2, - None = 3 - } - enum OverflowType { - Visible = 0, - Hidden = 1, - Scroll = 2 - } - enum PackageItemType { - Image = 0, - MovieClip = 1, - Sound = 2, - Component = 3, - Atlas = 4, - Font = 5, - Swf = 6, - Misc = 7, - Unknown = 8, - Spine = 9, - DragonBones = 10 - } - enum ObjectType { - Image = 0, - MovieClip = 1, - Swf = 2, - Graph = 3, - Loader = 4, - Group = 5, - Text = 6, - RichText = 7, - InputText = 8, - Component = 9, - List = 10, - Label = 11, - Button = 12, - ComboBox = 13, - ProgressBar = 14, - Slider = 15, - ScrollBar = 16, - Tree = 17, - Loader3D = 18 - } - enum ProgressTitleType { - Percent = 0, - ValueAndMax = 1, - Value = 2, - Max = 3 - } - enum ScrollBarDisplayType { - Default = 0, - Visible = 1, - Auto = 2, - Hidden = 3 - } - enum ScrollType { - Horizontal = 0, - Vertical = 1, - Both = 2 - } - enum FlipType { - None = 0, - Horizontal = 1, - Vertical = 2, - Both = 3 - } - enum ChildrenRenderOrder { - Ascent = 0, - Descent = 1, - Arch = 2 - } - enum GroupLayoutType { - None = 0, - Horizontal = 1, - Vertical = 2 - } - enum PopupDirection { - Auto = 0, - Up = 1, - Down = 2 - } - enum RelationType { - Left_Left = 0, - Left_Center = 1, - Left_Right = 2, - Center_Center = 3, - Right_Left = 4, - Right_Center = 5, - Right_Right = 6, - Top_Top = 7, - Top_Middle = 8, - Top_Bottom = 9, - Middle_Middle = 10, - Bottom_Top = 11, - Bottom_Middle = 12, - Bottom_Bottom = 13, - Width = 14, - Height = 15, - LeftExt_Left = 16, - LeftExt_Right = 17, - RightExt_Left = 18, - RightExt_Right = 19, - TopExt_Top = 20, - TopExt_Bottom = 21, - BottomExt_Top = 22, - BottomExt_Bottom = 23, - Size = 24 - } - enum FillMethod { - None = 0, - Horizontal = 1, - Vertical = 2, - Radial90 = 3, - Radial180 = 4, - Radial360 = 5 - } - enum FillOrigin { - Top = 0, - Bottom = 1, - Left = 2, - Right = 3, - TopLeft = 0, - TopRight = 1, - BottomLeft = 2, - BottomRight = 3 - } - enum FillOrigin90 { - TopLeft = 0, - TopRight = 1, - BottomLeft = 2, - BottomRight = 3 - } - enum ObjectPropID { - Text = 0, - Icon = 1, - Color = 2, - OutlineColor = 3, - Playing = 4, - Frame = 5, - DeltaTime = 6, - TimeScale = 7, - FontSize = 8, - Selected = 9 - } -} -declare module fgui { - class GObject extends egret.EventDispatcher { - data: any; - packageItem: PackageItem; - static draggingObject: GObject; - private _x; - private _y; - private _alpha; - private _rotation; - private _visible; - private _touchable; - private _grayed; - private _draggable; - private _scaleX; - private _scaleY; - private _skewX; - private _skewY; - private _pivotX; - private _pivotY; - private _pivotAsAnchor; - private _pivotOffsetX; - private _pivotOffsetY; - private _sortingOrder; - private _internalVisible; - private _handlingController?; - private _tooltips?; - private _pixelSnapping?; - private _disposed?; - private _dragTesting?; - private _dragStartPos?; - private _relations; - private _group?; - private _gears; - private _displayObject; - private _dragBounds?; - sourceWidth: number; - sourceHeight: number; - initWidth: number; - initHeight: number; - minWidth: number; - minHeight: number; - maxWidth: number; - maxHeight: number; - _parent: GComponent; - _width: number; - _height: number; - _rawWidth: number; - _rawHeight: number; - _id: string; - _name: string; - _underConstruct: boolean; - _gearLocked?: boolean; - _sizePercentInGroup: number; - _treeNode?: GTreeNode; - static XY_CHANGED: string; - static SIZE_CHANGED: string; - static SIZE_DELAY_CHANGE: string; - static GEAR_STOP: string; - constructor(); - readonly id: string; - name: string; - x: number; - y: number; - setXY(xv: number, yv: number): void; - xMin: number; - yMin: number; - pixelSnapping: boolean; - center(restraint?: boolean): void; - width: number; - height: number; - setSize(wv: number, hv: number, ignorePivot?: boolean): void; - makeFullScreen(): void; - ensureSizeCorrect(): void; - readonly actualWidth: number; - readonly actualHeight: number; - scaleX: number; - scaleY: number; - setScale(sx: number, sy: number): void; - skewX: number; - skewY: number; - setSkew(xv: number, yv: number): void; - pivotX: number; - pivotY: number; - setPivot(xv: number, yv: number, asAnchor?: boolean): void; - readonly pivotAsAnchor: boolean; - protected internalSetPivot(xv: number, yv: number, asAnchor: boolean): void; - private updatePivotOffset; - private applyPivot; - touchable: boolean; - grayed: boolean; - enabled: boolean; - rotation: number; - readonly normalizeRotation: number; - alpha: number; - visible: boolean; - readonly internalVisible: boolean; - readonly internalVisible2: boolean; - readonly internalVisible3: boolean; - sortingOrder: number; - readonly focused: boolean; - requestFocus(): void; - tooltips: string; - blendMode: string; - filters: egret.Filter[]; - readonly inContainer: boolean; - readonly onStage: boolean; - readonly resourceURL: string; - group: GGroup; - getGear(index: number): GearBase; - protected updateGear(index: number): void; - checkGearController(index: number, c: Controller): boolean; - updateGearFromRelations(index: number, dx: number, dy: number): void; - addDisplayLock(): number; - releaseDisplayLock(token: number): void; - private checkGearDisplay; - readonly gearXY: GearXY; - readonly gearSize: GearSize; - readonly gearLook: GearLook; - readonly relations: Relations; - addRelation(target: GObject, relationType: number, usePercent?: boolean): void; - removeRelation(target: GObject, relationType?: number): void; - readonly displayObject: egret.DisplayObject; - protected setDisplayObject(value: egret.DisplayObject): void; - parent: GComponent; - removeFromParent(): void; - readonly root: GRoot; - readonly asCom: GComponent; - readonly asButton: GButton; - readonly asLabel: GLabel; - readonly asProgress: GProgressBar; - readonly asTextField: GTextField; - readonly asRichTextField: GRichTextField; - readonly asTextInput: GTextInput; - readonly asLoader: GLoader; - readonly asList: GList; - readonly asTree: GTree; - readonly asGraph: GGraph; - readonly asGroup: GGroup; - readonly asSlider: GSlider; - readonly asComboBox: GComboBox; - readonly asImage: GImage; - readonly asMovieClip: GMovieClip; - static cast(obj: egret.DisplayObject): GObject; - text: string; - icon: string; - readonly isDisposed: boolean; - readonly treeNode: GTreeNode; - dispose(): void; - addClickListener(listener: Function, thisObj?: any): void; - removeClickListener(listener: Function, thisObj?: any): void; - hasClickListener(): boolean; - addEventListener(type: string, listener: Function, thisObject?: any): void; - removeEventListener(type: string, listener: Function, thisObject?: any): void; - private _reDispatch; - draggable: boolean; - dragBounds: egret.Rectangle; - startDrag(touchPointID?: number, stageX?: number, stageY?: number): void; - stopDrag(): void; - readonly dragging: boolean; - localToGlobal(ax?: number, ay?: number, result?: egret.Point): egret.Point; - globalToLocal(ax?: number, ay?: number, result?: egret.Point): egret.Point; - localToRoot(ax?: number, ay?: number, result?: egret.Point): egret.Point; - rootToLocal(ax?: number, ay?: number, resultPoint?: egret.Point): egret.Point; - localToGlobalRect(ax?: number, ay?: number, aw?: number, ah?: number, result?: egret.Rectangle): egret.Rectangle; - globalToLocalRect(ax?: number, ay?: number, aw?: number, ah?: number, result?: egret.Rectangle): egret.Rectangle; - handleControllerChanged(c: Controller): void; - protected createDisplayObject(): void; - protected switchDisplayObject(newObj: egret.DisplayObject): void; - protected handleXYChanged(): void; - protected handleSizeChanged(): void; - protected handleScaleChanged(): void; - protected handleGrayedChanged(): void; - protected handleAlphaChanged(): void; - handleVisibleChanged(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - constructFromResource(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - private initDrag; - private dragBegin; - private dragEnd; - private reset; - private __begin; - private __moving; - private __end; - } -} -declare module fgui { - class GComponent extends GObject { - private _sortingChildCount; - private _applyingController?; - protected _margin: Margin; - protected _trackBounds: boolean; - protected _boundsChanged: boolean; - protected _childrenRenderOrder: ChildrenRenderOrder; - protected _apexIndex: number; - _buildingDisplayList: boolean; - _children: Array; - _controllers: Array; - _transitions: Array; - _rootContainer: UIContainer; - _container: egret.DisplayObjectContainer; - _scrollPane?: ScrollPane; - _alignOffset: egret.Point; - constructor(); - protected createDisplayObject(): void; - dispose(): void; - readonly displayListContainer: egret.DisplayObjectContainer; - addChild(child: GObject): GObject; - addChildAt(child: GObject, index?: number): GObject; - private getInsertPosForSortingChild; - removeChild(child: GObject, dispose?: boolean): GObject; - removeChildAt(index: number, dispose?: boolean): GObject; - removeChildren(beginIndex?: number, endIndex?: number, dispose?: boolean): void; - getChildAt(index: number): GObject; - getChild(name: string): GObject; - getChildByPath(path: String): GObject; - getVisibleChild(name: string): GObject; - getChildInGroup(name: string, group: GGroup): GObject; - getChildById(id: string): GObject; - getChildIndex(child: GObject): number; - setChildIndex(child: GObject, index: number): void; - setChildIndexBefore(child: GObject, index: number): number; - private _setChildIndex; - swapChildren(child1: GObject, child2: GObject): void; - swapChildrenAt(index1: number, index2: number): void; - readonly numChildren: number; - isAncestorOf(child: GObject): boolean; - addController(controller: Controller): void; - getControllerAt(index: number): Controller; - getController(name: string): Controller; - removeController(c: Controller): void; - readonly controllers: Array; - childStateChanged(child: GObject): void; - private buildNativeDisplayList; - applyController(c: Controller): void; - applyAllControllers(): void; - adjustRadioGroupDepth(obj: GObject, c: Controller): void; - getTransitionAt(index: number): Transition; - getTransition(transName: string): Transition; - isChildInView(child: GObject): boolean; - getFirstChildInView(): number; - readonly scrollPane: ScrollPane; - opaque: boolean; - margin: Margin; - childrenRenderOrder: ChildrenRenderOrder; - apexIndex: number; - mask: egret.DisplayObject | egret.Rectangle; - readonly baseUserData: string; - protected updateScrollRect(): void; - protected setupScroll(buffer: ByteBuffer): void; - protected setupOverflow(overflow: OverflowType): void; - protected handleSizeChanged(): void; - protected handleGrayedChanged(): void; - handleControllerChanged(c: Controller): void; - setBoundsChangedFlag(): void; - private __render; - ensureBoundsCorrect(): void; - protected updateBounds(): void; - setBounds(ax: number, ay: number, aw: number, ah?: number): void; - viewWidth: number; - viewHeight: number; - getSnappingPosition(xValue: number, yValue: number, resultPoint?: egret.Point): egret.Point; - childSortingOrderChanged(child: GObject, oldValue: number, newValue?: number): void; - constructFromResource(): void; - constructFromResource2(objectPool: Array, poolIndex: number): void; - protected onConstruct(): void; - protected constructExtension(buffer: ByteBuffer): void; - protected constructFromXML(xml: any): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - private ___added; - private ___removed; - } -} -declare module fgui { - class GButton extends GComponent { - protected _titleObject: GObject; - protected _iconObject: GObject; - private _mode; - private _selected; - private _title; - private _selectedTitle; - private _icon; - private _selectedIcon; - private _sound; - private _soundVolumeScale; - private _buttonController; - private _relatedController?; - private _relatedPageId; - private _changeStateOnClick; - private _linkedPopup?; - private _downEffect; - private _downEffectValue; - private _downScaled?; - private _down; - private _over; - static UP: string; - static DOWN: string; - static OVER: string; - static SELECTED_OVER: string; - static DISABLED: string; - static SELECTED_DISABLED: string; - constructor(); - icon: string; - selectedIcon: string; - title: string; - text: string; - selectedTitle: string; - titleColor: number; - titleFontSize: number; - sound: string; - soundVolumeScale: number; - selected: boolean; - mode: ButtonMode; - relatedController: Controller; - relatedPageId: string; - changeStateOnClick: boolean; - linkedPopup: GObject; - getTextField(): GTextField; - addStateListener(listener: Function, thisObj: any): void; - removeStateListener(listener: Function, thisObj: any): void; - fireClick(downEffect?: boolean): void; - protected setState(val: string): void; - handleControllerChanged(c: Controller): void; - protected handleGrayedChanged(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - protected constructExtension(buffer: ByteBuffer): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - private __mousedown; - private __mouseup; - private __click; - } -} -declare module fgui { - class GComboBox extends GComponent { - dropdown: GComponent; - protected _titleObject: GObject; - protected _iconObject: GObject; - protected _list: GList; - private _items; - private _values; - private _icons?; - private _visibleItemCount; - private _itemsUpdated; - private _selectedIndex; - private _buttonController; - private _popupDirection; - private _selectionController?; - private _over; - private _down; - constructor(); - text: string; - icon: string; - titleColor: number; - titleFontSize: number; - visibleItemCount: number; - popupDirection: PopupDirection; - items: Array; - icons: Array; - values: Array; - selectedIndex: number; - value: string; - selectionController: Controller; - getTextField(): GTextField; - protected setState(val: string): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - protected constructExtension(buffer: ByteBuffer): void; - handleControllerChanged(c: Controller): void; - private updateSelectionController; - dispose(): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - protected showDropdown(): void; - private __popupWinClosed; - private __clickItem; - private __clickItem2; - private __mousedown; - private __mouseup; - } -} -declare module fgui { - class GGraph extends GObject { - private _graphics; - private _type; - private _lineSize; - private _lineColor; - private _lineAlpha; - private _fillColor; - private _fillAlpha; - private _cornerRadius?; - private _sides?; - private _startAngle?; - private _polygonPoints?; - private _distances?; - constructor(); - readonly graphics: egret.Graphics; - drawRect(lineSize: number, lineColor: number, lineAlpha: number, fillColor: number, fillAlpha: number, corner?: Array): void; - drawEllipse(lineSize: number, lineColor: number, lineAlpha: number, fillColor: number, fillAlpha: number): void; - drawRegularPolygon(lineSize: number, lineColor: number, lineAlpha: number, fillColor: number, fillAlpha: number, sides: number, startAngle?: number, distances?: number[]): void; - drawPolygon(lineSize: number, lineColor: number, lineAlpha: number, fillColor: number, fillAlpha: number, points: number[]): void; - distances: number[]; - clearGraphics(): void; - color: number; - private updateGraph; - replaceMe(target: GObject): void; - addBeforeMe(target: GObject): void; - addAfterMe(target: GObject): void; - setNativeObject(obj: egret.DisplayObject): void; - protected createDisplayObject(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - protected handleSizeChanged(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare namespace fgui { - class GGroup extends GObject { - private _layout; - private _lineGap; - private _columnGap; - private _excludeInvisibles?; - private _autoSizeDisabled?; - private _mainGridIndex; - private _mainGridMinSize; - private _boundsChanged; - private _percentReady; - private _mainChildIndex; - private _totalSize; - private _numChildren; - _updating: number; - constructor(); - dispose(): void; - layout: number; - lineGap: number; - columnGap: number; - excludeInvisibles: boolean; - autoSizeDisabled: boolean; - mainGridMinSize: number; - mainGridIndex: number; - setBoundsChangedFlag(positionChangedOnly?: boolean): void; - ensureSizeCorrect(): void; - ensureBoundsCorrect(): void; - private updateBounds; - private handleLayout; - moveChildren(dx: number, dy: number): void; - resizeChildren(dw: number, dh: number): void; - handleAlphaChanged(): void; - handleVisibleChanged(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GImage extends GObject { - private _content; - private _flip; - constructor(); - color: number; - flip: FlipType; - fillMethod: number; - fillOrigin: number; - fillClockwise: boolean; - fillAmount: number; - texture: egret.Texture; - protected createDisplayObject(): void; - constructFromResource(): void; - protected handleXYChanged(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GLabel extends GComponent { - protected _titleObject: GObject; - protected _iconObject: GObject; - constructor(); - icon: string; - title: string; - text: string; - titleColor: number; - titleFontSize: number; - editable: boolean; - getTextField(): GTextField; - getProp(index: number): any; - setProp(index: number, value: any): void; - protected constructExtension(buffer: ByteBuffer): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GList extends GComponent { - itemRenderer: (index: number, item: GObject) => void; - itemProvider: (index: number) => string; - callbackThisObj: any; - scrollItemToViewOnClick: boolean; - foldInvisibleItems: boolean; - private _layout; - private _lineCount; - private _columnCount; - private _lineGap; - private _columnGap; - private _defaultItem; - private _autoResizeItem; - private _selectionMode; - private _align; - private _verticalAlign; - private _selectionController?; - private _lastSelectedIndex; - private _pool; - private _virtual?; - private _loop?; - private _numItems; - private _realNumItems; - private _firstIndex; - private _curLineItemCount; - private _curLineItemCount2; - private _itemSize?; - private _virtualListChanged; - private _virtualItems?; - private _eventLocked?; - private itemInfoVer; - constructor(); - dispose(): void; - layout: ListLayoutType; - lineCount: number; - columnCount: number; - lineGap: number; - columnGap: number; - align: AlignType; - verticalAlign: VertAlignType; - virtualItemSize: egret.Point; - defaultItem: string; - autoResizeItem: boolean; - selectionMode: ListSelectionMode; - selectionController: Controller; - readonly itemPool: GObjectPool; - getFromPool(url?: string): GObject; - returnToPool(obj: GObject): void; - addChildAt(child: GObject, index: number): GObject; - addItem(url?: string): GObject; - addItemFromPool(url?: string): GObject; - removeChildAt(index: number, dispose?: boolean): GObject; - removeChildToPoolAt(index: number): void; - removeChildToPool(child: GObject): void; - removeChildrenToPool(beginIndex?: number, endIndex?: number): void; - selectedIndex: number; - getSelection(result?: number[]): number[]; - addSelection(index: number, scrollItToView?: boolean): void; - removeSelection(index: number): void; - clearSelection(): void; - private clearSelectionExcept; - selectAll(): void; - selectNone(): void; - selectReverse(): void; - handleArrowKey(dir: number): void; - private __clickItem; - protected dispatchItemEvent(evt: ItemEvent): void; - private setSelectionOnEvent; - resizeToFit(itemCount?: number, minSize?: number): void; - getMaxItemWidth(): number; - protected handleSizeChanged(): void; - handleControllerChanged(c: Controller): void; - private updateSelectionController; - getSnappingPosition(xValue: number, yValue: number, result?: egret.Point): egret.Point; - scrollToView(index: number, ani?: boolean, setFirst?: boolean): void; - getFirstChildInView(): number; - childIndexToItemIndex(index: number): number; - itemIndexToChildIndex(index: number): number; - setVirtual(): void; - setVirtualAndLoop(): void; - private _setVirtual; - numItems: number; - refreshVirtualList(): void; - private checkVirtualList; - private setVirtualListChangedFlag; - private _refreshVirtualList; - private __scrolled; - private getIndexOnPos1; - private getIndexOnPos2; - private getIndexOnPos3; - private handleScroll; - private handleScroll1; - private handleScroll2; - private handleScroll3; - private handleArchOrder1; - private handleArchOrder2; - private handleAlign; - protected updateBounds(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - protected readItems(buffer: ByteBuffer): void; - protected setupItem(buffer: ByteBuffer, obj: GObject): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GObjectPool { - private _pool; - private _count; - constructor(); - clear(): void; - readonly count: number; - getObject(url: string): GObject; - returnObject(obj: GObject): void; - } -} -declare module fgui { - class GLoader extends GObject { - private _url; - private _align; - private _verticalAlign; - private _autoSize; - private _fill; - private _shrinkOnly; - private _showErrorSign; - private _contentItem; - private _container; - private _content; - private _errorSign?; - private _content2?; - private _updatingLayout; - private static _errorSignPool; - constructor(); - protected createDisplayObject(): void; - dispose(): void; - url: string; - icon: string; - align: AlignType; - verticalAlign: VertAlignType; - fill: LoaderFillType; - shrinkOnly: boolean; - autoSize: boolean; - playing: boolean; - frame: number; - color: number; - showErrorSign: boolean; - readonly content: MovieClip; - readonly component: GComponent; - texture: egret.Texture; - fillMethod: number; - fillOrigin: number; - fillClockwise: boolean; - fillAmount: number; - protected loadContent(): void; - protected loadFromPackage(itemURL: string): void; - protected loadExternal(): void; - protected freeExternal(texture: egret.Texture): void; - protected onExternalLoadSuccess(texture: egret.Texture): void; - protected onExternalLoadFailed(): void; - private __getResCompleted; - private setErrorState; - private clearErrorState; - private updateLayout; - private clearContent; - protected handleSizeChanged(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare namespace fgui { - class GLoader3D extends GObject { - private _url; - private _align; - private _verticalAlign; - private _autoSize; - private _fill; - private _shrinkOnly; - private _playing; - private _frame; - private _loop; - private _animationName; - private _skinName; - private _color; - private _contentItem; - private _container; - private _content; - private _updatingLayout; - constructor(); - protected createDisplayObject(): void; - dispose(): void; - url: string; - icon: string; - align: AlignType; - verticalAlign: VertAlignType; - fill: LoaderFillType; - shrinkOnly: boolean; - autoSize: boolean; - playing: boolean; - frame: number; - animationName: string; - skinName: string; - loop: boolean; - color: number; - readonly content: dragonBones.EgretArmatureDisplay; - protected loadContent(): void; - protected loadFromPackage(itemURL: string): void; - private onLoaded; - setDragonBones(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string, anchor?: egret.Point): void; - private onChange; - private onChangeDragonBones; - protected loadExternal(): void; - private updateLayout; - private clearContent; - protected handleSizeChanged(): void; - protected handleGrayedChanged(): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GMovieClip extends GObject { - private _content; - constructor(); - color: number; - protected createDisplayObject(): void; - playing: boolean; - frame: number; - timeScale: number; - rewind(): void; - syncStatus(anotherMc: GMovieClip): void; - advance(timeInMiniseconds: number): void; - setPlaySettings(start?: number, end?: number, times?: number, endAt?: number, endCallback?: Function, callbackObj?: any): void; - getProp(index: number): any; - setProp(index: number, value: any): void; - constructFromResource(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GProgressBar extends GComponent { - private _min; - private _max; - private _value; - private _titleType; - private _reverse; - private _titleObject; - private _aniObject; - private _barObjectH; - private _barObjectV; - private _barMaxWidth; - private _barMaxHeight; - private _barMaxWidthDelta; - private _barMaxHeightDelta; - private _barStartX; - private _barStartY; - constructor(); - titleType: ProgressTitleType; - min: number; - max: number; - value: number; - tweenValue(value: number, duration: number): GTweener; - update(newValue: number): void; - private setFillAmount; - protected constructExtension(buffer: ByteBuffer): void; - protected handleSizeChanged(): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - } -} -declare module fgui { - class GTextField extends GObject { - protected _textField: egret.TextField; - protected _bitmapContainer?: egret.DisplayObjectContainer; - protected _font: string; - protected _fontSize: number; - protected _align: AlignType; - protected _verticalAlign: VertAlignType; - protected _color: number; - protected _leading: number; - protected _letterSpacing: number; - protected _underline: boolean; - protected _text: string; - protected _ubbEnabled: boolean; - protected _templateVars?: { - [index: string]: string; - }; - protected _autoSize: AutoSizeType; - protected _widthAutoSize: boolean; - protected _heightAutoSize: boolean; - protected _updatingSize: boolean; - protected _sizeDirty: boolean; - protected _textWidth: number; - protected _textHeight: number; - protected _requireRender: boolean; - protected _bitmapFont?: BitmapFont; - protected _lines?: Array; - protected _bitmapPool?: Array; - protected static _htmlParser: egret.HtmlTextParser; - constructor(); - protected createDisplayObject(): void; - private switchBitmapMode; - dispose(): void; - text: string; - protected updateTextFieldText(): void; - font: string; - fontSize: number; - color: number; - align: AlignType; - verticalAlign: VertAlignType; - private getAlignTypeString; - private getVertAlignTypeString; - leading: number; - letterSpacing: number; - underline: boolean; - bold: boolean; - italic: boolean; - singleLine: boolean; - stroke: number; - strokeColor: number; - ubbEnabled: boolean; - autoSize: AutoSizeType; - readonly textWidth: number; - ensureSizeCorrect(): void; - protected updateTextFormat(): void; - protected render(): void; - private __render; - protected renderNow(updateBounds?: boolean): void; - private renderWithBitmapFont; - protected handleSizeChanged(): void; - protected parseTemplate(template: string): string; - templateVars: { - [index: string]: string; - }; - setVar(name: string, value: string): GTextField; - flushVars(): void; - protected handleGrayedChanged(): void; - private doAlign; - getProp(index: number): any; - setProp(index: number, value: any): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - } - interface LineInfo { - width: number; - height: number; - textHeight: number; - text: string; - y: number; - } -} -declare module fgui { - class GRichTextField extends GTextField { - constructor(); - protected updateTextFieldText(): void; - } -} -declare module fgui { - class GRoot extends GComponent { - static contentScaleLevel: number; - private _nativeStage; - private _modalLayer; - private _popupStack; - private _justClosedPopups; - private _modalWaitPane; - private _tooltipWin; - private _defaultTooltipWin; - private _volumeScale; - private static _inst; - static touchScreen: boolean; - static contentScaleFactor: number; - static touchDown: boolean; - static ctrlKeyDown: boolean; - static shiftKeyDown: boolean; - static mouseX: number; - static mouseY: number; - static readonly inst: GRoot; - constructor(); - readonly nativeStage: egret.Stage; - showWindow(win: Window): void; - hideWindow(win: Window): void; - hideWindowImmediately(win: Window): void; - bringToFront(win: Window): void; - showModalWait(msg?: string): void; - closeModalWait(): void; - closeAllExceptModals(): void; - closeAllWindows(): void; - getTopWindow(): Window; - readonly modalLayer: GGraph; - readonly hasModalWindow: boolean; - readonly modalWaiting: boolean; - showPopup(popup: GObject, target?: GObject, dir?: PopupDirection | boolean): void; - togglePopup(popup: GObject, target?: GObject, dir?: PopupDirection | boolean): void; - hidePopup(popup?: GObject): void; - readonly hasAnyPopup: boolean; - private closePopup; - showTooltips(msg: string): void; - showTooltipsWin(tooltipWin: GObject, position?: egret.Point): void; - hideTooltips(): void; - getObjectUnderPoint(globalX: number, globalY: number): GObject; - focus: GObject; - private setFocus; - volumeScale: number; - playOneShotSound(sound: egret.Sound, volumeScale?: number): void; - private adjustModalLayer; - private __addedToStage; - private __stageMouseDownCapture; - private __stageMouseMoveCapture; - private __stageMouseUpCapture; - private __winResize; - private updateContentScaleLevel; - } -} -declare module fgui { - class GScrollBar extends GComponent { - private _grip; - private _arrowButton1; - private _arrowButton2; - private _bar; - private _target; - private _vertical; - private _scrollPerc; - private _fixedGripSize; - private _dragOffset; - private _gripDragging; - constructor(); - setScrollPane(target: ScrollPane, vertical: boolean): void; - setDisplayPerc(value: number): void; - setScrollPerc(val: number): void; - readonly minSize: number; - readonly gripDragging: boolean; - protected constructExtension(buffer: ByteBuffer): void; - private __gripMouseDown; - private __gripMouseMove; - private __gripMouseUp; - private __arrowButton1Click; - private __arrowButton2Click; - private __barMouseDown; - } -} -declare module fgui { - class GSlider extends GComponent { - private _min; - private _max; - private _value; - private _titleType; - private _reverse; - private _wholeNumbers; - private _titleObject; - private _barObjectH; - private _barObjectV; - private _barMaxWidth; - private _barMaxHeight; - private _barMaxWidthDelta; - private _barMaxHeightDelta; - private _gripObject; - private _clickPos; - private _clickPercent; - private _barStartX; - private _barStartY; - changeOnClick: boolean; - canDrag: boolean; - constructor(); - titleType: ProgressTitleType; - wholeNumbers: boolean; - min: number; - max: number; - value: number; - update(): void; - private updateWithPercent; - protected constructExtension(buffer: ByteBuffer): void; - protected handleSizeChanged(): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - private __gripMouseDown; - private __gripMouseMove; - private __gripMouseUp; - private __barMouseDown; - } -} -declare module fgui { - class GTextInput extends GTextField { - private _promptText; - private _password; - constructor(); - dispose(): void; - editable: boolean; - maxLength: number; - promptText: string; - restrict: string; - password: boolean; - verticalAlign: VertAlignType; - private updateVertAlign; - protected updateTextFieldText(): void; - protected handleSizeChanged(): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - setup_afterAdd(buffer: ByteBuffer, beginPos: number): void; - private __textChanged; - private __focusIn; - private __focusOut; - } -} -declare namespace fgui { - class GTree extends GList { - treeNodeRender: (node: GTreeNode, obj: GComponent) => void; - treeNodeWillExpand: (node: GTreeNode, expanded: boolean) => void; - private _indent; - private _clickToExpand; - private _rootNode; - private _expandedStatusInEvt; - constructor(); - readonly rootNode: GTreeNode; - indent: number; - clickToExpand: number; - getSelectedNode(): GTreeNode; - getSelectedNodes(result?: Array): Array; - selectNode(node: GTreeNode, scrollItToView?: boolean): void; - unselectNode(node: GTreeNode): void; - expandAll(folderNode?: GTreeNode): void; - collapseAll(folderNode?: GTreeNode): void; - private createCell; - _afterInserted(node: GTreeNode): void; - private getInsertIndexForNode; - _afterRemoved(node: GTreeNode): void; - _afterExpanded(node: GTreeNode): void; - _afterCollapsed(node: GTreeNode): void; - _afterMoved(node: GTreeNode): void; - private getFolderEndIndex; - private checkChildren; - private hideFolderNode; - private removeNode; - private __cellMouseDown; - private __expandedStateChanged; - protected dispatchItemEvent(evt: ItemEvent): void; - setup_beforeAdd(buffer: ByteBuffer, beginPos: number): void; - protected readItems(buffer: ByteBuffer): void; - } -} -declare namespace fgui { - class GTreeNode { - data: any; - private _parent; - private _children; - private _expanded; - private _level; - private _tree; - _cell: GComponent; - _resURL?: string; - constructor(hasChild: boolean, resURL?: string); - expanded: boolean; - readonly isFolder: boolean; - readonly parent: GTreeNode; - text: string; - icon: string; - readonly cell: GComponent; - readonly level: number; - _setLevel(value: number): void; - addChild(child: GTreeNode): GTreeNode; - addChildAt(child: GTreeNode, index: number): GTreeNode; - removeChild(child: GTreeNode): GTreeNode; - removeChildAt(index: number): GTreeNode; - removeChildren(beginIndex?: number, endIndex?: number): void; - getChildAt(index: number): GTreeNode; - getChildIndex(child: GTreeNode): number; - getPrevSibling(): GTreeNode; - getNextSibling(): GTreeNode; - setChildIndex(child: GTreeNode, index: number): void; - swapChildren(child1: GTreeNode, child2: GTreeNode): void; - swapChildrenAt(index1: number, index2: number): void; - readonly numChildren: number; - expandToRoot(): void; - readonly tree: GTree; - _setTree(value: GTree): void; - } -} -declare module fgui { - interface IUISource { - fileName: string; - loaded: boolean; - load(callback: Function, thisObj: any): void; - } -} -declare module fgui { - class Margin { - left: number; - right: number; - top: number; - bottom: number; - constructor(); - copy(source: Margin): void; - } -} -declare namespace fgui { - class PixelHitTest { - private _data; - offsetX: number; - offsetY: number; - scaleX: number; - scaleY: number; - constructor(data: PixelHitTestData, offsetX: number, offsetY: number); - contains(x: number, y: number): boolean; - } - class PixelHitTestData { - pixelWidth: number; - scale: number; - pixels: number[]; - constructor(); - load(ba: ByteBuffer): void; - } -} -declare module fgui { - class PackageItem { - owner: UIPackage; - type: PackageItemType; - objectType?: ObjectType; - id: string; - name: string; - width: number; - height: number; - file: string; - decoded?: boolean; - loading?: Array; - rawData?: ByteBuffer; - asset?: egret.Texture | egret.Sound | dragonBones.DragonBonesData; - highResolution?: Array; - branches?: Array; - scale9Grid?: egret.Rectangle; - scaleByTile?: boolean; - tileGridIndice?: number; - smoothing?: boolean; - pixelHitTestData?: PixelHitTestData; - interval?: number; - repeatDelay?: number; - swing?: boolean; - frames?: Array; - extensionType?: any; - bitmapFont?: BitmapFont; - skeletonAnchor?: egret.Point; - armatureName?: string; - atlasAsset?: dragonBones.TextureAtlasData; - constructor(); - load(): Object; - getBranch(): PackageItem; - getHighResolution(): PackageItem; - toString(): string; - } -} -declare module fgui { - class PopupMenu { - protected _contentPane: GComponent; - protected _list: GList; - constructor(resourceURL?: string); - dispose(): void; - addItem(caption: string, callback?: (item?: ItemEvent) => void): GButton; - addItemAt(caption: string, index: number, callback?: (item?: ItemEvent) => void): GButton; - addSeperator(): void; - getItemName(index: number): string; - setItemText(name: string, caption: string): void; - setItemVisible(name: string, visible: boolean): void; - setItemGrayed(name: string, grayed: boolean): void; - setItemCheckable(name: string, checkable: boolean): void; - setItemChecked(name: string, checked: boolean): void; - isItemChecked(name: string): boolean; - removeItem(name: string): boolean; - clearItems(): void; - readonly itemCount: number; - readonly contentPane: GComponent; - readonly list: GList; - show(target?: GObject, dir?: PopupDirection | boolean): void; - private __clickItem; - private __clickItem2; - private __addedToStage; - } -} -declare module fgui { - class RelationItem { - private _owner; - private _target; - private _defs; - private _targetX; - private _targetY; - private _targetWidth; - private _targetHeight; - constructor(owner: GObject); - readonly owner: GObject; - target: GObject; - add(relationType: number, usePercent: boolean): void; - internalAdd(relationType: number, usePercent: boolean): void; - remove(relationType?: number): void; - copyFrom(source: RelationItem): void; - dispose(): void; - readonly isEmpty: boolean; - applyOnSelfResized(dWidth: number, dHeight: number, applyPivot: boolean): void; - private applyOnXYChanged; - private applyOnSizeChanged; - private addRefTarget; - private releaseRefTarget; - private __targetXYChanged; - private __targetSizeChanged; - private __targetSizeWillChange; - } - class RelationDef { - percent: boolean; - type: number; - axis: number; - constructor(); - copyFrom(source: RelationDef): void; - } -} -declare module fgui { - class Relations { - private _owner; - private _items; - handling: GObject; - sizeDirty: boolean; - constructor(owner: GObject); - add(target: GObject, relationType: number, usePercent?: boolean): void; - remove(target: GObject, relationType?: number): void; - contains(target: GObject): boolean; - clearFor(target: GObject): void; - clearAll(): void; - copyFrom(source: Relations): void; - dispose(): void; - onOwnerSizeChanged(dWidth: number, dHeight: number, applyPivot: boolean): void; - ensureRelationsSizeCorrect(): void; - readonly empty: boolean; - setup(buffer: ByteBuffer, parentToChild: boolean): void; - } -} -declare module fgui { - class ScrollPane extends egret.EventDispatcher { - private _owner; - private _container; - private _maskContainer; - private _alignContainer?; - private _scrollType; - private _scrollStep; - private _decelerationRate; - private _scrollBarMargin; - private _bouncebackEffect; - private _touchEffect; - private _scrollBarDisplayAuto?; - private _vScrollNone; - private _hScrollNone; - private _needRefresh; - private _refreshBarAxis; - private _displayOnLeft?; - private _snapToItem?; - _displayInDemand?: boolean; - private _pageMode?; - private _inertiaDisabled?; - private _floating?; - private _dontClipMargin?; - private _xPos; - private _yPos; - private _viewSize; - private _contentSize; - private _overlapSize; - private _pageSize; - private _containerPos; - private _beginTouchPos; - private _lastTouchPos; - private _lastTouchGlobalPos; - private _velocity; - private _velocityScale; - private _lastMoveTime; - private _isHoldAreaDone; - private _aniFlag; - _loop: number; - private _headerLockedSize; - private _footerLockedSize; - private _refreshEventDispatching; - private _dragged; - private _tweening; - private _tweenTime; - private _tweenDuration; - private _tweenStart; - private _tweenChange; - private _pageController?; - private _hzScrollBar?; - private _vtScrollBar?; - private _header?; - private _footer?; - static draggingPane: ScrollPane; - static SCROLL: string; - static SCROLL_END: string; - static PULL_DOWN_RELEASE: string; - static PULL_UP_RELEASE: string; - constructor(owner: GComponent); - setup(buffer: ByteBuffer): void; - dispose(): void; - readonly owner: GComponent; - readonly hzScrollBar: GScrollBar; - readonly vtScrollBar: GScrollBar; - readonly header: GComponent; - readonly footer: GComponent; - bouncebackEffect: boolean; - touchEffect: boolean; - scrollStep: number; - decelerationRate: number; - snapToItem: boolean; - readonly isDragged: boolean; - percX: number; - setPercX(value: number, ani?: boolean): void; - percY: number; - setPercY(value: number, ani?: boolean): void; - posX: number; - setPosX(value: number, ani?: boolean): void; - posY: number; - setPosY(value: number, ani?: boolean): void; - readonly contentWidth: number; - readonly contentHeight: number; - viewWidth: number; - viewHeight: number; - currentPageX: number; - currentPageY: number; - setCurrentPageX(value: number, ani?: boolean): void; - setCurrentPageY(value: number, ani?: boolean): void; - readonly isBottomMost: boolean; - readonly isRightMost: boolean; - pageController: Controller; - readonly scrollingPosX: number; - readonly scrollingPosY: number; - scrollTop(ani?: boolean): void; - scrollBottom(ani?: boolean): void; - scrollUp(ratio?: number, ani?: boolean): void; - scrollDown(ratio?: number, ani?: boolean): void; - scrollLeft(ratio?: number, ani?: boolean): void; - scrollRight(ratio?: number, ani?: boolean): void; - scrollToView(target: egret.Rectangle | GObject, ani?: boolean, setFirst?: boolean): void; - isChildInView(obj: GObject): boolean; - cancelDragging(): void; - lockHeader(size: number): void; - lockFooter(size: number): void; - onOwnerSizeChanged(): void; - handleControllerChanged(c: Controller): void; - private updatePageController; - adjustMaskContainer(): void; - setSize(aWidth: number, aHeight: number): void; - setContentSize(aWidth: number, aHeight: number): void; - changeContentSizeOnScrolling(deltaWidth: number, deltaHeight: number, deltaPosX: number, deltaPosY: number): void; - private handleSizeChanged; - private posChanged; - private refresh; - private refresh2; - private __touchBegin; - private __touchMove; - private __touchEnd; - private __touchTap; - private updateScrollBarPos; - updateScrollBarVisible(): void; - private updateScrollBarVisible2; - private __barTweenComplete; - private getLoopPartSize; - private loopCheckingCurrent; - private loopCheckingTarget; - private loopCheckingTarget2; - private loopCheckingNewPos; - private alignPosition; - private alignByPage; - private updateTargetAndDuration; - private updateTargetAndDuration2; - private fixDuration; - private startTween; - private killTween; - private checkRefreshBar; - private tweenUpdate; - private runTween; - } -} -declare module fgui { - class Transition { - name: string; - private _owner; - private _ownerBaseX; - private _ownerBaseY; - private _items; - private _totalTimes; - private _totalTasks; - private _playing; - private _paused; - private _onComplete; - private _onCompleteCaller; - private _onCompleteParam; - private _options; - private _reversed; - private _totalDuration; - private _autoPlay; - private _autoPlayTimes; - private _autoPlayDelay; - private _timeScale; - private _startTime; - private _endTime; - constructor(owner: GComponent); - play(onComplete?: () => void, onCompleteObj?: any, onCompleteParam?: any, times?: number, delay?: number, startTime?: number, endTime?: number): void; - playReverse(onComplete?: () => void, onCompleteObj?: any, onCompleteParam?: any, times?: number, delay?: number): void; - changePlayTimes(value: number): void; - setAutoPlay(value: boolean, times?: number, delay?: number): void; - private _play; - stop(setToComplete?: boolean, processCallback?: boolean): void; - private stopItem; - setPaused(paused: boolean): void; - dispose(): void; - readonly playing: boolean; - setValue(label: string, ...args: any[]): void; - setHook(label: string, callback: Function, caller?: any): void; - clearHooks(): void; - setTarget(label: string, newTarget: GObject): void; - setDuration(label: string, value: number): void; - getLabelTime(label: string): number; - timeScale: number; - updateFromRelations(targetId: string, dx: number, dy: number): void; - onOwnerAddedToStage(): void; - onOwnerRemovedFromStage(): void; - private onDelayedPlay; - private internalPlay; - private playItem; - private skipAnimations; - private onDelayedPlayItem; - private onTweenStart; - private onTweenUpdate; - private onTweenComplete; - private onPlayTransCompleted; - private callHook; - private checkAllComplete; - private applyValue; - setup(buffer: ByteBuffer): void; - private decodeValue; - } -} -declare module fgui { - class TranslationHelper { - static strings: { - [index: string]: { - [index: string]: string; - }; - }; - static loadFromXML(source: string): void; - static translateComponent(item: PackageItem): void; - } -} -declare module fgui { - class UIConfig { - constructor(); - static defaultFont: string; - static windowModalWaiting: string; - static globalModalWaiting: string; - static modalLayerColor: number; - static modalLayerAlpha: number; - static buttonSound: string; - static buttonSoundVolumeScale: number; - static horizontalScrollBar: string; - static verticalScrollBar: string; - static defaultScrollStep: number; - static defaultScrollDecelerationRate: number; - static defaultScrollBarDisplay: number; - static defaultScrollTouchEffect: boolean; - static defaultScrollBounceEffect: boolean; - static popupMenu: string; - static popupMenu_seperator: string; - static loaderErrorSign: string; - static tooltipsWin: string; - static defaultComboBoxVisibleItemCount: number; - static touchScrollSensitivity: number; - static touchDragSensitivity: number; - static clickDragSensitivity: number; - static bringWindowToFrontOnClick: boolean; - static frameTimeForAsyncUIConstruction: number; - } -} -declare module fgui { - class UIObjectFactory { - static extensions: { - [index: string]: new () => GComponent; - }; - static loaderType: new () => GLoader; - constructor(); - static setExtension(url: string, type: new () => GComponent): void; - static setPackageItemExtension(url: string, type: new () => GComponent): void; - static setLoaderExtension(type: new () => GLoader): void; - static resolvePackageItemExtension(pi: PackageItem): void; - static newObject(type: number | PackageItem, userClass?: new () => GObject): GObject; - } -} -declare module fgui { - class UIPackage { - private _id; - private _name; - private _items; - private _itemsById; - private _itemsByName; - private _resKey; - private _customId; - private _sprites; - private _dependencies; - private _branches; - _branchIndex: number; - static _constructing: number; - private static _instById; - private static _instByName; - private static _branch; - private static _vars; - constructor(); - static branch: string; - static getVar(key: string): string; - static setVar(key: string, value: string): void; - static getById(id: string): UIPackage; - static getByName(name: string): UIPackage; - static loadPackage(resKey: string): Promise; - static addPackage(resKey: string, descData?: ArrayBuffer): UIPackage; - static removePackage(packageIdOrName: string): void; - static createObject(pkgName: string, resName: string, userClass?: new () => GObject): GObject; - static createObjectFromURL(url: string, userClass?: new () => GObject): GObject; - static getItemURL(pkgName: string, resName: string): string; - static getItemByURL(url: string): PackageItem; - static normalizeURL(url: string): string; - static setStringsSource(source: string): void; - private loadPackage; - dispose(): void; - readonly id: string; - readonly name: string; - customId: string; - createObject(resName: string, userClass?: new () => GObject): GObject; - internalCreateObject(item: PackageItem, userClass?: new () => GObject): GObject; - getItemById(itemId: string): PackageItem; - getItemByName(resName: string): PackageItem; - getItemAssetByName(resName: string): Object; - getItemAsset(item: PackageItem): Object; - getItemAssetAsync(item: PackageItem, onComplete?: (err: any, item: PackageItem) => void): void; - private loadMovieClip; - private loadFont; - private loadDragonBones; - } -} -declare module fgui { - class Window extends GComponent { - private _contentPane; - private _modalWaitPane; - private _closeButton; - private _dragArea; - private _contentArea; - private _frame; - private _modal; - private _uiSources?; - private _inited?; - private _loading?; - protected _requestingCmd: number; - bringToFontOnClick: boolean; - constructor(); - addUISource(source: IUISource): void; - contentPane: GComponent; - readonly frame: GComponent; - closeButton: GObject; - dragArea: GObject; - contentArea: GObject; - show(): void; - showOn(root: GRoot): void; - hide(): void; - hideImmediately(): void; - centerOn(r: GRoot, restraint?: boolean): void; - toggleStatus(): void; - readonly isShowing: boolean; - readonly isTop: boolean; - modal: boolean; - bringToFront(): void; - showModalWait(requestingCmd?: number): void; - protected layoutModalWaitPane(): void; - closeModalWait(requestingCmd?: number): boolean; - readonly modalWaiting: boolean; - init(): void; - protected onInit(): void; - protected onShown(): void; - protected onHide(): void; - protected doShowAnimation(): void; - protected doHideAnimation(): void; - private __uiLoadComplete; - private _init; - dispose(): void; - protected closeEventHandler(evt: egret.Event): void; - private __onShown; - private __onHidden; - private __mouseDown; - private __dragStart; - } -} -declare module fgui { - class ControllerAction { - fromPage: string[]; - toPage: string[]; - static createAction(type: number): ControllerAction; - constructor(); - run(controller: Controller, prevPage: string, curPage: string): void; - protected enter(controller: Controller): void; - protected leave(controller: Controller): void; - setup(buffer: ByteBuffer): void; - } -} -declare module fgui { - class ChangePageAction extends ControllerAction { - objectId: string; - controllerName: string; - targetPage: string; - constructor(); - protected enter(controller: Controller): void; - setup(buffer: ByteBuffer): void; - } -} -declare module fgui { - class PlayTransitionAction extends ControllerAction { - transitionName: string; - playTimes: number; - delay: number; - stopOnExit: boolean; - private _currentTransition; - constructor(); - protected enter(controller: Controller): void; - protected leave(controller: Controller): void; - setup(buffer: ByteBuffer): void; - } -} -declare module fgui { - class BitmapFont { - id: string; - size: number; - ttf: boolean; - glyphs: { - [index: string]: BMGlyph; - }; - resizable: boolean; - tint: boolean; - constructor(); - } - interface BMGlyph { - x?: number; - y?: number; - width?: number; - height?: number; - advance?: number; - lineHeight?: number; - channel?: number; - texture?: egret.Texture; - } -} -declare namespace fgui { - function fillImage(w: number, h: number, method: number, origin: number, clockwise: boolean, amount: number): Array; -} -declare module fgui { - class Image extends egret.Bitmap { - private _fillMethod; - private _fillOrigin; - private _fillAmount; - private _fillClockwise?; - private _mask?; - private _maskDirtyFlag?; - private _color; - constructor(); - color: number; - $setX(value: number): boolean; - $setY(value: number): boolean; - fillMethod: FillMethod; - fillOrigin: number; - fillClockwise: boolean; - fillAmount: number; - private markChanged; - private doFill; - } -} -declare module fgui { - interface Frame { - addDelay?: number; - texture?: egret.Texture; - } - class MovieClip extends Image { - interval: number; - swing: boolean; - repeatDelay: number; - timeScale: number; - private _playing; - private _frameCount; - private _frames; - private _frame; - private _start; - private _end; - private _times; - private _endAt; - private _status; - private _callback; - private _callbackObj; - private _smoothing; - private _frameElapsed; - private _reversed; - private _repeatedCount; - constructor(); - frames: Array; - readonly frameCount: number; - frame: number; - playing: boolean; - smoothing: boolean; - rewind(): void; - syncStatus(anotherMc: MovieClip): void; - advance(timeInMiniseconds: number): void; - setPlaySettings(start?: number, end?: number, times?: number, endAt?: number, endCallback?: Function, callbackObj?: any): void; - private update; - private drawFrame; - private checkTimer; - $onAddToStage(stage: egret.Stage, nestLevel: number): void; - $onRemoveFromStage(): void; - } -} -declare module fgui { - class UIContainer extends egret.DisplayObjectContainer { - private _hitArea?; - private _cachedMatrix?; - private _cachedHitArea?; - private _opaque?; - constructor(); - cacheHitArea(value: boolean): void; - hitArea: PixelHitTest | egret.DisplayObject; - opaque: boolean; - $hitTest(stageX: number, stageY: number): egret.DisplayObject; - } -} -declare module fgui { - class DragEvent extends egret.Event { - stageX: number; - stageY: number; - touchPointID: number; - private _prevented; - static DRAG_START: string; - static DRAG_END: string; - static DRAG_MOVING: string; - constructor(type: string, stageX?: number, stageY?: number, touchPointID?: number); - preventDefault(): void; - isDefaultPrevented(): boolean; - } -} -declare module fgui { - class DropEvent extends egret.Event { - source: any; - static DROP: string; - constructor(type: string, source?: any); - } -} -declare module fgui { - class ItemEvent extends egret.Event { - itemObject: GObject; - stageX: number; - stageY: number; - static CLICK: string; - constructor(type: string, itemObject?: GObject, stageX?: number, stageY?: number); - } -} -declare module fgui { - class StateChangeEvent extends egret.Event { - static CHANGED: string; - constructor(type: string); - } -} -declare namespace fgui { - class GearBase { - static disableAllTweenEffect: boolean; - protected _owner: GObject; - protected _controller: Controller; - protected _tweenConfig?: GearTweenConfig; - static create(owner: GObject, index: number): GearBase; - constructor(owner: GObject); - dispose(): void; - controller: Controller; - readonly tweenConfig: GearTweenConfig; - setup(buffer: ByteBuffer): void; - updateFromRelations(dx: number, dy: number): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - protected init(): void; - apply(): void; - updateState(): void; - } - class GearTweenConfig { - tween: boolean; - easeType: number; - duration: number; - delay: number; - _displayLockToken: number; - _tweener: GTweener; - constructor(); - } -} -declare namespace fgui { - class GearAnimation extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - updateState(): void; - } -} -declare namespace fgui { - class GearColor extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - updateState(): void; - } -} -declare namespace fgui { - class GearDisplay extends GearBase { - pages: string[]; - private _visible; - private _displayLockToken; - constructor(owner: GObject); - protected init(): void; - apply(): void; - addLock(): number; - releaseLock(token: number): void; - readonly connected: boolean; - } -} -declare namespace fgui { - class GearDisplay2 extends GearBase { - pages: string[]; - condition: number; - private _visible; - constructor(owner: GObject); - protected init(): void; - apply(): void; - evaluate(connected: boolean): boolean; - } -} -declare namespace fgui { - class GearFontSize extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - updateState(): void; - } -} -declare namespace fgui { - class GearIcon extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - updateState(): void; - } -} -declare namespace fgui { - class GearLook extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - private __tweenUpdate; - private __tweenComplete; - updateState(): void; - } -} -declare namespace fgui { - class GearSize extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - private __tweenUpdate; - private __tweenComplete; - updateState(): void; - updateFromRelations(dx: number, dy: number): void; - } -} -declare namespace fgui { - class GearText extends GearBase { - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - updateState(): void; - } -} -declare namespace fgui { - class GearXY extends GearBase { - positionsInPercent: boolean; - private _storage; - private _default; - constructor(owner: GObject); - protected init(): void; - protected addStatus(pageId: string, buffer: ByteBuffer): void; - addExtStatus(pageId: string, buffer: ByteBuffer): void; - apply(): void; - private __tweenUpdate; - private __tweenComplete; - updateState(): void; - updateFromRelations(dx: number, dy: number): void; - } -} -declare namespace fgui { - function evaluateEase(easeType: number, time: number, duration: number, overshootOrAmplitude: number, period: number): number; -} -declare namespace fgui { - class EaseType { - static Linear: number; - static SineIn: number; - static SineOut: number; - static SineInOut: number; - static QuadIn: number; - static QuadOut: number; - static QuadInOut: number; - static CubicIn: number; - static CubicOut: number; - static CubicInOut: number; - static QuartIn: number; - static QuartOut: number; - static QuartInOut: number; - static QuintIn: number; - static QuintOut: number; - static QuintInOut: number; - static ExpoIn: number; - static ExpoOut: number; - static ExpoInOut: number; - static CircIn: number; - static CircOut: number; - static CircInOut: number; - static ElasticIn: number; - static ElasticOut: number; - static ElasticInOut: number; - static BackIn: number; - static BackOut: number; - static BackInOut: number; - static BounceIn: number; - static BounceOut: number; - static BounceInOut: number; - static Custom: number; - } -} -declare namespace fgui { - class GPath { - private _segments; - private _points; - private _fullLength; - constructor(); - readonly length: number; - create(pt1: Array | GPathPoint, pt2?: GPathPoint, pt3?: GPathPoint, pt4?: GPathPoint): void; - private createSplineSegment; - clear(): void; - getPointAt(t: number, result?: egret.Point): egret.Point; - readonly segmentCount: number; - getAnchorsInSegment(segmentIndex: number, points?: Array): Array; - getPointsInSegment(segmentIndex: number, t0: number, t1: number, points?: Array, ts?: Array, pointDensity?: number): Array; - getAllPoints(points?: Array, ts?: Array, pointDensity?: number): Array; - private onCRSplineCurve; - private onBezierCurve; - } -} -declare namespace fgui { - enum CurveType { - CRSpline = 0, - Bezier = 1, - CubicBezier = 2, - Straight = 3 - } - class GPathPoint { - x: number; - y: number; - control1_x: number; - control1_y: number; - control2_x: number; - control2_y: number; - curveType: number; - constructor(); - static newPoint(x?: number, y?: number, curveType?: number): GPathPoint; - static newBezierPoint(x?: number, y?: number, control1_x?: number, control1_y?: number): GPathPoint; - static newCubicBezierPoint(x?: number, y?: number, control1_x?: number, control1_y?: number, control2_x?: number, control2_y?: number): GPathPoint; - clone(): GPathPoint; - } -} -declare namespace fgui { - class GTween { - static catchCallbackExceptions: boolean; - static to(start: number, end: number, duration: number): GTweener; - static to2(start: number, start2: number, end: number, end2: number, duration: number): GTweener; - static to3(start: number, start2: number, start3: number, end: number, end2: number, end3: number, duration: number): GTweener; - static to4(start: number, start2: number, start3: number, start4: number, end: number, end2: number, end3: number, end4: number, duration: number): GTweener; - static toColor(start: number, end: number, duration: number): GTweener; - static delayedCall(delay: number): GTweener; - static shake(startX: number, startY: number, amplitude: number, duration: number): GTweener; - static isTweening(target: any, propType?: any): Boolean; - static kill(target: any, complete?: boolean, propType?: any): void; - static getTween(target: any, propType?: any): GTweener; - } -} -declare module fgui { - class GTweener { - _target: any; - _propType: any; - _killed: boolean; - _paused: boolean; - private _delay; - private _duration; - private _breakpoint; - private _easeType; - private _easeOvershootOrAmplitude; - private _easePeriod; - private _repeat; - private _yoyo; - private _timeScale; - private _snapping; - private _userData; - private _path; - private _onUpdate; - private _onStart; - private _onComplete; - private _onUpdateCaller; - private _onStartCaller; - private _onCompleteCaller; - private _startValue; - private _endValue; - private _value; - private _deltaValue; - private _valueSize; - private _started; - private _ended; - private _elapsedTime; - private _normalizedTime; - constructor(); - setDelay(value: number): GTweener; - readonly delay: number; - setDuration(value: number): GTweener; - readonly duration: number; - setBreakpoint(value: number): GTweener; - setEase(value: number): GTweener; - setEasePeriod(value: number): GTweener; - setEaseOvershootOrAmplitude(value: number): GTweener; - setRepeat(repeat: number, yoyo?: boolean): GTweener; - readonly repeat: number; - setTimeScale(value: number): GTweener; - setSnapping(value: boolean): GTweener; - setTarget(value: any, propType?: any): GTweener; - readonly target: any; - setUserData(value: any): GTweener; - readonly userData: any; - setPath(value: GPath): GTweener; - onUpdate(callback: Function, caller?: any): GTweener; - onStart(callback: Function, caller?: any): GTweener; - onComplete(callback: Function, caller?: any): GTweener; - readonly startValue: TweenValue; - readonly endValue: TweenValue; - readonly value: TweenValue; - readonly deltaValue: TweenValue; - readonly normalizedTime: number; - readonly completed: boolean; - readonly allCompleted: boolean; - setPaused(paused: boolean): GTweener; - seek(time: number): void; - kill(complete?: boolean): void; - _to(start: number, end: number, duration: number): GTweener; - _to2(start: number, start2: number, end: number, end2: number, duration: number): GTweener; - _to3(start: number, start2: number, start3: number, end: number, end2: number, end3: number, duration: number): GTweener; - _to4(start: number, start2: number, start3: number, start4: number, end: number, end2: number, end3: number, end4: number, duration: number): GTweener; - _toColor(start: number, end: number, duration: number): GTweener; - _shake(startX: number, startY: number, amplitude: number, duration: number): GTweener; - _init(): void; - _reset(): void; - _update(dt: number): void; - private update; - private callStartCallback; - private callUpdateCallback; - private callCompleteCallback; - } -} -declare module fgui { - class TweenManager { - static createTween(): GTweener; - static isTweening(target: any, propType?: any): boolean; - static killTweens(target: any, completed?: boolean, propType?: any): boolean; - static getTween(target: any, propType?: any): GTweener; - private static update; - } -} -declare namespace fgui { - class TweenValue { - x: number; - y: number; - z: number; - w: number; - constructor(); - color: number; - getField(index: number): number; - setField(index: number, value: number): void; - setZero(): void; - } -} -declare module fgui { - class ByteBuffer extends egret.ByteArray { - stringTable?: Array; - version: number; - constructor(buffer?: ArrayBuffer | Uint8Array, bufferExtSize?: number); - skip(count: number): void; - readBool(): boolean; - readS(): string; - readSArray(cnt: number): Array; - writeS(value: string): void; - readColor(hasAlpha?: boolean): number; - readChar(): string; - readBuffer(): ByteBuffer; - seek(indexTablePos: number, blockIndex: number): boolean; - } -} -declare namespace fgui { - class ColorMatrix { - readonly matrix: Array; - constructor(p_brightness?: number, p_contrast?: number, p_saturation?: number, p_hue?: number); - reset(): void; - invert(): void; - adjustColor(p_brightness: number, p_contrast: number, p_saturation: number, p_hue: number): void; - adjustBrightness(p_val: number): void; - adjustContrast(p_val: number): void; - adjustSaturation(p_val: number): void; - adjustHue(p_val: number): void; - concat(p_matrix: Array): void; - clone(): ColorMatrix; - protected copyMatrix(p_matrix: Array): void; - protected multiplyMatrix(p_matrix: Array): void; - protected cleanValue(p_val: number, p_limit: number): number; - } -} -declare module fgui { - class GTimers { - private _items; - private _itemPool; - private _enumI; - private _enumCount; - private _lastTime; - static deltaTime: number; - static time: number; - static readonly inst: GTimers; - constructor(); - private getItem; - private findItem; - add(delayInMiniseconds: number, repeat: number, callback: Function, thisObj?: any, callbackParam?: any): void; - callLater(callback: Function, thisObj?: any, callbackParam?: any): void; - callDelay(delay: number, callback: Function, thisObj?: any, callbackParam?: any): void; - exists(callback: Function, thisObj?: any): boolean; - remove(callback: Function, thisObj?: any): void; - private __timer; - } -} -declare module fgui { - class UBBParser { - private _text; - private _readPos; - protected _handlers: { - [index: string]: (tagName: string, end: boolean, attr: string) => string; - }; - smallFontSize: number; - normalFontSize: number; - largeFontSize: number; - defaultImgWidth: number; - defaultImgHeight: number; - static inst: UBBParser; - constructor(); - protected onTag_URL(tagName: string, end: boolean, attr: string): string; - protected onTag_IMG(tagName: string, end: boolean, attr: string): string; - protected onTag_Simple(tagName: string, end: boolean, attr: string): string; - protected onTag_COLOR(tagName: string, end: boolean, attr: string): string; - protected onTag_FONT(tagName: string, end: boolean, attr: string): string; - protected onTag_SIZE(tagName: string, end: boolean, attr: string): string; - protected getTagText(remove?: boolean): string; - parse(text: string, remove?: boolean): string; - } -} -declare module fgui { - class ToolSet { - static startsWith(source: string, str: string, ignoreCase?: boolean): boolean; - static trimRight(targetString: string): string; - static convertToHtmlColor(argb: number, hasAlpha?: boolean): string; - static convertFromHtmlColor(str: string, hasAlpha?: boolean): number; - static displayObjectToGObject(obj: egret.DisplayObject): GObject; - static encodeHTML(str: string): string; - static clamp(value: number, min: number, max: number): number; - static clamp01(value: number): number; - static lerp(start: number, end: number, percent: number): number; - static repeat(t: number, length: number): number; - static distance(x1: number, y1: number, x2: number, y2: number): number; - static fillPath(ctx: egret.Graphics, points: number[], px: number, py: number): void; - static setColorFilter(obj: egret.DisplayObject, color?: number | number[] | boolean): void; - } -} -import fairygui = fgui; \ No newline at end of file diff --git a/demo/libs/fairygui/fairygui.js b/demo/libs/fairygui/fairygui.js deleted file mode 100644 index 49b99782..00000000 --- a/demo/libs/fairygui/fairygui.js +++ /dev/null @@ -1,19026 +0,0 @@ -window.fgui = {}; -window.fairygui = window.fgui; -window.__extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; - -(function (fgui) { - var AsyncOperation = (function () { - function AsyncOperation() { - this._itemList = new Array(); - this._objectPool = new Array(); - } - AsyncOperation.prototype.createObject = function (pkgName, resName) { - var pkg = fgui.UIPackage.getByName(pkgName); - if (pkg) { - var pi = pkg.getItemByName(resName); - if (!pi) - throw new Error("resource not found: " + resName); - this.internalCreateObject(pi); - } - else - throw new Error("package not found: " + pkgName); - }; - AsyncOperation.prototype.createObjectFromURL = function (url) { - var pi = fgui.UIPackage.getItemByURL(url); - if (pi) - this.internalCreateObject(pi); - else - throw new Error("resource not found: " + url); - }; - AsyncOperation.prototype.cancel = function () { - fgui.GTimers.inst.remove(this.run, this); - this._itemList.length = 0; - var cnt = this._objectPool.length; - if (cnt > 0) { - for (var i = 0; i < cnt; i++) - this._objectPool[i].dispose(); - this._objectPool.length = 0; - } - }; - AsyncOperation.prototype.internalCreateObject = function (item) { - this._itemList.length = 0; - this._objectPool.length = 0; - var di = { pi: item, type: item.objectType }; - di.childCount = this.collectComponentChildren(item); - this._itemList.push(di); - this._index = 0; - fgui.GTimers.inst.add(1, 0, this.run, this); - }; - AsyncOperation.prototype.collectComponentChildren = function (item) { - var buffer = item.rawData; - buffer.seek(0, 2); - var di; - var pi; - var i; - var dataLen; - var curPos; - var pkg; - var dcnt = buffer.readShort(); - for (i = 0; i < dcnt; i++) { - dataLen = buffer.readShort(); - curPos = buffer.position; - buffer.seek(curPos, 0); - var type = buffer.readByte(); - var src = buffer.readS(); - var pkgId = buffer.readS(); - buffer.position = curPos; - if (src != null) { - if (pkgId != null) - pkg = fgui.UIPackage.getById(pkgId); - else - pkg = item.owner; - pi = pkg != null ? pkg.getItemById(src) : null; - di = { pi: pi, type: type }; - if (pi != null && pi.type == fgui.PackageItemType.Component) - di.childCount = this.collectComponentChildren(pi); - } - else { - di = { type: type }; - if (type == fgui.ObjectType.List) - di.listItemCount = this.collectListChildren(buffer); - } - this._itemList.push(di); - buffer.position = curPos + dataLen; - } - return dcnt; - }; - AsyncOperation.prototype.collectListChildren = function (buffer) { - buffer.seek(buffer.position, 8); - var listItemCount = 0; - var i; - var nextPos; - var url; - var pi; - var di; - var defaultItem = buffer.readS(); - var itemCount = buffer.readShort(); - for (i = 0; i < itemCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - url = buffer.readS(); - if (url == null) - url = defaultItem; - if (url) { - pi = fgui.UIPackage.getItemByURL(url); - if (pi) { - di = { pi: pi, type: pi.objectType }; - if (pi.type == fgui.PackageItemType.Component) - di.childCount = this.collectComponentChildren(pi); - this._itemList.push(di); - listItemCount++; - } - } - buffer.position = nextPos; - } - return listItemCount; - }; - AsyncOperation.prototype.run = function () { - var obj; - var di; - var poolStart; - var k; - var t = egret.getTimer(); - var frameTime = fgui.UIConfig.frameTimeForAsyncUIConstruction; - var totalItems = this._itemList.length; - while (this._index < totalItems) { - di = this._itemList[this._index]; - if (di.pi) { - obj = fgui.UIObjectFactory.newObject(di.pi); - this._objectPool.push(obj); - fgui.UIPackage._constructing++; - if (di.pi.type == fgui.PackageItemType.Component) { - poolStart = this._objectPool.length - di.childCount - 1; - obj.constructFromResource2(this._objectPool, poolStart); - this._objectPool.splice(poolStart, di.childCount); - } - else { - obj.constructFromResource(); - } - fgui.UIPackage._constructing--; - } - else { - obj = fgui.UIObjectFactory.newObject(di.type); - this._objectPool.push(obj); - if (di.type == fgui.ObjectType.List && di.listItemCount > 0) { - poolStart = this._objectPool.length - di.listItemCount - 1; - for (k = 0; k < di.listItemCount; k++) - obj.itemPool.returnObject(this._objectPool[k + poolStart]); - this._objectPool.splice(poolStart, di.listItemCount); - } - } - this._index++; - if ((this._index % 5 == 0) && egret.getTimer() - t >= frameTime) - return; - } - fgui.GTimers.inst.remove(this.run, this); - var result = this._objectPool[0]; - this._itemList.length = 0; - this._objectPool.length = 0; - if (this.callback != null) - this.callback.call(this.callbackObj, result); - }; - return AsyncOperation; - }()); - fgui.AsyncOperation = AsyncOperation; -})(fgui || (fgui = {})); - -(function (fgui) { - var _nextPageId = 0; - var Controller = (function (_super_1) { - __extends(Controller, _super_1); - function Controller() { - var _this = _super_1.call(this) || this; - _this._pageIds = []; - _this._pageNames = []; - _this._selectedIndex = -1; - _this._previousIndex = -1; - return _this; - } - Controller.prototype.dispose = function () { - }; - Object.defineProperty(Controller.prototype, "selectedIndex", { - get: function () { - return this._selectedIndex; - }, - set: function (value) { - if (this._selectedIndex != value) { - if (value > this._pageIds.length - 1) - throw "index out of bounds: " + value; - this.changing = true; - this._previousIndex = this._selectedIndex; - this._selectedIndex = value; - this.parent.applyController(this); - this.dispatchEvent(new fgui.StateChangeEvent(fgui.StateChangeEvent.CHANGED)); - this.changing = false; - } - }, - enumerable: true, - configurable: true - }); - Controller.prototype.setSelectedIndex = function (value) { - if (this._selectedIndex != value) { - if (value > this._pageIds.length - 1) - throw "index out of bounds: " + value; - this.changing = true; - this._previousIndex = this._selectedIndex; - this._selectedIndex = value; - this.parent.applyController(this); - this.changing = false; - } - }; - Object.defineProperty(Controller.prototype, "previsousIndex", { - get: function () { - return this._previousIndex; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Controller.prototype, "selectedPage", { - get: function () { - if (this._selectedIndex == -1) - return null; - else - return this._pageNames[this._selectedIndex]; - }, - set: function (val) { - var i = this._pageNames.indexOf(val); - if (i == -1) - i = 0; - this.selectedIndex = i; - }, - enumerable: true, - configurable: true - }); - Controller.prototype.setSelectedPage = function (value) { - var i = this._pageNames.indexOf(value); - if (i == -1) - i = 0; - this.setSelectedIndex(i); - }; - Object.defineProperty(Controller.prototype, "previousPage", { - get: function () { - if (this._previousIndex == -1) - return null; - else - return this._pageNames[this._previousIndex]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Controller.prototype, "pageCount", { - get: function () { - return this._pageIds.length; - }, - enumerable: true, - configurable: true - }); - Controller.prototype.getPageName = function (index) { - return this._pageNames[index]; - }; - Controller.prototype.addPage = function (name) { - this.addPageAt(name || "", this._pageIds.length); - }; - Controller.prototype.addPageAt = function (name, index) { - var nid = "" + (_nextPageId++); - if (index == this._pageIds.length) { - this._pageIds.push(nid); - this._pageNames.push(name); - } - else { - this._pageIds.splice(index, 0, nid); - this._pageNames.splice(index, 0, name); - } - }; - Controller.prototype.removePage = function (name) { - var i = this._pageNames.indexOf(name); - if (i != -1) { - this._pageIds.splice(i, 1); - this._pageNames.splice(i, 1); - if (this._selectedIndex >= this._pageIds.length) - this.selectedIndex = this._selectedIndex - 1; - else - this.parent.applyController(this); - } - }; - Controller.prototype.removePageAt = function (index) { - if (index === void 0) { index = 0; } - this._pageIds.splice(index, 1); - this._pageNames.splice(index, 1); - if (this._selectedIndex >= this._pageIds.length) - this.selectedIndex = this._selectedIndex - 1; - else - this.parent.applyController(this); - }; - Controller.prototype.clearPages = function () { - this._pageIds.length = 0; - this._pageNames.length = 0; - if (this._selectedIndex != -1) - this.selectedIndex = -1; - else - this.parent.applyController(this); - }; - Controller.prototype.hasPage = function (aName) { - return this._pageNames.indexOf(aName) != -1; - }; - Controller.prototype.getPageIndexById = function (aId) { - return this._pageIds.indexOf(aId); - }; - Controller.prototype.getPageIdByName = function (aName) { - var i = this._pageNames.indexOf(aName); - if (i != -1) - return this._pageIds[i]; - else - return null; - }; - Controller.prototype.getPageNameById = function (aId) { - var i = this._pageIds.indexOf(aId); - if (i != -1) - return this._pageNames[i]; - else - return null; - }; - Controller.prototype.getPageId = function (index) { - if (index === void 0) { index = 0; } - return this._pageIds[index]; - }; - Object.defineProperty(Controller.prototype, "selectedPageId", { - get: function () { - if (this._selectedIndex == -1) - return null; - else - return this._pageIds[this._selectedIndex]; - }, - set: function (val) { - var i = this._pageIds.indexOf(val); - this.selectedIndex = i; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Controller.prototype, "oppositePageId", { - set: function (val) { - var i = this._pageIds.indexOf(val); - if (i > 0) - this.selectedIndex = 0; - else if (this._pageIds.length > 1) - this.selectedIndex = 1; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Controller.prototype, "previousPageId", { - get: function () { - if (this._previousIndex == -1) - return null; - else - return this._pageIds[this._previousIndex]; - }, - enumerable: true, - configurable: true - }); - Controller.prototype.runActions = function () { - if (this._actions) { - var cnt = this._actions.length; - for (var i = 0; i < cnt; i++) - this._actions[i].run(this, this.previousPageId, this.selectedPageId); - } - }; - Controller.prototype.setup = function (buffer) { - var beginPos = buffer.position; - buffer.seek(beginPos, 0); - this.name = buffer.readS(); - if (buffer.readBool()) - this.autoRadioGroupDepth = true; - buffer.seek(beginPos, 1); - var i; - var nextPos; - var cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - this._pageIds.push(buffer.readS()); - this._pageNames.push(buffer.readS()); - } - var homePageIndex = 0; - if (buffer.version >= 2) { - var homePageType = buffer.readByte(); - switch (homePageType) { - case 1: - homePageIndex = buffer.readShort(); - break; - case 2: - homePageIndex = this._pageNames.indexOf(fgui.UIPackage.branch); - if (homePageIndex == -1) - homePageIndex = 0; - break; - case 3: - homePageIndex = this._pageNames.indexOf(fgui.UIPackage.getVar(buffer.readS())); - if (homePageIndex == -1) - homePageIndex = 0; - break; - } - } - buffer.seek(beginPos, 2); - cnt = buffer.readShort(); - if (cnt > 0) { - if (!this._actions) - this._actions = new Array(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - var action = fgui.ControllerAction.createAction(buffer.readByte()); - action.setup(buffer); - this._actions.push(action); - buffer.position = nextPos; - } - } - if (this.parent && this._pageIds.length > 0) - this._selectedIndex = homePageIndex; - else - this._selectedIndex = -1; - }; - return Controller; - }(egret.EventDispatcher)); - fgui.Controller = Controller; -})(fgui || (fgui = {})); - -(function (fgui) { - var DragDropManager = (function () { - function DragDropManager() { - this._agent = new fgui.GLoader(); - this._agent.draggable = true; - this._agent.touchable = false; - this._agent.setSize(100, 100); - this._agent.setPivot(0.5, 0.5, true); - this._agent.align = fgui.AlignType.Center; - this._agent.verticalAlign = fgui.VertAlignType.Middle; - this._agent.sortingOrder = 1000000; - this._agent.addEventListener(fgui.DragEvent.DRAG_END, this.__dragEnd, this); - } - Object.defineProperty(DragDropManager, "inst", { - get: function () { - if (DragDropManager._inst == null) - DragDropManager._inst = new DragDropManager(); - return DragDropManager._inst; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DragDropManager.prototype, "dragAgent", { - get: function () { - return this._agent; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DragDropManager.prototype, "dragging", { - get: function () { - return this._agent.parent != null; - }, - enumerable: true, - configurable: true - }); - DragDropManager.prototype.startDrag = function (source, icon, sourceData, touchPointID) { - if (this._agent.parent) - return; - this._sourceData = sourceData; - this._agent.url = icon; - fgui.GRoot.inst.addChild(this._agent); - var pt = fgui.GRoot.inst.globalToLocal(fgui.GRoot.mouseX, fgui.GRoot.mouseY); - this._agent.setXY(pt.x, pt.y); - this._agent.startDrag(touchPointID); - }; - DragDropManager.prototype.cancel = function () { - if (this._agent.parent) { - this._agent.stopDrag(); - fgui.GRoot.inst.removeChild(this._agent); - this._sourceData = null; - } - }; - DragDropManager.prototype.__dragEnd = function (evt) { - if (this._agent.parent == null) - return; - fgui.GRoot.inst.removeChild(this._agent); - var sourceData = this._sourceData; - this._sourceData = null; - var obj = fgui.GRoot.inst.getObjectUnderPoint(evt.stageX, evt.stageY); - while (obj) { - if (obj.hasEventListener(fgui.DropEvent.DROP)) { - var dropEvt = new fgui.DropEvent(fgui.DropEvent.DROP, sourceData); - obj.requestFocus(); - obj.dispatchEvent(dropEvt); - return; - } - obj = obj.parent; - } - }; - return DragDropManager; - }()); - fgui.DragDropManager = DragDropManager; -})(fgui || (fgui = {})); - -(function (fgui) { - var ButtonMode; - (function (ButtonMode) { - ButtonMode[ButtonMode["Common"] = 0] = "Common"; - ButtonMode[ButtonMode["Check"] = 1] = "Check"; - ButtonMode[ButtonMode["Radio"] = 2] = "Radio"; - })(ButtonMode = fgui.ButtonMode || (fgui.ButtonMode = {})); - var AutoSizeType; - (function (AutoSizeType) { - AutoSizeType[AutoSizeType["None"] = 0] = "None"; - AutoSizeType[AutoSizeType["Both"] = 1] = "Both"; - AutoSizeType[AutoSizeType["Height"] = 2] = "Height"; - })(AutoSizeType = fgui.AutoSizeType || (fgui.AutoSizeType = {})); - var AlignType; - (function (AlignType) { - AlignType[AlignType["Left"] = 0] = "Left"; - AlignType[AlignType["Center"] = 1] = "Center"; - AlignType[AlignType["Right"] = 2] = "Right"; - })(AlignType = fgui.AlignType || (fgui.AlignType = {})); - var VertAlignType; - (function (VertAlignType) { - VertAlignType[VertAlignType["Top"] = 0] = "Top"; - VertAlignType[VertAlignType["Middle"] = 1] = "Middle"; - VertAlignType[VertAlignType["Bottom"] = 2] = "Bottom"; - })(VertAlignType = fgui.VertAlignType || (fgui.VertAlignType = {})); - var LoaderFillType; - (function (LoaderFillType) { - LoaderFillType[LoaderFillType["None"] = 0] = "None"; - LoaderFillType[LoaderFillType["Scale"] = 1] = "Scale"; - LoaderFillType[LoaderFillType["ScaleMatchHeight"] = 2] = "ScaleMatchHeight"; - LoaderFillType[LoaderFillType["ScaleMatchWidth"] = 3] = "ScaleMatchWidth"; - LoaderFillType[LoaderFillType["ScaleFree"] = 4] = "ScaleFree"; - LoaderFillType[LoaderFillType["ScaleNoBorder"] = 5] = "ScaleNoBorder"; - })(LoaderFillType = fgui.LoaderFillType || (fgui.LoaderFillType = {})); - var ListLayoutType; - (function (ListLayoutType) { - ListLayoutType[ListLayoutType["SingleColumn"] = 0] = "SingleColumn"; - ListLayoutType[ListLayoutType["SingleRow"] = 1] = "SingleRow"; - ListLayoutType[ListLayoutType["FlowHorizontal"] = 2] = "FlowHorizontal"; - ListLayoutType[ListLayoutType["FlowVertical"] = 3] = "FlowVertical"; - ListLayoutType[ListLayoutType["Pagination"] = 4] = "Pagination"; - })(ListLayoutType = fgui.ListLayoutType || (fgui.ListLayoutType = {})); - var ListSelectionMode; - (function (ListSelectionMode) { - ListSelectionMode[ListSelectionMode["Single"] = 0] = "Single"; - ListSelectionMode[ListSelectionMode["Multiple"] = 1] = "Multiple"; - ListSelectionMode[ListSelectionMode["Multiple_SingleClick"] = 2] = "Multiple_SingleClick"; - ListSelectionMode[ListSelectionMode["None"] = 3] = "None"; - })(ListSelectionMode = fgui.ListSelectionMode || (fgui.ListSelectionMode = {})); - var OverflowType; - (function (OverflowType) { - OverflowType[OverflowType["Visible"] = 0] = "Visible"; - OverflowType[OverflowType["Hidden"] = 1] = "Hidden"; - OverflowType[OverflowType["Scroll"] = 2] = "Scroll"; - })(OverflowType = fgui.OverflowType || (fgui.OverflowType = {})); - var PackageItemType; - (function (PackageItemType) { - PackageItemType[PackageItemType["Image"] = 0] = "Image"; - PackageItemType[PackageItemType["MovieClip"] = 1] = "MovieClip"; - PackageItemType[PackageItemType["Sound"] = 2] = "Sound"; - PackageItemType[PackageItemType["Component"] = 3] = "Component"; - PackageItemType[PackageItemType["Atlas"] = 4] = "Atlas"; - PackageItemType[PackageItemType["Font"] = 5] = "Font"; - PackageItemType[PackageItemType["Swf"] = 6] = "Swf"; - PackageItemType[PackageItemType["Misc"] = 7] = "Misc"; - PackageItemType[PackageItemType["Unknown"] = 8] = "Unknown"; - PackageItemType[PackageItemType["Spine"] = 9] = "Spine"; - PackageItemType[PackageItemType["DragonBones"] = 10] = "DragonBones"; - })(PackageItemType = fgui.PackageItemType || (fgui.PackageItemType = {})); - ; - var ObjectType; - (function (ObjectType) { - ObjectType[ObjectType["Image"] = 0] = "Image"; - ObjectType[ObjectType["MovieClip"] = 1] = "MovieClip"; - ObjectType[ObjectType["Swf"] = 2] = "Swf"; - ObjectType[ObjectType["Graph"] = 3] = "Graph"; - ObjectType[ObjectType["Loader"] = 4] = "Loader"; - ObjectType[ObjectType["Group"] = 5] = "Group"; - ObjectType[ObjectType["Text"] = 6] = "Text"; - ObjectType[ObjectType["RichText"] = 7] = "RichText"; - ObjectType[ObjectType["InputText"] = 8] = "InputText"; - ObjectType[ObjectType["Component"] = 9] = "Component"; - ObjectType[ObjectType["List"] = 10] = "List"; - ObjectType[ObjectType["Label"] = 11] = "Label"; - ObjectType[ObjectType["Button"] = 12] = "Button"; - ObjectType[ObjectType["ComboBox"] = 13] = "ComboBox"; - ObjectType[ObjectType["ProgressBar"] = 14] = "ProgressBar"; - ObjectType[ObjectType["Slider"] = 15] = "Slider"; - ObjectType[ObjectType["ScrollBar"] = 16] = "ScrollBar"; - ObjectType[ObjectType["Tree"] = 17] = "Tree"; - ObjectType[ObjectType["Loader3D"] = 18] = "Loader3D"; - })(ObjectType = fgui.ObjectType || (fgui.ObjectType = {})); - var ProgressTitleType; - (function (ProgressTitleType) { - ProgressTitleType[ProgressTitleType["Percent"] = 0] = "Percent"; - ProgressTitleType[ProgressTitleType["ValueAndMax"] = 1] = "ValueAndMax"; - ProgressTitleType[ProgressTitleType["Value"] = 2] = "Value"; - ProgressTitleType[ProgressTitleType["Max"] = 3] = "Max"; - })(ProgressTitleType = fgui.ProgressTitleType || (fgui.ProgressTitleType = {})); - var ScrollBarDisplayType; - (function (ScrollBarDisplayType) { - ScrollBarDisplayType[ScrollBarDisplayType["Default"] = 0] = "Default"; - ScrollBarDisplayType[ScrollBarDisplayType["Visible"] = 1] = "Visible"; - ScrollBarDisplayType[ScrollBarDisplayType["Auto"] = 2] = "Auto"; - ScrollBarDisplayType[ScrollBarDisplayType["Hidden"] = 3] = "Hidden"; - })(ScrollBarDisplayType = fgui.ScrollBarDisplayType || (fgui.ScrollBarDisplayType = {})); - ; - var ScrollType; - (function (ScrollType) { - ScrollType[ScrollType["Horizontal"] = 0] = "Horizontal"; - ScrollType[ScrollType["Vertical"] = 1] = "Vertical"; - ScrollType[ScrollType["Both"] = 2] = "Both"; - })(ScrollType = fgui.ScrollType || (fgui.ScrollType = {})); - ; - var FlipType; - (function (FlipType) { - FlipType[FlipType["None"] = 0] = "None"; - FlipType[FlipType["Horizontal"] = 1] = "Horizontal"; - FlipType[FlipType["Vertical"] = 2] = "Vertical"; - FlipType[FlipType["Both"] = 3] = "Both"; - })(FlipType = fgui.FlipType || (fgui.FlipType = {})); - var ChildrenRenderOrder; - (function (ChildrenRenderOrder) { - ChildrenRenderOrder[ChildrenRenderOrder["Ascent"] = 0] = "Ascent"; - ChildrenRenderOrder[ChildrenRenderOrder["Descent"] = 1] = "Descent"; - ChildrenRenderOrder[ChildrenRenderOrder["Arch"] = 2] = "Arch"; - })(ChildrenRenderOrder = fgui.ChildrenRenderOrder || (fgui.ChildrenRenderOrder = {})); - var GroupLayoutType; - (function (GroupLayoutType) { - GroupLayoutType[GroupLayoutType["None"] = 0] = "None"; - GroupLayoutType[GroupLayoutType["Horizontal"] = 1] = "Horizontal"; - GroupLayoutType[GroupLayoutType["Vertical"] = 2] = "Vertical"; - })(GroupLayoutType = fgui.GroupLayoutType || (fgui.GroupLayoutType = {})); - var PopupDirection; - (function (PopupDirection) { - PopupDirection[PopupDirection["Auto"] = 0] = "Auto"; - PopupDirection[PopupDirection["Up"] = 1] = "Up"; - PopupDirection[PopupDirection["Down"] = 2] = "Down"; - })(PopupDirection = fgui.PopupDirection || (fgui.PopupDirection = {})); - var RelationType; - (function (RelationType) { - RelationType[RelationType["Left_Left"] = 0] = "Left_Left"; - RelationType[RelationType["Left_Center"] = 1] = "Left_Center"; - RelationType[RelationType["Left_Right"] = 2] = "Left_Right"; - RelationType[RelationType["Center_Center"] = 3] = "Center_Center"; - RelationType[RelationType["Right_Left"] = 4] = "Right_Left"; - RelationType[RelationType["Right_Center"] = 5] = "Right_Center"; - RelationType[RelationType["Right_Right"] = 6] = "Right_Right"; - RelationType[RelationType["Top_Top"] = 7] = "Top_Top"; - RelationType[RelationType["Top_Middle"] = 8] = "Top_Middle"; - RelationType[RelationType["Top_Bottom"] = 9] = "Top_Bottom"; - RelationType[RelationType["Middle_Middle"] = 10] = "Middle_Middle"; - RelationType[RelationType["Bottom_Top"] = 11] = "Bottom_Top"; - RelationType[RelationType["Bottom_Middle"] = 12] = "Bottom_Middle"; - RelationType[RelationType["Bottom_Bottom"] = 13] = "Bottom_Bottom"; - RelationType[RelationType["Width"] = 14] = "Width"; - RelationType[RelationType["Height"] = 15] = "Height"; - RelationType[RelationType["LeftExt_Left"] = 16] = "LeftExt_Left"; - RelationType[RelationType["LeftExt_Right"] = 17] = "LeftExt_Right"; - RelationType[RelationType["RightExt_Left"] = 18] = "RightExt_Left"; - RelationType[RelationType["RightExt_Right"] = 19] = "RightExt_Right"; - RelationType[RelationType["TopExt_Top"] = 20] = "TopExt_Top"; - RelationType[RelationType["TopExt_Bottom"] = 21] = "TopExt_Bottom"; - RelationType[RelationType["BottomExt_Top"] = 22] = "BottomExt_Top"; - RelationType[RelationType["BottomExt_Bottom"] = 23] = "BottomExt_Bottom"; - RelationType[RelationType["Size"] = 24] = "Size"; - })(RelationType = fgui.RelationType || (fgui.RelationType = {})); - var FillMethod; - (function (FillMethod) { - FillMethod[FillMethod["None"] = 0] = "None"; - FillMethod[FillMethod["Horizontal"] = 1] = "Horizontal"; - FillMethod[FillMethod["Vertical"] = 2] = "Vertical"; - FillMethod[FillMethod["Radial90"] = 3] = "Radial90"; - FillMethod[FillMethod["Radial180"] = 4] = "Radial180"; - FillMethod[FillMethod["Radial360"] = 5] = "Radial360"; - })(FillMethod = fgui.FillMethod || (fgui.FillMethod = {})); - var FillOrigin; - (function (FillOrigin) { - FillOrigin[FillOrigin["Top"] = 0] = "Top"; - FillOrigin[FillOrigin["Bottom"] = 1] = "Bottom"; - FillOrigin[FillOrigin["Left"] = 2] = "Left"; - FillOrigin[FillOrigin["Right"] = 3] = "Right"; - FillOrigin[FillOrigin["TopLeft"] = 0] = "TopLeft"; - FillOrigin[FillOrigin["TopRight"] = 1] = "TopRight"; - FillOrigin[FillOrigin["BottomLeft"] = 2] = "BottomLeft"; - FillOrigin[FillOrigin["BottomRight"] = 3] = "BottomRight"; - })(FillOrigin = fgui.FillOrigin || (fgui.FillOrigin = {})); - var FillOrigin90; - (function (FillOrigin90) { - FillOrigin90[FillOrigin90["TopLeft"] = 0] = "TopLeft"; - FillOrigin90[FillOrigin90["TopRight"] = 1] = "TopRight"; - FillOrigin90[FillOrigin90["BottomLeft"] = 2] = "BottomLeft"; - FillOrigin90[FillOrigin90["BottomRight"] = 3] = "BottomRight"; - })(FillOrigin90 = fgui.FillOrigin90 || (fgui.FillOrigin90 = {})); - var ObjectPropID; - (function (ObjectPropID) { - ObjectPropID[ObjectPropID["Text"] = 0] = "Text"; - ObjectPropID[ObjectPropID["Icon"] = 1] = "Icon"; - ObjectPropID[ObjectPropID["Color"] = 2] = "Color"; - ObjectPropID[ObjectPropID["OutlineColor"] = 3] = "OutlineColor"; - ObjectPropID[ObjectPropID["Playing"] = 4] = "Playing"; - ObjectPropID[ObjectPropID["Frame"] = 5] = "Frame"; - ObjectPropID[ObjectPropID["DeltaTime"] = 6] = "DeltaTime"; - ObjectPropID[ObjectPropID["TimeScale"] = 7] = "TimeScale"; - ObjectPropID[ObjectPropID["FontSize"] = 8] = "FontSize"; - ObjectPropID[ObjectPropID["Selected"] = 9] = "Selected"; - })(ObjectPropID = fgui.ObjectPropID || (fgui.ObjectPropID = {})); -})(fgui || (fgui = {})); - -(function (fgui) { - var GObject = (function (_super_1) { - __extends(GObject, _super_1); - function GObject() { - var _this = _super_1.call(this) || this; - _this._x = 0; - _this._y = 0; - _this._alpha = 1; - _this._rotation = 0; - _this._visible = true; - _this._touchable = true; - _this._scaleX = 1; - _this._scaleY = 1; - _this._skewX = 0; - _this._skewY = 0; - _this._pivotX = 0; - _this._pivotY = 0; - _this._pivotOffsetX = 0; - _this._pivotOffsetY = 0; - _this._sortingOrder = 0; - _this._internalVisible = true; - _this._disposed = false; - _this.sourceWidth = 0; - _this.sourceHeight = 0; - _this.initWidth = 0; - _this.initHeight = 0; - _this.minWidth = 0; - _this.minHeight = 0; - _this.maxWidth = 0; - _this.maxHeight = 0; - _this._width = 0; - _this._height = 0; - _this._rawWidth = 0; - _this._rawHeight = 0; - _this._sizePercentInGroup = 0; - _this._id = "" + _gInstanceCounter++; - _this._name = ""; - _this.createDisplayObject(); - _this._relations = new fgui.Relations(_this); - _this._gears = new Array(10); - return _this; - } - Object.defineProperty(GObject.prototype, "id", { - get: function () { - return this._id; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "name", { - get: function () { - return this._name; - }, - set: function (value) { - this._name = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "x", { - get: function () { - return this._x; - }, - set: function (value) { - this.setXY(value, this._y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "y", { - get: function () { - return this._y; - }, - set: function (value) { - this.setXY(this._x, value); - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setXY = function (xv, yv) { - if (this._x != xv || this._y != yv) { - var dx = xv - this._x; - var dy = yv - this._y; - this._x = xv; - this._y = yv; - this.handleXYChanged(); - if (this instanceof fgui.GGroup) - this.moveChildren(dx, dy); - this.updateGear(1); - if (this._parent && !(this._parent instanceof fgui.GList)) { - this._parent.setBoundsChangedFlag(); - if (this._group) - this._group.setBoundsChangedFlag(true); - this.dispatchEventWith(GObject.XY_CHANGED); - } - if (GObject.draggingObject == this && !sUpdateInDragging) - this.localToGlobalRect(0, 0, this._width, this._height, sGlobalRect); - } - }; - Object.defineProperty(GObject.prototype, "xMin", { - get: function () { - return this._pivotAsAnchor ? (this._x - this._width * this._pivotX) : this._x; - }, - set: function (value) { - if (this._pivotAsAnchor) - this.setXY(value + this._width * this._pivotX, this._y); - else - this.setXY(value, this._y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "yMin", { - get: function () { - return this._pivotAsAnchor ? (this._y - this._height * this._pivotY) : this._y; - }, - set: function (value) { - if (this._pivotAsAnchor) - this.setXY(this._x, value + this._height * this._pivotY); - else - this.setXY(this._x, value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "pixelSnapping", { - get: function () { - return this._pixelSnapping; - }, - set: function (value) { - if (this._pixelSnapping != value) { - this._pixelSnapping = value; - this.handleXYChanged(); - } - }, - enumerable: true, - configurable: true - }); - GObject.prototype.center = function (restraint) { - var r; - if (this._parent) - r = this.parent; - else - r = this.root; - this.setXY((r.width - this._width) / 2, (r.height - this._height) / 2); - if (restraint) { - this.addRelation(r, fgui.RelationType.Center_Center); - this.addRelation(r, fgui.RelationType.Middle_Middle); - } - }; - Object.defineProperty(GObject.prototype, "width", { - get: function () { - this.ensureSizeCorrect(); - if (this._relations.sizeDirty) - this._relations.ensureRelationsSizeCorrect(); - return this._width; - }, - set: function (value) { - this.setSize(value, this._rawHeight); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "height", { - get: function () { - this.ensureSizeCorrect(); - if (this._relations.sizeDirty) - this._relations.ensureRelationsSizeCorrect(); - return this._height; - }, - set: function (value) { - this.setSize(this._rawWidth, value); - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setSize = function (wv, hv, ignorePivot) { - if (this._rawWidth != wv || this._rawHeight != hv) { - this._rawWidth = wv; - this._rawHeight = hv; - if (wv < this.minWidth) - wv = this.minWidth; - if (hv < this.minHeight) - hv = this.minHeight; - if (this.maxWidth > 0 && wv > this.maxWidth) - wv = this.maxWidth; - if (this.maxHeight > 0 && hv > this.maxHeight) - hv = this.maxHeight; - var dWidth = wv - this._width; - var dHeight = hv - this._height; - this._width = wv; - this._height = hv; - this.handleSizeChanged(); - if (this._pivotX != 0 || this._pivotY != 0) { - if (!this._pivotAsAnchor) { - if (!ignorePivot) - this.setXY(this.x - this._pivotX * dWidth, this.y - this._pivotY * dHeight); - this.updatePivotOffset(); - } - else { - this.applyPivot(); - } - } - if (this instanceof fgui.GGroup) - this.resizeChildren(dWidth, dHeight); - this.updateGear(2); - if (this._parent) { - this._relations.onOwnerSizeChanged(dWidth, dHeight, this._pivotAsAnchor || !ignorePivot); - this._parent.setBoundsChangedFlag(); - if (this._group) - this._group.setBoundsChangedFlag(); - } - this.dispatchEventWith(GObject.SIZE_CHANGED); - } - }; - GObject.prototype.makeFullScreen = function () { - this.setSize(fgui.GRoot.inst.width, fgui.GRoot.inst.height); - }; - GObject.prototype.ensureSizeCorrect = function () { - }; - Object.defineProperty(GObject.prototype, "actualWidth", { - get: function () { - return this.width * Math.abs(this._scaleX); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "actualHeight", { - get: function () { - return this.height * Math.abs(this._scaleY); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "scaleX", { - get: function () { - return this._scaleX; - }, - set: function (value) { - this.setScale(value, this._scaleY); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "scaleY", { - get: function () { - return this._scaleY; - }, - set: function (value) { - this.setScale(this._scaleX, value); - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setScale = function (sx, sy) { - if (this._scaleX != sx || this._scaleY != sy) { - this._scaleX = sx; - this._scaleY = sy; - this.handleScaleChanged(); - this.applyPivot(); - this.updateGear(2); - } - }; - Object.defineProperty(GObject.prototype, "skewX", { - get: function () { - return this._skewX; - }, - set: function (value) { - this.setSkew(value, this._skewY); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "skewY", { - get: function () { - return this._skewY; - }, - set: function (value) { - this.setSkew(this._skewX, value); - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setSkew = function (xv, yv) { - if (this._skewX != xv || this._skewY != yv) { - this._skewX = xv; - this._skewY = yv; - if (this._displayObject) { - this._displayObject.skewX = xv; - this._displayObject.skewY = yv; - } - this.applyPivot(); - } - }; - Object.defineProperty(GObject.prototype, "pivotX", { - get: function () { - return this._pivotX; - }, - set: function (value) { - this.setPivot(value, this._pivotY); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "pivotY", { - get: function () { - return this._pivotY; - }, - set: function (value) { - this.setPivot(this._pivotX, value); - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setPivot = function (xv, yv, asAnchor) { - if (this._pivotX != xv || this._pivotY != yv || this._pivotAsAnchor != asAnchor) { - this._pivotX = xv; - this._pivotY = yv; - this._pivotAsAnchor = asAnchor; - this.updatePivotOffset(); - this.handleXYChanged(); - } - }; - Object.defineProperty(GObject.prototype, "pivotAsAnchor", { - get: function () { - return this._pivotAsAnchor; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.internalSetPivot = function (xv, yv, asAnchor) { - this._pivotX = xv; - this._pivotY = yv; - this._pivotAsAnchor = asAnchor; - if (asAnchor) - this.handleXYChanged(); - }; - GObject.prototype.updatePivotOffset = function () { - if (this._displayObject) { - if (this._pivotX != 0 || this._pivotY != 0) { - var px = this._pivotX * this._width; - var py = this._pivotY * this._height; - var pt = this._displayObject.matrix.transformPoint(px, py, sHelperPoint); - this._pivotOffsetX = this._pivotX * this._width - (pt.x - this._displayObject.x); - this._pivotOffsetY = this._pivotY * this._height - (pt.y - this._displayObject.y); - } - else { - this._pivotOffsetX = 0; - this._pivotOffsetY = 0; - } - } - }; - GObject.prototype.applyPivot = function () { - if (this._pivotX != 0 || this._pivotY != 0) { - this.updatePivotOffset(); - this.handleXYChanged(); - } - }; - Object.defineProperty(GObject.prototype, "touchable", { - get: function () { - return this._touchable; - }, - set: function (value) { - if (this._touchable != value) { - this._touchable = value; - this.updateGear(3); - if ((this instanceof fgui.GImage) || (this instanceof fgui.GMovieClip) - || (this instanceof fgui.GTextField) && !(this instanceof fgui.GTextInput) && !(this instanceof fgui.GRichTextField)) - return; - if (this._displayObject) { - this._displayObject.touchEnabled = this._touchable; - if (this._displayObject instanceof egret.DisplayObjectContainer) - this._displayObject.touchChildren = this._touchable; - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "grayed", { - get: function () { - return this._grayed; - }, - set: function (value) { - if (this._grayed != value) { - this._grayed = value; - this.handleGrayedChanged(); - this.updateGear(3); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "enabled", { - get: function () { - return !this._grayed && this._touchable; - }, - set: function (value) { - this.grayed = !value; - this.touchable = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "rotation", { - get: function () { - return this._rotation; - }, - set: function (value) { - if (this._rotation != value) { - this._rotation = value; - if (this._displayObject) - this._displayObject.rotation = this.normalizeRotation; - this.applyPivot(); - this.updateGear(3); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "normalizeRotation", { - get: function () { - var rot = this._rotation % 360; - if (rot > 180) - rot -= 360; - else if (rot < -180) - rot += 360; - return rot; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "alpha", { - get: function () { - return this._alpha; - }, - set: function (value) { - if (this._alpha != value) { - this._alpha = value; - this.handleAlphaChanged(); - this.updateGear(3); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "visible", { - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible != value) { - this._visible = value; - this.handleVisibleChanged(); - if (this._parent) - this._parent.setBoundsChangedFlag(); - if (this._group && this._group.excludeInvisibles) - this._group.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "internalVisible", { - get: function () { - return this._internalVisible && (!this._group || this._group.internalVisible); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "internalVisible2", { - get: function () { - return this._visible && (!this._group || this._group.internalVisible2); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "internalVisible3", { - get: function () { - return this._visible && this._internalVisible; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "sortingOrder", { - get: function () { - return this._sortingOrder; - }, - set: function (value) { - if (value < 0) - value = 0; - if (this._sortingOrder != value) { - var old = this._sortingOrder; - this._sortingOrder = value; - if (this._parent) - this._parent.childSortingOrderChanged(this, old, this._sortingOrder); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "focused", { - get: function () { - return this.root.focus == this; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.requestFocus = function () { - this.root.focus = this; - }; - Object.defineProperty(GObject.prototype, "tooltips", { - get: function () { - return this._tooltips; - }, - set: function (value) { - this._tooltips = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "blendMode", { - get: function () { - return this._displayObject.blendMode; - }, - set: function (value) { - this._displayObject.blendMode = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "filters", { - get: function () { - return this._displayObject.filters; - }, - set: function (value) { - this._displayObject.filters = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "inContainer", { - get: function () { - return this._displayObject != null && this._displayObject.parent != null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "onStage", { - get: function () { - return this._displayObject != null && this._displayObject.stage != null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "resourceURL", { - get: function () { - if (this.packageItem) - return "ui://" + this.packageItem.owner.id + this.packageItem.id; - else - return null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "group", { - get: function () { - return this._group; - }, - set: function (value) { - if (this._group != value) { - if (this._group) - this._group.setBoundsChangedFlag(); - this._group = value; - if (this._group) - this._group.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - GObject.prototype.getGear = function (index) { - var gear = this._gears[index]; - if (gear == null) - this._gears[index] = gear = fgui.GearBase.create(this, index); - return gear; - }; - GObject.prototype.updateGear = function (index) { - if (this._underConstruct || this._gearLocked) - return; - var gear = this._gears[index]; - if (gear && gear.controller) - gear.updateState(); - }; - GObject.prototype.checkGearController = function (index, c) { - return this._gears[index] != null && this._gears[index].controller == c; - }; - GObject.prototype.updateGearFromRelations = function (index, dx, dy) { - if (this._gears[index]) - this._gears[index].updateFromRelations(dx, dy); - }; - GObject.prototype.addDisplayLock = function () { - var gearDisplay = this._gears[0]; - if (gearDisplay && gearDisplay.controller) { - var ret = gearDisplay.addLock(); - this.checkGearDisplay(); - return ret; - } - else - return 0; - }; - GObject.prototype.releaseDisplayLock = function (token) { - var gearDisplay = this._gears[0]; - if (gearDisplay && gearDisplay.controller) { - gearDisplay.releaseLock(token); - this.checkGearDisplay(); - } - }; - GObject.prototype.checkGearDisplay = function () { - if (this._handlingController) - return; - var connected = this._gears[0] == null || this._gears[0].connected; - if (this._gears[8]) - connected = this._gears[8].evaluate(connected); - if (connected != this._internalVisible) { - this._internalVisible = connected; - if (this._parent) - this._parent.childStateChanged(this); - if (this._group && this._group.excludeInvisibles) - this._group.setBoundsChangedFlag(); - } - }; - Object.defineProperty(GObject.prototype, "gearXY", { - get: function () { - return this.getGear(1); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "gearSize", { - get: function () { - return this.getGear(2); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "gearLook", { - get: function () { - return this.getGear(3); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "relations", { - get: function () { - return this._relations; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.addRelation = function (target, relationType, usePercent) { - this._relations.add(target, relationType, usePercent); - }; - GObject.prototype.removeRelation = function (target, relationType) { - this._relations.remove(target, relationType || 0); - }; - Object.defineProperty(GObject.prototype, "displayObject", { - get: function () { - return this._displayObject; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.setDisplayObject = function (value) { - if (this._displayObject != value) { - if (this._displayObject) - delete this._displayObject["$owner"]; - this._displayObject = value; - this._displayObject["$owner"] = this; - } - }; - Object.defineProperty(GObject.prototype, "parent", { - get: function () { - return this._parent; - }, - set: function (val) { - this._parent = val; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.removeFromParent = function () { - if (this._parent) - this._parent.removeChild(this); - }; - Object.defineProperty(GObject.prototype, "root", { - get: function () { - if (this instanceof fgui.GRoot) - return this; - var p = this._parent; - while (p) { - if (p instanceof fgui.GRoot) - return p; - p = p.parent; - } - return fgui.GRoot.inst; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asCom", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asButton", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asLabel", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asProgress", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asTextField", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asRichTextField", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asTextInput", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asLoader", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asList", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asTree", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asGraph", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asGroup", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asSlider", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asComboBox", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asImage", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "asMovieClip", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - GObject.cast = function (obj) { - return obj["$owner"]; - }; - Object.defineProperty(GObject.prototype, "text", { - get: function () { - return null; - }, - set: function (value) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "icon", { - get: function () { - return null; - }, - set: function (value) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "isDisposed", { - get: function () { - return this._disposed; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "treeNode", { - get: function () { - return this._treeNode; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.dispose = function () { - if (this._disposed) - return; - this._disposed = true; - this.removeFromParent(); - this._relations.dispose(); - this._displayObject = null; - for (var i = 0; i < 10; i++) { - var gear = this._gears[i]; - if (gear) - gear.dispose(); - } - }; - GObject.prototype.addClickListener = function (listener, thisObj) { - this.addEventListener(egret.TouchEvent.TOUCH_TAP, listener, thisObj); - }; - GObject.prototype.removeClickListener = function (listener, thisObj) { - this.removeEventListener(egret.TouchEvent.TOUCH_TAP, listener, thisObj); - }; - GObject.prototype.hasClickListener = function () { - return this.hasEventListener(egret.TouchEvent.TOUCH_TAP); - }; - GObject.prototype.addEventListener = function (type, listener, thisObject) { - _super_1.prototype.addEventListener.call(this, type, listener, thisObject); - if (this._displayObject) { - this._displayObject.addEventListener(type, this._reDispatch, this); - } - }; - GObject.prototype.removeEventListener = function (type, listener, thisObject) { - _super_1.prototype.removeEventListener.call(this, type, listener, thisObject); - if (this._displayObject && !this.hasEventListener(type)) { - this._displayObject.removeEventListener(type, this._reDispatch, this); - } - }; - GObject.prototype._reDispatch = function (evt) { - this.dispatchEvent(evt); - }; - Object.defineProperty(GObject.prototype, "draggable", { - get: function () { - return this._draggable; - }, - set: function (value) { - if (this._draggable != value) { - this._draggable = value; - this.initDrag(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GObject.prototype, "dragBounds", { - get: function () { - return this._dragBounds; - }, - set: function (value) { - this._dragBounds = value; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.startDrag = function (touchPointID, stageX, stageY) { - if (this._displayObject.stage == null) - return; - this.dragBegin(touchPointID, stageX, stageY); - }; - GObject.prototype.stopDrag = function () { - this.dragEnd(); - }; - Object.defineProperty(GObject.prototype, "dragging", { - get: function () { - return GObject.draggingObject == this; - }, - enumerable: true, - configurable: true - }); - GObject.prototype.localToGlobal = function (ax, ay, result) { - ax = ax || 0; - ay = ay || 0; - if (this._pivotAsAnchor) { - ax += this._pivotX * this._width; - ay += this._pivotY * this._height; - } - return this._displayObject.localToGlobal(ax, ay, result); - }; - GObject.prototype.globalToLocal = function (ax, ay, result) { - ax = ax || 0; - ay = ay || 0; - var pt = this._displayObject.globalToLocal(ax, ay, result); - if (this._pivotAsAnchor) { - pt.x -= this._pivotX * this._width; - pt.y -= this._pivotY * this._height; - } - return pt; - }; - GObject.prototype.localToRoot = function (ax, ay, result) { - ax = ax || 0; - ay = ay || 0; - var pt = this._displayObject.localToGlobal(ax, ay, result); - pt.x /= fgui.GRoot.contentScaleFactor; - pt.y /= fgui.GRoot.contentScaleFactor; - return pt; - }; - GObject.prototype.rootToLocal = function (ax, ay, resultPoint) { - ax = ax || 0; - ay = ay || 0; - ax *= fgui.GRoot.contentScaleFactor; - ay *= fgui.GRoot.contentScaleFactor; - return this._displayObject.globalToLocal(ax, ay, resultPoint); - }; - GObject.prototype.localToGlobalRect = function (ax, ay, aw, ah, result) { - ax = ax || 0; - ay = ay || 0; - aw = aw || 0; - ah = ah || 0; - result = result || new egret.Rectangle(); - var pt = this.localToGlobal(ax, ay); - result.x = pt.x; - result.y = pt.y; - pt = this.localToGlobal(ax + aw, ay + ah); - result.right = pt.x; - result.bottom = pt.y; - return result; - }; - GObject.prototype.globalToLocalRect = function (ax, ay, aw, ah, result) { - ax = ax || 0; - ay = ay || 0; - aw = aw || 0; - ah = ah || 0; - result = result || new egret.Rectangle(); - var pt = this.globalToLocal(ax, ay); - result.x = pt.x; - result.y = pt.y; - pt = this.globalToLocal(ax + aw, ay + ah); - result.right = pt.x; - result.bottom = pt.y; - return result; - }; - GObject.prototype.handleControllerChanged = function (c) { - this._handlingController = true; - for (var i = 0; i < 10; i++) { - var gear = this._gears[i]; - if (gear && gear.controller == c) - gear.apply(); - } - this._handlingController = false; - this.checkGearDisplay(); - }; - GObject.prototype.createDisplayObject = function () { - }; - GObject.prototype.switchDisplayObject = function (newObj) { - if (newObj == this._displayObject) - return; - var old = this._displayObject; - if (this._displayObject && this._displayObject.parent) { - var i = this._displayObject.parent.getChildIndex(this._displayObject); - this._displayObject.parent.addChildAt(newObj, i); - this._displayObject.parent.removeChild(this._displayObject); - } - this._displayObject = newObj; - this._displayObject.x = old.x; - this._displayObject.y = old.y; - this._displayObject.rotation = old.rotation; - this._displayObject.alpha = old.alpha; - this._displayObject.visible = old.visible; - this._displayObject.touchEnabled = old.touchEnabled; - this._displayObject.scaleX = old.scaleX; - this._displayObject.scaleY = old.scaleY; - fgui.ToolSet.setColorFilter(this._displayObject, this._grayed); - if (this._displayObject instanceof egret.DisplayObjectContainer) - this._displayObject.touchChildren = this._touchable; - }; - GObject.prototype.handleXYChanged = function () { - if (this._displayObject) { - var xv = this._x; - var yv = this._y; - if (this._pivotAsAnchor) { - xv -= this._pivotX * this._width; - yv -= this._pivotY * this._height; - } - if (this._pixelSnapping) { - xv = Math.round(xv); - yv = Math.round(yv); - } - this._displayObject.x = xv + this._pivotOffsetX; - this._displayObject.y = yv + this._pivotOffsetY; - } - }; - GObject.prototype.handleSizeChanged = function () { - if (this._displayObject) { - this._displayObject.width = this._width; - this._displayObject.height = this._height; - } - }; - GObject.prototype.handleScaleChanged = function () { - if (this._displayObject) { - this._displayObject.scaleX = this._scaleX; - this._displayObject.scaleY = this._scaleY; - } - }; - GObject.prototype.handleGrayedChanged = function () { - if (this._displayObject) { - fgui.ToolSet.setColorFilter(this._displayObject, this._grayed); - } - }; - GObject.prototype.handleAlphaChanged = function () { - if (this._displayObject) - this._displayObject.alpha = this._alpha; - }; - GObject.prototype.handleVisibleChanged = function () { - if (this._displayObject) - this._displayObject.visible = this.internalVisible2; - if (this instanceof fgui.GGroup) - this.handleVisibleChanged(); - }; - GObject.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Text: - return this.text; - case fgui.ObjectPropID.Icon: - return this.icon; - case fgui.ObjectPropID.Color: - return NaN; - case fgui.ObjectPropID.OutlineColor: - return NaN; - case fgui.ObjectPropID.Playing: - return false; - case fgui.ObjectPropID.Frame: - return 0; - case fgui.ObjectPropID.DeltaTime: - return 0; - case fgui.ObjectPropID.TimeScale: - return 1; - case fgui.ObjectPropID.FontSize: - return 0; - case fgui.ObjectPropID.Selected: - return false; - default: - return undefined; - } - }; - GObject.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Text: - this.text = value; - break; - case fgui.ObjectPropID.Icon: - this.icon = value; - break; - } - }; - GObject.prototype.constructFromResource = function () { - }; - GObject.prototype.setup_beforeAdd = function (buffer, beginPos) { - buffer.seek(beginPos, 0); - buffer.skip(5); - var f1; - var f2; - this._id = buffer.readS(); - this._name = buffer.readS(); - f1 = buffer.readInt(); - f2 = buffer.readInt(); - this.setXY(f1, f2); - if (buffer.readBool()) { - this.initWidth = buffer.readInt(); - this.initHeight = buffer.readInt(); - this.setSize(this.initWidth, this.initHeight, true); - } - if (buffer.readBool()) { - this.minWidth = buffer.readInt(); - this.maxWidth = buffer.readInt(); - this.minHeight = buffer.readInt(); - this.maxHeight = buffer.readInt(); - } - if (buffer.readBool()) { - f1 = buffer.readFloat(); - f2 = buffer.readFloat(); - this.setScale(f1, f2); - } - if (buffer.readBool()) { - f1 = buffer.readFloat(); - f2 = buffer.readFloat(); - this.setSkew(f1, f2); - } - if (buffer.readBool()) { - f1 = buffer.readFloat(); - f2 = buffer.readFloat(); - this.setPivot(f1, f2, buffer.readBool()); - } - f1 = buffer.readFloat(); - if (f1 != 1) - this.alpha = f1; - f1 = buffer.readFloat(); - if (f1 != 0) - this.rotation = f1; - if (!buffer.readBool()) - this.visible = false; - if (!buffer.readBool()) - this.touchable = false; - if (buffer.readBool()) - this.grayed = true; - var bm = buffer.readByte(); - if (bm == 2) - this.blendMode = egret.BlendMode.ADD; - else if (bm == 5) - this.blendMode = egret.BlendMode.ERASE; - var filter = buffer.readByte(); - if (filter == 1 && this._displayObject) - fgui.ToolSet.setColorFilter(this._displayObject, [buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat()]); - var str = buffer.readS(); - if (str != null) - this.data = str; - }; - GObject.prototype.setup_afterAdd = function (buffer, beginPos) { - buffer.seek(beginPos, 1); - var str = buffer.readS(); - if (str != null) - this.tooltips = str; - var groupId = buffer.readShort(); - if (groupId >= 0) - this.group = this.parent.getChildAt(groupId); - buffer.seek(beginPos, 2); - var cnt = buffer.readShort(); - for (var i = 0; i < cnt; i++) { - var nextPos = buffer.readShort(); - nextPos += buffer.position; - var gear = this.getGear(buffer.readByte()); - gear.setup(buffer); - buffer.position = nextPos; - } - }; - GObject.prototype.initDrag = function () { - if (this._draggable) - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__begin, this); - else - this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__begin, this); - }; - GObject.prototype.dragBegin = function (touchPointID, stageX, stageY) { - if (GObject.draggingObject) { - var tmp = GObject.draggingObject; - tmp.stopDrag(); - GObject.draggingObject = null; - var dragEvent = new fgui.DragEvent(fgui.DragEvent.DRAG_END); - dragEvent.stageX = stageX || fgui.GRoot.mouseX; - dragEvent.stageY = stageY || fgui.GRoot.mouseY; - dragEvent.touchPointID = touchPointID || 0; - tmp.dispatchEvent(dragEvent); - } - sGlobalDragStart.x = stageX || fgui.GRoot.mouseX; - sGlobalDragStart.y = stageY || fgui.GRoot.mouseY; - this.localToGlobalRect(0, 0, this._width, this._height, sGlobalRect); - this._dragTesting = true; - GObject.draggingObject = this; - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__moving, this); - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_END, this.__end, this); - }; - GObject.prototype.dragEnd = function () { - if (GObject.draggingObject == this) { - this.reset(); - this._dragTesting = false; - GObject.draggingObject = null; - } - }; - GObject.prototype.reset = function () { - fgui.GRoot.inst.nativeStage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.__moving, this); - fgui.GRoot.inst.nativeStage.removeEventListener(egret.TouchEvent.TOUCH_END, this.__end, this); - }; - GObject.prototype.__begin = function (evt) { - if (this._dragStartPos == null) - this._dragStartPos = new egret.Point(); - this._dragStartPos.x = evt.stageX; - this._dragStartPos.y = evt.stageY; - this._dragTesting = true; - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__moving, this); - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_END, this.__end, this); - }; - GObject.prototype.__moving = function (evt) { - if (GObject.draggingObject != this && this._draggable && this._dragTesting) { - var sensitivity = fgui.UIConfig.touchDragSensitivity; - if (this._dragStartPos - && Math.abs(this._dragStartPos.x - evt.stageX) < sensitivity - && Math.abs(this._dragStartPos.y - evt.stageY) < sensitivity) - return; - this._dragTesting = false; - var dragEvent = new fgui.DragEvent(fgui.DragEvent.DRAG_START); - dragEvent.stageX = evt.stageX; - dragEvent.stageY = evt.stageY; - dragEvent.touchPointID = evt.touchPointID; - this.dispatchEvent(dragEvent); - if (!dragEvent.isDefaultPrevented()) - this.dragBegin(evt.touchPointID, evt.stageX, evt.stageY); - } - if (GObject.draggingObject == this) { - var xx = evt.stageX - sGlobalDragStart.x + sGlobalRect.x; - var yy = evt.stageY - sGlobalDragStart.y + sGlobalRect.y; - if (this._dragBounds) { - var rect = fgui.GRoot.inst.localToGlobalRect(this._dragBounds.x, this._dragBounds.y, this._dragBounds.width, this._dragBounds.height, sDragHelperRect); - if (xx < rect.x) - xx = rect.x; - else if (xx + sGlobalRect.width > rect.right) { - xx = rect.right - sGlobalRect.width; - if (xx < rect.x) - xx = rect.x; - } - if (yy < rect.y) - yy = rect.y; - else if (yy + sGlobalRect.height > rect.bottom) { - yy = rect.bottom - sGlobalRect.height; - if (yy < rect.y) - yy = rect.y; - } - } - sUpdateInDragging = true; - var pt = this.parent.globalToLocal(xx, yy, sHelperPoint); - this.setXY(Math.round(pt.x), Math.round(pt.y)); - sUpdateInDragging = false; - var dragEvent = new fgui.DragEvent(fgui.DragEvent.DRAG_MOVING); - dragEvent.stageX = evt.stageX; - dragEvent.stageY = evt.stageY; - dragEvent.touchPointID = evt.touchPointID; - this.dispatchEvent(dragEvent); - } - }; - GObject.prototype.__end = function (evt) { - if (GObject.draggingObject == this) { - GObject.draggingObject = null; - this.reset(); - var dragEvent = new fgui.DragEvent(fgui.DragEvent.DRAG_END); - dragEvent.stageX = evt.stageX; - dragEvent.stageY = evt.stageY; - dragEvent.touchPointID = evt.touchPointID; - this.dispatchEvent(dragEvent); - } - else if (this._dragTesting) { - this._dragTesting = false; - this.reset(); - } - }; - GObject.XY_CHANGED = "__xyChanged"; - GObject.SIZE_CHANGED = "__sizeChanged"; - GObject.SIZE_DELAY_CHANGE = "__sizeDelayChange"; - GObject.GEAR_STOP = "gearStop"; - return GObject; - }(egret.EventDispatcher)); - fgui.GObject = GObject; - var _gInstanceCounter = 0; - var sGlobalDragStart = new egret.Point(); - var sGlobalRect = new egret.Rectangle(); - var sHelperPoint = new egret.Point(); - var sDragHelperRect = new egret.Rectangle(); - var sUpdateInDragging; -})(fgui || (fgui = {})); - -(function (fgui) { - var GComponent = (function (_super_1) { - __extends(GComponent, _super_1); - function GComponent() { - var _this = _super_1.call(this) || this; - _this._sortingChildCount = 0; - _this._childrenRenderOrder = fgui.ChildrenRenderOrder.Ascent; - _this._apexIndex = 0; - _this._children = new Array(); - _this._controllers = new Array(); - _this._transitions = new Array(); - _this._margin = new fgui.Margin(); - _this._alignOffset = new egret.Point(); - return _this; - } - GComponent.prototype.createDisplayObject = function () { - this._rootContainer = new fgui.UIContainer(); - this.setDisplayObject(this._rootContainer); - this._container = this._rootContainer; - }; - GComponent.prototype.dispose = function () { - var i; - var cnt; - cnt = this._transitions.length; - for (i = 0; i < cnt; ++i) { - var trans = this._transitions[i]; - trans.dispose(); - } - cnt = this._controllers.length; - for (i = 0; i < cnt; ++i) { - var cc = this._controllers[i]; - cc.dispose(); - } - if (this._scrollPane) - this._scrollPane.dispose(); - cnt = this._children.length; - for (i = cnt - 1; i >= 0; --i) { - var obj = this._children[i]; - obj.parent = null; - obj.dispose(); - } - this._boundsChanged = false; - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GComponent.prototype, "displayListContainer", { - get: function () { - return this._container; - }, - enumerable: true, - configurable: true - }); - GComponent.prototype.addChild = function (child) { - this.addChildAt(child, this._children.length); - return child; - }; - GComponent.prototype.addChildAt = function (child, index) { - if (index === void 0) { index = 0; } - if (!child) - throw "child is null"; - var numChildren = this._children.length; - if (index >= 0 && index <= numChildren) { - if (child.parent == this) { - this.setChildIndex(child, index); - } - else { - child.removeFromParent(); - child.parent = this; - var cnt = this._children.length; - if (child.sortingOrder != 0) { - this._sortingChildCount++; - index = this.getInsertPosForSortingChild(child); - } - else if (this._sortingChildCount > 0) { - if (index > (cnt - this._sortingChildCount)) - index = cnt - this._sortingChildCount; - } - if (index == cnt) - this._children.push(child); - else - this._children.splice(index, 0, child); - this.childStateChanged(child); - this.setBoundsChangedFlag(); - } - return child; - } - else { - throw "Invalid child index"; - } - }; - GComponent.prototype.getInsertPosForSortingChild = function (target) { - var cnt = this._children.length; - var i = 0; - for (i = 0; i < cnt; i++) { - var child = this._children[i]; - if (child == target) - continue; - if (target.sortingOrder < child.sortingOrder) - break; - } - return i; - }; - GComponent.prototype.removeChild = function (child, dispose) { - var childIndex = this._children.indexOf(child); - if (childIndex != -1) { - this.removeChildAt(childIndex, dispose); - } - return child; - }; - GComponent.prototype.removeChildAt = function (index, dispose) { - if (index >= 0 && index < this.numChildren) { - var child = this._children[index]; - child.parent = null; - if (child.sortingOrder != 0) - this._sortingChildCount--; - this._children.splice(index, 1); - child.group = null; - if (child.inContainer) { - this._container.removeChild(child.displayObject); - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Arch) - fgui.GTimers.inst.callLater(this.buildNativeDisplayList, this); - } - if (dispose) - child.dispose(); - this.setBoundsChangedFlag(); - return child; - } - else { - throw "Invalid child index"; - } - }; - GComponent.prototype.removeChildren = function (beginIndex, endIndex, dispose) { - if (beginIndex == undefined) - beginIndex = 0; - if (endIndex == undefined) - endIndex = -1; - if (endIndex < 0 || endIndex >= this.numChildren) - endIndex = this.numChildren - 1; - for (var i = beginIndex; i <= endIndex; ++i) - this.removeChildAt(beginIndex, dispose); - }; - GComponent.prototype.getChildAt = function (index) { - if (index >= 0 && index < this.numChildren) - return this._children[index]; - else - throw "Invalid child index"; - }; - GComponent.prototype.getChild = function (name) { - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - if (this._children[i].name == name) - return this._children[i]; - } - return null; - }; - GComponent.prototype.getChildByPath = function (path) { - var arr = path.split("."); - var cnt = arr.length; - var gcom = this; - var obj; - for (var i = 0; i < cnt; ++i) { - obj = gcom.getChild(arr[i]); - if (!obj) - break; - if (i != cnt - 1) { - if (!(obj instanceof GComponent)) { - obj = null; - break; - } - else - gcom = obj; - } - } - return obj; - }; - GComponent.prototype.getVisibleChild = function (name) { - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - var child = this._children[i]; - if (child.internalVisible && child.internalVisible && child.name == name) - return child; - } - return null; - }; - GComponent.prototype.getChildInGroup = function (name, group) { - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - var child = this._children[i]; - if (child.group == group && child.name == name) - return child; - } - return null; - }; - GComponent.prototype.getChildById = function (id) { - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - if (this._children[i]._id == id) - return this._children[i]; - } - return null; - }; - GComponent.prototype.getChildIndex = function (child) { - return this._children.indexOf(child); - }; - GComponent.prototype.setChildIndex = function (child, index) { - var oldIndex = this._children.indexOf(child); - if (oldIndex == -1) - throw "Not a child of this container"; - if (child.sortingOrder != 0) - return; - var cnt = this._children.length; - if (this._sortingChildCount > 0) { - if (index > (cnt - this._sortingChildCount - 1)) - index = cnt - this._sortingChildCount - 1; - } - this._setChildIndex(child, oldIndex, index); - }; - GComponent.prototype.setChildIndexBefore = function (child, index) { - var oldIndex = this._children.indexOf(child); - if (oldIndex == -1) - throw "Not a child of this container"; - if (child.sortingOrder != 0) - return oldIndex; - var cnt = this._children.length; - if (this._sortingChildCount > 0) { - if (index > (cnt - this._sortingChildCount - 1)) - index = cnt - this._sortingChildCount - 1; - } - if (oldIndex < index) - return this._setChildIndex(child, oldIndex, index - 1); - else - return this._setChildIndex(child, oldIndex, index); - }; - GComponent.prototype._setChildIndex = function (child, oldIndex, index) { - var cnt = this._children.length; - if (index > cnt) - index = cnt; - if (oldIndex == index) - return oldIndex; - this._children.splice(oldIndex, 1); - this._children.splice(index, 0, child); - if (child.inContainer) { - var displayIndex = 0; - var g; - var i; - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Ascent) { - for (i = 0; i < index; i++) { - g = this._children[i]; - if (g.inContainer) - displayIndex++; - } - if (displayIndex == this._container.numChildren) - displayIndex--; - this._container.setChildIndex(child.displayObject, displayIndex); - } - else if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Descent) { - for (i = cnt - 1; i > index; i--) { - g = this._children[i]; - if (g.inContainer) - displayIndex++; - } - if (displayIndex == this._container.numChildren) - displayIndex--; - this._container.setChildIndex(child.displayObject, displayIndex); - } - else { - fgui.GTimers.inst.callLater(this.buildNativeDisplayList, this); - } - this.setBoundsChangedFlag(); - } - return index; - }; - GComponent.prototype.swapChildren = function (child1, child2) { - var index1 = this._children.indexOf(child1); - var index2 = this._children.indexOf(child2); - if (index1 == -1 || index2 == -1) - throw "Not a child of this container"; - this.swapChildrenAt(index1, index2); - }; - GComponent.prototype.swapChildrenAt = function (index1, index2) { - var child1 = this._children[index1]; - var child2 = this._children[index2]; - this.setChildIndex(child1, index2); - this.setChildIndex(child2, index1); - }; - Object.defineProperty(GComponent.prototype, "numChildren", { - get: function () { - return this._children.length; - }, - enumerable: true, - configurable: true - }); - GComponent.prototype.isAncestorOf = function (child) { - if (!child) - return false; - var p = child.parent; - while (p) { - if (p == this) - return true; - p = p.parent; - } - return false; - }; - GComponent.prototype.addController = function (controller) { - this._controllers.push(controller); - controller.parent = this; - this.applyController(controller); - }; - GComponent.prototype.getControllerAt = function (index) { - return this._controllers[index]; - }; - GComponent.prototype.getController = function (name) { - var cnt = this._controllers.length; - for (var i = 0; i < cnt; ++i) { - var c = this._controllers[i]; - if (c.name == name) - return c; - } - return null; - }; - GComponent.prototype.removeController = function (c) { - var index = this._controllers.indexOf(c); - if (index == -1) - throw "controller not exists"; - c.parent = null; - this._controllers.splice(index, 1); - var length = this._children.length; - for (var i = 0; i < length; i++) { - var child = this._children[i]; - child.handleControllerChanged(c); - } - }; - Object.defineProperty(GComponent.prototype, "controllers", { - get: function () { - return this._controllers; - }, - enumerable: true, - configurable: true - }); - GComponent.prototype.childStateChanged = function (child) { - if (this._buildingDisplayList) - return; - var cnt = this._children.length; - var g; - var i; - if (child instanceof fgui.GGroup) { - for (i = 0; i < cnt; i++) { - g = this._children[i]; - if (g.group == child) - this.childStateChanged(g); - } - return; - } - if (!child.displayObject) - return; - if (child.internalVisible) { - if (!child.displayObject.parent) { - var index = 0; - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Ascent) { - for (i = 0; i < cnt; i++) { - g = this._children[i]; - if (g == child) - break; - if (g.displayObject && g.displayObject.parent) - index++; - } - this._container.addChildAt(child.displayObject, index); - } - else if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Descent) { - for (i = cnt - 1; i >= 0; i--) { - g = this._children[i]; - if (g == child) - break; - if (g.displayObject && g.displayObject.parent) - index++; - } - this._container.addChildAt(child.displayObject, index); - } - else { - this._container.addChild(child.displayObject); - fgui.GTimers.inst.callLater(this.buildNativeDisplayList, this); - } - } - } - else { - if (child.displayObject.parent) - this._container.removeChild(child.displayObject); - } - }; - GComponent.prototype.buildNativeDisplayList = function () { - var cnt = this._children.length; - if (cnt == 0) - return; - var i; - var child; - switch (this._childrenRenderOrder) { - case fgui.ChildrenRenderOrder.Ascent: - { - for (i = 0; i < cnt; i++) { - child = this._children[i]; - if (child.displayObject && child.internalVisible) - this._container.addChild(child.displayObject); - } - } - break; - case fgui.ChildrenRenderOrder.Descent: - { - for (i = cnt - 1; i >= 0; i--) { - child = this._children[i]; - if (child.displayObject && child.internalVisible) - this._container.addChild(child.displayObject); - } - } - break; - case fgui.ChildrenRenderOrder.Arch: - { - var apex = fgui.ToolSet.clamp(this._apexIndex, 0, cnt); - for (i = 0; i < apex; i++) { - child = this._children[i]; - if (child.displayObject && child.internalVisible) - this._container.addChild(child.displayObject); - } - for (i = cnt - 1; i >= apex; i--) { - child = this._children[i]; - if (child.displayObject && child.internalVisible) - this._container.addChild(child.displayObject); - } - } - break; - } - }; - GComponent.prototype.applyController = function (c) { - this._applyingController = c; - var child; - var length = this._children.length; - for (var i = 0; i < length; i++) { - child = this._children[i]; - child.handleControllerChanged(c); - } - this._applyingController = null; - c.runActions(); - }; - GComponent.prototype.applyAllControllers = function () { - var cnt = this._controllers.length; - for (var i = 0; i < cnt; ++i) { - this.applyController(this._controllers[i]); - } - }; - GComponent.prototype.adjustRadioGroupDepth = function (obj, c) { - var cnt = this._children.length; - var i; - var child; - var myIndex = -1, maxIndex = -1; - for (i = 0; i < cnt; i++) { - child = this._children[i]; - if (child == obj) { - myIndex = i; - } - else if ((child instanceof fgui.GButton) && child.relatedController == c) { - if (i > maxIndex) - maxIndex = i; - } - } - if (myIndex < maxIndex) { - if (this._applyingController) - this._children[maxIndex].handleControllerChanged(this._applyingController); - this.swapChildrenAt(myIndex, maxIndex); - } - }; - GComponent.prototype.getTransitionAt = function (index) { - return this._transitions[index]; - }; - GComponent.prototype.getTransition = function (transName) { - var cnt = this._transitions.length; - for (var i = 0; i < cnt; ++i) { - var trans = this._transitions[i]; - if (trans.name == transName) - return trans; - } - return null; - }; - GComponent.prototype.isChildInView = function (child) { - if (this._rootContainer.scrollRect) { - return child.x + child.width >= 0 && child.x <= this.width - && child.y + child.height >= 0 && child.y <= this.height; - } - else if (this._scrollPane) { - return this._scrollPane.isChildInView(child); - } - else - return true; - }; - GComponent.prototype.getFirstChildInView = function () { - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - var child = this._children[i]; - if (this.isChildInView(child)) - return i; - } - return -1; - }; - Object.defineProperty(GComponent.prototype, "scrollPane", { - get: function () { - return this._scrollPane; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "opaque", { - get: function () { - return this._rootContainer.opaque; - }, - set: function (value) { - this._rootContainer.opaque = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "margin", { - get: function () { - return this._margin; - }, - set: function (value) { - this._margin.copy(value); - if (this._rootContainer.scrollRect) { - this._container.x = this._margin.left + this._alignOffset.x; - this._container.y = this._margin.top + this._alignOffset.y; - } - this.handleSizeChanged(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "childrenRenderOrder", { - get: function () { - return this._childrenRenderOrder; - }, - set: function (value) { - if (this._childrenRenderOrder != value) { - this._childrenRenderOrder = value; - this.buildNativeDisplayList(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "apexIndex", { - get: function () { - return this._apexIndex; - }, - set: function (value) { - if (this._apexIndex != value) { - this._apexIndex = value; - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Arch) - this.buildNativeDisplayList(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "mask", { - get: function () { - return this._rootContainer.mask; - }, - set: function (value) { - this._rootContainer.mask = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "baseUserData", { - get: function () { - var buffer = this.packageItem.rawData; - buffer.seek(0, 4); - return buffer.readS(); - }, - enumerable: true, - configurable: true - }); - GComponent.prototype.updateScrollRect = function () { - var rect = this._rootContainer.scrollRect; - if (rect == null) - rect = new egret.Rectangle(); - var w = this.width - this._margin.right; - var h = this.height - this._margin.bottom; - rect.setTo(0, 0, w, h); - this._rootContainer.scrollRect = rect; - }; - GComponent.prototype.setupScroll = function (buffer) { - if (this._rootContainer == this._container) { - this._container = new egret.DisplayObjectContainer(); - this._rootContainer.addChild(this._container); - } - this._scrollPane = new fgui.ScrollPane(this); - this._scrollPane.setup(buffer); - this.setBoundsChangedFlag(); - }; - GComponent.prototype.setupOverflow = function (overflow) { - if (overflow == fgui.OverflowType.Hidden) { - if (this._rootContainer == this._container) { - this._container = new egret.DisplayObjectContainer(); - this._rootContainer.addChild(this._container); - } - this.updateScrollRect(); - this._container.x = this._margin.left; - this._container.y = this._margin.top; - } - else if (this._margin.left != 0 || this._margin.top != 0) { - if (this._rootContainer == this._container) { - this._container = new egret.DisplayObjectContainer(); - this._rootContainer.addChild(this._container); - } - this._container.x = this._margin.left; - this._container.y = this._margin.top; - } - this.setBoundsChangedFlag(); - }; - GComponent.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (this._scrollPane) - this._scrollPane.onOwnerSizeChanged(); - else if (this._rootContainer.scrollRect) - this.updateScrollRect(); - if (this._rootContainer.hitArea instanceof fgui.PixelHitTest) { - var hitTest = (this._rootContainer.hitArea); - if (this.sourceWidth != 0) - hitTest.scaleX = this._width / this.sourceWidth; - if (this.sourceHeight != 0) - hitTest.scaleY = this._height / this.sourceHeight; - } - }; - GComponent.prototype.handleGrayedChanged = function () { - var c = this.getController("grayed"); - if (c) { - c.selectedIndex = this.grayed ? 1 : 0; - return; - } - var v = this.grayed; - var cnt = this._children.length; - for (var i = 0; i < cnt; ++i) { - this._children[i].grayed = v; - } - }; - GComponent.prototype.handleControllerChanged = function (c) { - _super_1.prototype.handleControllerChanged.call(this, c); - if (this._scrollPane) - this._scrollPane.handleControllerChanged(c); - }; - GComponent.prototype.setBoundsChangedFlag = function () { - if (!this._scrollPane && !this._trackBounds) - return; - if (!this._boundsChanged) { - this._boundsChanged = true; - egret.callLater(this.__render, this); - } - }; - GComponent.prototype.__render = function () { - if (this._boundsChanged) { - var len = this._children.length; - if (len > 0) { - for (var i = 0; i < len; i++) { - var child = this._children[i]; - child.ensureSizeCorrect(); - } - } - this.updateBounds(); - } - }; - GComponent.prototype.ensureBoundsCorrect = function () { - var len = this._children.length; - if (len > 0) { - for (var i = 0; i < len; i++) { - var child = this._children[i]; - child.ensureSizeCorrect(); - } - } - if (this._boundsChanged) - this.updateBounds(); - }; - GComponent.prototype.updateBounds = function () { - var ax = 0, ay = 0, aw = 0, ah = 0; - var len = this._children.length; - if (len > 0) { - ax = Number.POSITIVE_INFINITY, ay = Number.POSITIVE_INFINITY; - var ar = Number.NEGATIVE_INFINITY, ab = Number.NEGATIVE_INFINITY; - var tmp = 0; - var i = 0; - for (var i = 0; i < len; i++) { - var child = this._children[i]; - tmp = child.x; - if (tmp < ax) - ax = tmp; - tmp = child.y; - if (tmp < ay) - ay = tmp; - tmp = child.x + child.actualWidth; - if (tmp > ar) - ar = tmp; - tmp = child.y + child.actualHeight; - if (tmp > ab) - ab = tmp; - } - aw = ar - ax; - ah = ab - ay; - } - this.setBounds(ax, ay, aw, ah); - }; - GComponent.prototype.setBounds = function (ax, ay, aw, ah) { - if (ah === void 0) { ah = 0; } - this._boundsChanged = false; - if (this._scrollPane) - this._scrollPane.setContentSize(Math.round(ax + aw), Math.round(ay + ah)); - }; - Object.defineProperty(GComponent.prototype, "viewWidth", { - get: function () { - if (this._scrollPane) - return this._scrollPane.viewWidth; - else - return this.width - this._margin.left - this._margin.right; - }, - set: function (value) { - if (this._scrollPane) - this._scrollPane.viewWidth = value; - else - this.width = value + this._margin.left + this._margin.right; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComponent.prototype, "viewHeight", { - get: function () { - if (this._scrollPane) - return this._scrollPane.viewHeight; - else - return this.height - this._margin.top - this._margin.bottom; - }, - set: function (value) { - if (this._scrollPane) - this._scrollPane.viewHeight = value; - else - this.height = value + this._margin.top + this._margin.bottom; - }, - enumerable: true, - configurable: true - }); - GComponent.prototype.getSnappingPosition = function (xValue, yValue, resultPoint) { - if (!resultPoint) - resultPoint = new egret.Point(); - var cnt = this._children.length; - if (cnt == 0) { - resultPoint.x = 0; - resultPoint.y = 0; - return resultPoint; - } - this.ensureBoundsCorrect(); - var obj = null; - var prev = null; - var i = 0; - if (yValue != 0) { - for (; i < cnt; i++) { - obj = this._children[i]; - if (yValue < obj.y) { - if (i == 0) { - yValue = 0; - break; - } - else { - prev = this._children[i - 1]; - if (yValue < prev.y + prev.actualHeight / 2) - yValue = prev.y; - else - yValue = obj.y; - break; - } - } - } - if (i == cnt) - yValue = obj.y; - } - if (xValue != 0) { - if (i > 0) - i--; - for (; i < cnt; i++) { - obj = this._children[i]; - if (xValue < obj.x) { - if (i == 0) { - xValue = 0; - break; - } - else { - prev = this._children[i - 1]; - if (xValue < prev.x + prev.actualWidth / 2) - xValue = prev.x; - else - xValue = obj.x; - break; - } - } - } - if (i == cnt) - xValue = obj.x; - } - resultPoint.x = xValue; - resultPoint.y = yValue; - return resultPoint; - }; - GComponent.prototype.childSortingOrderChanged = function (child, oldValue, newValue) { - if (newValue === void 0) { newValue = 0; } - if (newValue == 0) { - this._sortingChildCount--; - this.setChildIndex(child, this._children.length); - } - else { - if (oldValue == 0) - this._sortingChildCount++; - var oldIndex = this._children.indexOf(child); - var index = this.getInsertPosForSortingChild(child); - if (oldIndex < index) - this._setChildIndex(child, oldIndex, index - 1); - else - this._setChildIndex(child, oldIndex, index); - } - }; - GComponent.prototype.constructFromResource = function () { - this.constructFromResource2(null, 0); - }; - GComponent.prototype.constructFromResource2 = function (objectPool, poolIndex) { - var contentItem = this.packageItem.getBranch(); - if (!contentItem.decoded) { - contentItem.decoded = true; - fgui.TranslationHelper.translateComponent(contentItem); - } - var i; - var dataLen; - var curPos; - var nextPos; - var f1; - var f2; - var i1; - var i2; - var buffer = contentItem.rawData; - buffer.seek(0, 0); - this._underConstruct = true; - this.sourceWidth = buffer.readInt(); - this.sourceHeight = buffer.readInt(); - this.initWidth = this.sourceWidth; - this.initHeight = this.sourceHeight; - this.setSize(this.sourceWidth, this.sourceHeight); - if (buffer.readBool()) { - this.minWidth = buffer.readInt(); - this.maxWidth = buffer.readInt(); - this.minHeight = buffer.readInt(); - this.maxHeight = buffer.readInt(); - } - if (buffer.readBool()) { - f1 = buffer.readFloat(); - f2 = buffer.readFloat(); - this.internalSetPivot(f1, f2, buffer.readBool()); - } - if (buffer.readBool()) { - this._margin.top = buffer.readInt(); - this._margin.bottom = buffer.readInt(); - this._margin.left = buffer.readInt(); - this._margin.right = buffer.readInt(); - } - var overflow = buffer.readByte(); - if (overflow == fgui.OverflowType.Scroll) { - var savedPos = buffer.position; - buffer.seek(0, 7); - this.setupScroll(buffer); - buffer.position = savedPos; - } - else - this.setupOverflow(overflow); - if (buffer.readBool()) - buffer.skip(8); - this._buildingDisplayList = true; - buffer.seek(0, 1); - var controllerCount = buffer.readShort(); - for (i = 0; i < controllerCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - var controller = new fgui.Controller(); - this._controllers.push(controller); - controller.parent = this; - controller.setup(buffer); - buffer.position = nextPos; - } - buffer.seek(0, 2); - var child; - var childCount = buffer.readShort(); - for (i = 0; i < childCount; i++) { - dataLen = buffer.readShort(); - curPos = buffer.position; - if (objectPool) - child = objectPool[poolIndex + i]; - else { - buffer.seek(curPos, 0); - var type = buffer.readByte(); - var src = buffer.readS(); - var pkgId = buffer.readS(); - var pi = null; - if (src != null) { - var pkg; - if (pkgId != null) - pkg = fgui.UIPackage.getById(pkgId); - else - pkg = contentItem.owner; - pi = pkg ? pkg.getItemById(src) : null; - } - if (pi) { - child = fgui.UIObjectFactory.newObject(pi); - child.constructFromResource(); - } - else - child = fgui.UIObjectFactory.newObject(type); - } - child._underConstruct = true; - child.setup_beforeAdd(buffer, curPos); - child.parent = this; - this._children.push(child); - buffer.position = curPos + dataLen; - } - buffer.seek(0, 3); - this.relations.setup(buffer, true); - buffer.seek(0, 2); - buffer.skip(2); - for (i = 0; i < childCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - buffer.seek(buffer.position, 3); - this._children[i].relations.setup(buffer, false); - buffer.position = nextPos; - } - buffer.seek(0, 2); - buffer.skip(2); - for (i = 0; i < childCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - child = this._children[i]; - child.setup_afterAdd(buffer, buffer.position); - child._underConstruct = false; - buffer.position = nextPos; - } - buffer.seek(0, 4); - buffer.skip(2); - this.opaque = buffer.readBool(); - var maskId = buffer.readShort(); - if (maskId != -1) { - this.mask = this.getChildAt(maskId).displayObject; - buffer.readBool(); - } - var hitTestId = buffer.readS(); - i1 = buffer.readInt(); - i2 = buffer.readInt(); - if (hitTestId != null) { - pi = contentItem.owner.getItemById(hitTestId); - if (pi && pi.pixelHitTestData) - this._rootContainer.hitArea = new fgui.PixelHitTest(pi.pixelHitTestData, i1, i2); - } - else if (i1 != 0 && i2 != -1) { - this._rootContainer.hitArea = this.getChildAt(i2).displayObject; - } - buffer.seek(0, 5); - var transitionCount = buffer.readShort(); - for (i = 0; i < transitionCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - var trans = new fgui.Transition(this); - trans.setup(buffer); - this._transitions.push(trans); - buffer.position = nextPos; - } - if (this._transitions.length > 0) { - this.displayObject.addEventListener(egret.Event.ADDED_TO_STAGE, this.___added, this); - this.displayObject.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.___removed, this); - } - this.applyAllControllers(); - this._buildingDisplayList = false; - this._underConstruct = false; - this.buildNativeDisplayList(); - this.setBoundsChangedFlag(); - if (contentItem.objectType != fgui.ObjectType.Component) - this.constructExtension(buffer); - this.onConstruct(); - }; - GComponent.prototype.onConstruct = function () { - this.constructFromXML(null); - }; - GComponent.prototype.constructExtension = function (buffer) { - }; - GComponent.prototype.constructFromXML = function (xml) { - }; - GComponent.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 4); - var pageController = buffer.readShort(); - if (pageController != -1 && this._scrollPane) - this._scrollPane.pageController = this._parent.getControllerAt(pageController); - var cnt = buffer.readShort(); - for (var i = 0; i < cnt; i++) { - var cc = this.getController(buffer.readS()); - var pageId = buffer.readS(); - if (cc) - cc.selectedPageId = pageId; - } - if (buffer.version >= 2) { - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - var target = buffer.readS(); - var propertyId = buffer.readShort(); - var value = buffer.readS(); - var obj = this.getChildByPath(target); - if (obj) - obj.setProp(propertyId, value); - } - } - }; - GComponent.prototype.___added = function (evt) { - var cnt = this._transitions.length; - for (var i = 0; i < cnt; ++i) { - this._transitions[i].onOwnerAddedToStage(); - } - }; - GComponent.prototype.___removed = function (evt) { - var cnt = this._transitions.length; - for (var i = 0; i < cnt; ++i) { - this._transitions[i].onOwnerRemovedFromStage(); - } - }; - return GComponent; - }(fgui.GObject)); - fgui.GComponent = GComponent; -})(fgui || (fgui = {})); - -(function (fgui) { - var GButton = (function (_super_1) { - __extends(GButton, _super_1); - function GButton() { - var _this = _super_1.call(this) || this; - _this._mode = fgui.ButtonMode.Common; - _this._title = ""; - _this._icon = ""; - _this._sound = fgui.UIConfig.buttonSound; - _this._soundVolumeScale = fgui.UIConfig.buttonSoundVolumeScale; - _this._changeStateOnClick = true; - _this._downEffect = 0; - _this._downEffectValue = 0.8; - return _this; - } - Object.defineProperty(GButton.prototype, "icon", { - get: function () { - return this._icon; - }, - set: function (value) { - this._icon = value; - value = (this._selected && this._selectedIcon) ? this._selectedIcon : this._icon; - if (this._iconObject) - this._iconObject.icon = value; - this.updateGear(7); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "selectedIcon", { - get: function () { - return this._selectedIcon; - }, - set: function (value) { - this._selectedIcon = value; - value = (this._selected && this._selectedIcon) ? this._selectedIcon : this._icon; - if (this._iconObject) - this._iconObject.icon = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "title", { - get: function () { - return this._title; - }, - set: function (value) { - this._title = value; - if (this._titleObject) - this._titleObject.text = (this._selected && this._selectedTitle) ? this._selectedTitle : this._title; - this.updateGear(6); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "text", { - get: function () { - return this.title; - }, - set: function (value) { - this.title = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "selectedTitle", { - get: function () { - return this._selectedTitle; - }, - set: function (value) { - this._selectedTitle = value; - if (this._titleObject) - this._titleObject.text = (this._selected && this._selectedTitle) ? this._selectedTitle : this._title; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "titleColor", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.color; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.color = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "titleFontSize", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.fontSize; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.fontSize = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "sound", { - get: function () { - return this._sound; - }, - set: function (val) { - this._sound = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "soundVolumeScale", { - get: function () { - return this._soundVolumeScale; - }, - set: function (value) { - this._soundVolumeScale = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "selected", { - get: function () { - return this._selected; - }, - set: function (val) { - if (this._mode == fgui.ButtonMode.Common) - return; - if (this._selected != val) { - this._selected = val; - if (this.grayed && this._buttonController && this._buttonController.hasPage(GButton.DISABLED)) { - if (this._selected) - this.setState(GButton.SELECTED_DISABLED); - else - this.setState(GButton.DISABLED); - } - else { - if (this._selected) - this.setState(this._over ? GButton.SELECTED_OVER : GButton.DOWN); - else - this.setState(this._over ? GButton.OVER : GButton.UP); - } - if (this._selectedTitle && this._titleObject) - this._titleObject.text = this._selected ? this._selectedTitle : this._title; - if (this._selectedIcon) { - var str = this._selected ? this._selectedIcon : this._icon; - if (this._iconObject) - this._iconObject.icon = str; - } - if (this._relatedController - && this._parent - && !this._parent._buildingDisplayList) { - if (this._selected) { - this._relatedController.selectedPageId = this._relatedPageId; - if (this._relatedController.autoRadioGroupDepth) - this._parent.adjustRadioGroupDepth(this, this._relatedController); - } - else if (this._mode == fgui.ButtonMode.Check && this._relatedController.selectedPageId == this._relatedPageId) - this._relatedController.oppositePageId = this._relatedPageId; - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "mode", { - get: function () { - return this._mode; - }, - set: function (value) { - if (this._mode != value) { - if (value == fgui.ButtonMode.Common) - this.selected = false; - this._mode = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "relatedController", { - get: function () { - return this._relatedController; - }, - set: function (val) { - this._relatedController = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "relatedPageId", { - get: function () { - return this._relatedPageId; - }, - set: function (val) { - this._relatedPageId = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "changeStateOnClick", { - get: function () { - return this._changeStateOnClick; - }, - set: function (value) { - this._changeStateOnClick = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GButton.prototype, "linkedPopup", { - get: function () { - return this._linkedPopup; - }, - set: function (value) { - this._linkedPopup = value; - }, - enumerable: true, - configurable: true - }); - GButton.prototype.getTextField = function () { - if (this._titleObject instanceof fgui.GTextField) - return this._titleObject; - else if ((this._titleObject instanceof fgui.GLabel) || (this._titleObject instanceof GButton)) - return this._titleObject.getTextField(); - else - return null; - }; - GButton.prototype.addStateListener = function (listener, thisObj) { - this.addEventListener(fgui.StateChangeEvent.CHANGED, listener, thisObj); - }; - GButton.prototype.removeStateListener = function (listener, thisObj) { - this.removeEventListener(fgui.StateChangeEvent.CHANGED, listener, thisObj); - }; - GButton.prototype.fireClick = function (downEffect) { - if (downEffect && this._mode == fgui.ButtonMode.Common) { - this.setState(GButton.OVER); - fgui.GTimers.inst.add(100, 1, function () { this.setState(GButton.DOWN); }, this); - fgui.GTimers.inst.add(200, 1, function () { this.setState(GButton.UP); }, this); - } - this.__click(null); - }; - GButton.prototype.setState = function (val) { - if (this._buttonController) - this._buttonController.selectedPage = val; - if (this._downEffect == 1) { - var cnt = this.numChildren; - if (val == GButton.DOWN || val == GButton.SELECTED_OVER || val == GButton.SELECTED_DISABLED) { - var r = this._downEffectValue * 255; - var color = (r << 16) + (r << 8) + r; - for (var i = 0; i < cnt; i++) { - var obj = this.getChildAt(i); - if (obj["color"] != undefined && !(obj instanceof fgui.GTextField)) - obj.color = color; - } - } - else { - for (var i = 0; i < cnt; i++) { - var obj = this.getChildAt(i); - if (obj["color"] != undefined && !(obj instanceof fgui.GTextField)) - obj.color = 0xFFFFFF; - } - } - } - else if (this._downEffect == 2) { - if (val == GButton.DOWN || val == GButton.SELECTED_OVER || val == GButton.SELECTED_DISABLED) { - if (!this._downScaled) { - this._downScaled = true; - this._rootContainer.cacheHitArea(true); - this.setScale(this.scaleX * this._downEffectValue, this.scaleY * this._downEffectValue); - } - } - else { - if (this._downScaled) { - this._downScaled = false; - this._rootContainer.cacheHitArea(false); - this.setScale(this.scaleX / this._downEffectValue, this.scaleY / this._downEffectValue); - } - } - } - }; - GButton.prototype.handleControllerChanged = function (c) { - _super_1.prototype.handleControllerChanged.call(this, c); - if (this._relatedController == c) - this.selected = this._relatedPageId == c.selectedPageId; - }; - GButton.prototype.handleGrayedChanged = function () { - if (this._buttonController && this._buttonController.hasPage(GButton.DISABLED)) { - if (this.grayed) { - if (this._selected && this._buttonController.hasPage(GButton.SELECTED_DISABLED)) - this.setState(GButton.SELECTED_DISABLED); - else - this.setState(GButton.DISABLED); - } - else if (this._selected) - this.setState(GButton.DOWN); - else - this.setState(GButton.UP); - } - else - _super_1.prototype.handleGrayedChanged.call(this); - }; - GButton.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.titleColor; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - return tf.strokeColor; - else - return 0; - } - case fgui.ObjectPropID.FontSize: - return this.titleFontSize; - case fgui.ObjectPropID.Selected: - return this.selected; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GButton.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.titleColor = value; - break; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - tf.strokeColor = value; - } - break; - case fgui.ObjectPropID.FontSize: - this.titleFontSize = value; - break; - case fgui.ObjectPropID.Selected: - this.selected = value; - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GButton.prototype.constructExtension = function (buffer) { - buffer.seek(0, 6); - this._mode = buffer.readByte(); - var str = buffer.readS(); - if (str) - this._sound = str; - this._soundVolumeScale = buffer.readFloat(); - this._downEffect = buffer.readByte(); - this._downEffectValue = buffer.readFloat(); - if (this._downEffect == 2) - this.setPivot(0.5, 0.5, this.pivotAsAnchor); - this._buttonController = this.getController("button"); - this._titleObject = this.getChild("title"); - this._iconObject = this.getChild("icon"); - if (this._titleObject) - this._title = this._titleObject.text; - if (this._iconObject) - this._icon = this._iconObject.icon; - if (this._mode == fgui.ButtonMode.Common) - this.setState(GButton.UP); - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__mousedown, this); - this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.__click, this); - }; - GButton.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!buffer.seek(beginPos, 6)) - return; - if (buffer.readByte() != this.packageItem.objectType) - return; - var str; - var iv; - str = buffer.readS(); - if (str != null) - this.title = str; - str = buffer.readS(); - if (str != null) - this.selectedTitle = str; - str = buffer.readS(); - if (str != null) - this.icon = str; - str = buffer.readS(); - if (str != null) - this.selectedIcon = str; - if (buffer.readBool()) - this.titleColor = buffer.readColor(); - iv = buffer.readInt(); - if (iv != 0) - this.titleFontSize = iv; - iv = buffer.readShort(); - if (iv >= 0) - this._relatedController = this.parent.getControllerAt(iv); - this._relatedPageId = buffer.readS(); - str = buffer.readS(); - if (str != null) - this._sound = str; - if (buffer.readBool()) - this._soundVolumeScale = buffer.readFloat(); - this.selected = buffer.readBool(); - }; - GButton.prototype.__mousedown = function (evt) { - this._down = true; - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_END, this.__mouseup, this); - if (this._mode == fgui.ButtonMode.Common) { - if (this.grayed && this._buttonController && this._buttonController.hasPage(GButton.DISABLED)) - this.setState(GButton.SELECTED_DISABLED); - else - this.setState(GButton.DOWN); - } - if (this._linkedPopup) { - if (this._linkedPopup instanceof fgui.Window) - this._linkedPopup.toggleStatus(); - else - this.root.togglePopup(this._linkedPopup, this); - } - }; - GButton.prototype.__mouseup = function (evt) { - if (this._down) { - fgui.GRoot.inst.nativeStage.removeEventListener(egret.TouchEvent.TOUCH_END, this.__mouseup, this); - this._down = false; - if (!this.displayObject) - return; - if (this._mode == fgui.ButtonMode.Common) { - if (this.grayed && this._buttonController && this._buttonController.hasPage(GButton.DISABLED)) - this.setState(GButton.DISABLED); - else if (this._over) - this.setState(GButton.OVER); - else - this.setState(GButton.UP); - } - } - }; - GButton.prototype.__click = function (evt) { - if (this._sound) { - var pi = fgui.UIPackage.getItemByURL(this._sound); - if (pi) { - var sound = pi.owner.getItemAsset(pi); - if (sound) - fgui.GRoot.inst.playOneShotSound(sound, this._soundVolumeScale); - } - } - if (this._mode == fgui.ButtonMode.Check) { - if (this._changeStateOnClick) { - this.selected = !this._selected; - this.dispatchEvent(new fgui.StateChangeEvent(fgui.StateChangeEvent.CHANGED)); - } - } - else if (this._mode == fgui.ButtonMode.Radio) { - if (this._changeStateOnClick && !this._selected) { - this.selected = true; - this.dispatchEvent(new fgui.StateChangeEvent(fgui.StateChangeEvent.CHANGED)); - } - } - else { - if (this._relatedController) - this._relatedController.selectedPageId = this._relatedPageId; - } - }; - GButton.UP = "up"; - GButton.DOWN = "down"; - GButton.OVER = "over"; - GButton.SELECTED_OVER = "selectedOver"; - GButton.DISABLED = "disabled"; - GButton.SELECTED_DISABLED = "selectedDisabled"; - return GButton; - }(fgui.GComponent)); - fgui.GButton = GButton; -})(fgui || (fgui = {})); - -(function (fgui) { - var GComboBox = (function (_super_1) { - __extends(GComboBox, _super_1); - function GComboBox() { - var _this = _super_1.call(this) || this; - _this._visibleItemCount = 0; - _this._selectedIndex = 0; - _this._popupDirection = fgui.PopupDirection.Auto; - _this._visibleItemCount = fgui.UIConfig.defaultComboBoxVisibleItemCount; - _this._itemsUpdated = true; - _this._selectedIndex = -1; - _this._items = []; - _this._values = []; - return _this; - } - Object.defineProperty(GComboBox.prototype, "text", { - get: function () { - if (this._titleObject) - return this._titleObject.text; - else - return null; - }, - set: function (value) { - if (this._titleObject) - this._titleObject.text = value; - this.updateGear(6); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "icon", { - get: function () { - if (this._iconObject) - return this._iconObject.icon; - else - return null; - }, - set: function (value) { - if (this._iconObject) - this._iconObject.icon = value; - this.updateGear(7); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "titleColor", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.color; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.color = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "titleFontSize", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.fontSize; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.fontSize = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "visibleItemCount", { - get: function () { - return this._visibleItemCount; - }, - set: function (value) { - this._visibleItemCount = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "popupDirection", { - get: function () { - return this._popupDirection; - }, - set: function (value) { - this._popupDirection = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "items", { - get: function () { - return this._items; - }, - set: function (value) { - if (!value) - this._items.length = 0; - else - this._items = value.concat(); - if (this._items.length > 0) { - if (this._selectedIndex >= this._items.length) - this._selectedIndex = this._items.length - 1; - else if (this._selectedIndex == -1) - this._selectedIndex = 0; - this.text = this._items[this._selectedIndex]; - if (this._icons && this._selectedIndex < this._icons.length) - this.icon = this._icons[this._selectedIndex]; - } - else { - this.text = ""; - if (this._icons) - this.icon = null; - this._selectedIndex = -1; - } - this._itemsUpdated = true; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "icons", { - get: function () { - return this._icons; - }, - set: function (value) { - this._icons = value; - if (this._icons && this._selectedIndex != -1 && this._selectedIndex < this._icons.length) - this.icon = this._icons[this._selectedIndex]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "values", { - get: function () { - return this._values; - }, - set: function (value) { - if (!value) - this._values.length = 0; - else - this._values = value.concat(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "selectedIndex", { - get: function () { - return this._selectedIndex; - }, - set: function (val) { - if (this._selectedIndex == val) - return; - this._selectedIndex = val; - if (this._selectedIndex >= 0 && this._selectedIndex < this._items.length) { - this.text = this._items[this._selectedIndex]; - if (this._icons && this._selectedIndex < this._icons.length) - this.icon = this._icons[this._selectedIndex]; - } - else { - this.text = ""; - if (this._icons) - this.icon = null; - } - this.updateSelectionController(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "value", { - get: function () { - return this._values[this._selectedIndex]; - }, - set: function (val) { - var index = this._values.indexOf(val); - if (index == -1 && val == null) - index = this._values.indexOf(""); - this.selectedIndex = index; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GComboBox.prototype, "selectionController", { - get: function () { - return this._selectionController; - }, - set: function (value) { - this._selectionController = value; - }, - enumerable: true, - configurable: true - }); - GComboBox.prototype.getTextField = function () { - if (this._titleObject instanceof fgui.GTextField) - return this._titleObject; - else if ((this._titleObject instanceof fgui.GLabel) || (this._titleObject instanceof fgui.GButton)) - return this._titleObject.getTextField(); - else - return null; - }; - GComboBox.prototype.setState = function (val) { - if (this._buttonController) - this._buttonController.selectedPage = val; - }; - GComboBox.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.titleColor; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - return tf.strokeColor; - else - return 0; - } - case fgui.ObjectPropID.FontSize: - { - tf = this.getTextField(); - if (tf) - return tf.fontSize; - else - return 0; - } - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GComboBox.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.titleColor = value; - break; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - tf.strokeColor = value; - } - break; - case fgui.ObjectPropID.FontSize: - { - tf = this.getTextField(); - if (tf) - tf.fontSize = value; - } - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GComboBox.prototype.constructExtension = function (buffer) { - var str; - this._buttonController = this.getController("button"); - this._titleObject = this.getChild("title"); - this._iconObject = this.getChild("icon"); - str = buffer.readS(); - if (str) { - this.dropdown = (fgui.UIPackage.createObjectFromURL(str)); - if (!this.dropdown) { - console.error("下拉框必须为元件"); - return; - } - this.dropdown.name = "this.dropdown"; - this._list = this.dropdown.getChild("list").asList; - if (this._list == null) { - console.error(this.resourceURL + ": 下拉框的弹出元件里必须包含名为list的列表"); - return; - } - this._list.addEventListener(fgui.ItemEvent.CLICK, this.__clickItem, this); - this._list.addRelation(this.dropdown, fgui.RelationType.Width); - this._list.removeRelation(this.dropdown, fgui.RelationType.Height); - this.dropdown.addRelation(this._list, fgui.RelationType.Height); - this.dropdown.removeRelation(this._list, fgui.RelationType.Width); - this.dropdown.displayObject.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.__popupWinClosed, this); - } - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__mousedown, this); - }; - GComboBox.prototype.handleControllerChanged = function (c) { - _super_1.prototype.handleControllerChanged.call(this, c); - if (this._selectionController == c) - this.selectedIndex = c.selectedIndex; - }; - GComboBox.prototype.updateSelectionController = function () { - if (this._selectionController && !this._selectionController.changing - && this._selectedIndex < this._selectionController.pageCount) { - var c = this._selectionController; - this._selectionController = null; - c.selectedIndex = this._selectedIndex; - this._selectionController = c; - } - }; - GComboBox.prototype.dispose = function () { - if (this.dropdown) { - this.dropdown.dispose(); - this.dropdown = null; - } - _super_1.prototype.dispose.call(this); - }; - GComboBox.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!buffer.seek(beginPos, 6)) - return; - if (buffer.readByte() != this.packageItem.objectType) - return; - var i; - var iv; - var nextPos; - var str; - var itemCount = buffer.readShort(); - for (i = 0; i < itemCount; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - this._items[i] = buffer.readS(); - this._values[i] = buffer.readS(); - str = buffer.readS(); - if (str != null) { - if (this._icons == null) - this._icons = new Array(); - this._icons[i] = str; - } - buffer.position = nextPos; - } - str = buffer.readS(); - if (str != null) { - this.text = str; - this._selectedIndex = this._items.indexOf(str); - } - else if (this._items.length > 0) { - this._selectedIndex = 0; - this.text = this._items[0]; - } - else - this._selectedIndex = -1; - str = buffer.readS(); - if (str != null) - this.icon = str; - if (buffer.readBool()) - this.titleColor = buffer.readColor(); - iv = buffer.readInt(); - if (iv > 0) - this._visibleItemCount = iv; - this._popupDirection = buffer.readByte(); - iv = buffer.readShort(); - if (iv >= 0) - this._selectionController = this.parent.getControllerAt(iv); - }; - GComboBox.prototype.showDropdown = function () { - if (this._itemsUpdated) { - this._itemsUpdated = false; - this._list.removeChildrenToPool(); - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._list.addItemFromPool(); - item.name = i < this._values.length ? this._values[i] : ""; - item.text = this._items[i]; - item.icon = (this._icons && i < this._icons.length) ? this._icons[i] : null; - } - this._list.resizeToFit(this._visibleItemCount); - } - this._list.selectedIndex = -1; - this.dropdown.width = this.width; - this._list.ensureBoundsCorrect(); - this.root.togglePopup(this.dropdown, this, this._popupDirection); - if (this.dropdown.parent) - this.setState(fgui.GButton.DOWN); - }; - GComboBox.prototype.__popupWinClosed = function (evt) { - if (this._over) - this.setState(fgui.GButton.OVER); - else - this.setState(fgui.GButton.UP); - }; - GComboBox.prototype.__clickItem = function (evt) { - fgui.GTimers.inst.add(100, 1, this.__clickItem2, this, this._list.getChildIndex(evt.itemObject)); - }; - GComboBox.prototype.__clickItem2 = function (index) { - if (this.dropdown.parent instanceof fgui.GRoot) - this.dropdown.parent.hidePopup(); - this._selectedIndex = -1; - this.selectedIndex = index; - this.dispatchEvent(new fgui.StateChangeEvent(fgui.StateChangeEvent.CHANGED)); - }; - GComboBox.prototype.__mousedown = function (evt) { - if ((evt.target instanceof egret.TextField) && evt.target.type == egret.TextFieldType.INPUT) - return; - this._down = true; - fgui.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_END, this.__mouseup, this); - if (this.dropdown) - this.showDropdown(); - }; - GComboBox.prototype.__mouseup = function (evt) { - if (this._down) { - this._down = false; - fgui.GRoot.inst.nativeStage.removeEventListener(egret.TouchEvent.TOUCH_END, this.__mouseup, this); - if (this.dropdown && !this.dropdown.parent) { - if (this._over) - this.setState(fgui.GButton.OVER); - else - this.setState(fgui.GButton.UP); - } - } - }; - return GComboBox; - }(fgui.GComponent)); - fgui.GComboBox = GComboBox; -})(fgui || (fgui = {})); - -(function (fgui) { - var GGraph = (function (_super_1) { - __extends(GGraph, _super_1); - function GGraph() { - var _this = _super_1.call(this) || this; - _this._type = 0; - _this._lineSize = 0; - _this._lineColor = 0; - _this._fillColor = 0; - _this._lineSize = 1; - _this._lineAlpha = 1; - _this._fillAlpha = 1; - _this._fillColor = 0xFFFFFF; - return _this; - } - Object.defineProperty(GGraph.prototype, "graphics", { - get: function () { - return this._graphics; - }, - enumerable: true, - configurable: true - }); - GGraph.prototype.drawRect = function (lineSize, lineColor, lineAlpha, fillColor, fillAlpha, corner) { - this._type = 1; - this._lineSize = lineSize; - this._lineColor = lineColor; - this._lineAlpha = lineAlpha; - this._fillColor = fillColor; - this._fillAlpha = fillAlpha; - this._cornerRadius = corner; - this.updateGraph(); - }; - GGraph.prototype.drawEllipse = function (lineSize, lineColor, lineAlpha, fillColor, fillAlpha) { - this._type = 2; - this._lineSize = lineSize; - this._lineColor = lineColor; - this._lineAlpha = lineAlpha; - this._fillColor = fillColor; - this._fillAlpha = fillAlpha; - this._cornerRadius = null; - this.updateGraph(); - }; - GGraph.prototype.drawRegularPolygon = function (lineSize, lineColor, lineAlpha, fillColor, fillAlpha, sides, startAngle, distances) { - this._type = 4; - this._lineSize = lineSize; - this._lineColor = lineColor; - this._lineAlpha = lineAlpha; - this._fillColor = fillColor; - this._fillAlpha = fillAlpha; - this._sides = sides; - this._startAngle = startAngle || 0; - this._distances = distances; - this.updateGraph(); - }; - GGraph.prototype.drawPolygon = function (lineSize, lineColor, lineAlpha, fillColor, fillAlpha, points) { - this._type = 3; - this._lineSize = lineSize; - this._lineColor = lineColor; - this._lineAlpha = lineAlpha; - this._fillColor = fillColor; - this._fillAlpha = fillAlpha; - this._polygonPoints = points; - this.updateGraph(); - }; - Object.defineProperty(GGraph.prototype, "distances", { - get: function () { - return this._distances; - }, - set: function (value) { - this._distances = value; - if (this._type == 3) - this.updateGraph(); - }, - enumerable: true, - configurable: true - }); - GGraph.prototype.clearGraphics = function () { - if (this._graphics) { - this._type = 0; - this._graphics.clear(); - } - }; - Object.defineProperty(GGraph.prototype, "color", { - get: function () { - return this._fillColor; - }, - set: function (value) { - this._fillColor = value; - if (this._type != 0) - this.updateGraph(); - }, - enumerable: true, - configurable: true - }); - GGraph.prototype.updateGraph = function () { - var ctx = this.graphics; - ctx.clear(); - var w = this.width; - var h = this.height; - if (w == 0 || h == 0) - return; - if (this._lineSize == 0) - ctx.lineStyle(0, 0, 0); - else - ctx.lineStyle(this._lineSize, this._lineColor, this._lineAlpha); - ctx.beginFill(this._fillColor, this._fillAlpha); - if (this._type == 1) { - if (this._cornerRadius) { - if (this._cornerRadius.length == 1) - ctx.drawRoundRect(0, 0, w, h, this._cornerRadius[0] * 2, this._cornerRadius[0] * 2); - else - ctx.drawRoundRect(0, 0, w, h, this._cornerRadius[0] * 2, this._cornerRadius[1] * 2); - } - else - ctx.drawRect(0, 0, w, h); - } - else if (this._type == 2) - ctx.drawEllipse(0, 0, w, h); - else if (this._type == 3) { - fgui.ToolSet.fillPath(ctx, this._polygonPoints, 0, 0); - } - else if (this._type == 4) { - if (!this._polygonPoints) - this._polygonPoints = []; - var radius = Math.min(this._width, this._height) / 2; - this._polygonPoints.length = 0; - var angle = this._startAngle * Math.PI / 180; - var deltaAngle = 2 * Math.PI / this._sides; - var dist; - for (var i = 0; i < this._sides; i++) { - if (this._distances) { - dist = this._distances[i]; - if (isNaN(dist)) - dist = 1; - } - else - dist = 1; - var xv = radius + radius * dist * Math.cos(angle); - var yv = radius + radius * dist * Math.sin(angle); - this._polygonPoints.push(xv, yv); - angle += deltaAngle; - } - fgui.ToolSet.fillPath(ctx, this._polygonPoints, 0, 0); - } - ctx.endFill(); - }; - GGraph.prototype.replaceMe = function (target) { - if (!this._parent) - throw "parent not set"; - target.name = this.name; - target.alpha = this.alpha; - target.rotation = this.rotation; - target.visible = this.visible; - target.touchable = this.touchable; - target.grayed = this.grayed; - target.setXY(this.x, this.y); - target.setSize(this.width, this.height); - var index = this._parent.getChildIndex(this); - this._parent.addChildAt(target, index); - target.relations.copyFrom(this.relations); - this._parent.removeChild(this, true); - }; - GGraph.prototype.addBeforeMe = function (target) { - if (this._parent == null) - throw "parent not set"; - var index = this._parent.getChildIndex(this); - this._parent.addChildAt(target, index); - }; - GGraph.prototype.addAfterMe = function (target) { - if (this._parent == null) - throw "parent not set"; - var index = this._parent.getChildIndex(this); - index++; - this._parent.addChildAt(target, index); - }; - GGraph.prototype.setNativeObject = function (obj) { - var sprite = new egret.Sprite(); - this.setDisplayObject(sprite); - if (this._parent) - this._parent.childStateChanged(this); - this.handleXYChanged(); - sprite.alpha = this.alpha; - sprite.rotation = this.rotation; - sprite.visible = this.visible; - sprite.touchEnabled = this.touchable; - sprite.touchChildren = this.touchable; - sprite.addChild(obj); - }; - GGraph.prototype.createDisplayObject = function () { - var sprite = new egret.Sprite(); - sprite.touchEnabled = true; - this._graphics = sprite.graphics; - this.setDisplayObject(sprite); - }; - GGraph.prototype.getProp = function (index) { - if (index == fgui.ObjectPropID.Color) - return this.color; - else - return _super_1.prototype.getProp.call(this, index); - }; - GGraph.prototype.setProp = function (index, value) { - if (index == fgui.ObjectPropID.Color) - this.color = value; - else - _super_1.prototype.setProp.call(this, index, value); - }; - GGraph.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (this._type != 0) - this.updateGraph(); - }; - GGraph.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._type = buffer.readByte(); - if (this._type != 0) { - var i; - var cnt; - this._lineSize = buffer.readInt(); - var c = buffer.readColor(true); - this._lineColor = c & 0xFFFFFF; - this._lineAlpha = ((c >> 24) & 0xFF) / 0xFF; - c = buffer.readColor(true); - this._fillColor = c & 0xFFFFFF; - this._fillAlpha = ((c >> 24) & 0xFF) / 0xFF; - if (buffer.readBool()) { - this._cornerRadius = new Array(4); - for (i = 0; i < 4; i++) - this._cornerRadius[i] = buffer.readFloat(); - } - if (this._type == 3) { - cnt = buffer.readShort(); - this._polygonPoints = []; - this._polygonPoints.length = cnt; - for (i = 0; i < cnt; i++) - this._polygonPoints[i] = buffer.readFloat(); - } - else if (this._type == 4) { - this._sides = buffer.readShort(); - this._startAngle = buffer.readFloat(); - cnt = buffer.readShort(); - if (cnt > 0) { - this._distances = []; - for (i = 0; i < cnt; i++) - this._distances[i] = buffer.readFloat(); - } - } - this.updateGraph(); - } - }; - return GGraph; - }(fgui.GObject)); - fgui.GGraph = GGraph; -})(fgui || (fgui = {})); - -(function (fgui) { - var GGroup = (function (_super_1) { - __extends(GGroup, _super_1); - function GGroup() { - var _this = _super_1.call(this) || this; - _this._layout = 0; - _this._lineGap = 0; - _this._columnGap = 0; - _this._mainGridIndex = -1; - _this._mainGridMinSize = 50; - _this._mainChildIndex = -1; - _this._totalSize = 0; - _this._numChildren = 0; - _this._updating = 0; - return _this; - } - GGroup.prototype.dispose = function () { - this._boundsChanged = false; - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GGroup.prototype, "layout", { - get: function () { - return this._layout; - }, - set: function (value) { - if (this._layout != value) { - this._layout = value; - this.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "lineGap", { - get: function () { - return this._lineGap; - }, - set: function (value) { - if (this._lineGap != value) { - this._lineGap = value; - this.setBoundsChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "columnGap", { - get: function () { - return this._columnGap; - }, - set: function (value) { - if (this._columnGap != value) { - this._columnGap = value; - this.setBoundsChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "excludeInvisibles", { - get: function () { - return this._excludeInvisibles; - }, - set: function (value) { - if (this._excludeInvisibles != value) { - this._excludeInvisibles = value; - this.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "autoSizeDisabled", { - get: function () { - return this._autoSizeDisabled; - }, - set: function (value) { - this._autoSizeDisabled = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "mainGridMinSize", { - get: function () { - return this._mainGridMinSize; - }, - set: function (value) { - if (this._mainGridMinSize != value) { - this._mainGridMinSize = value; - this.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GGroup.prototype, "mainGridIndex", { - get: function () { - return this._mainGridIndex; - }, - set: function (value) { - if (this._mainGridIndex != value) { - this._mainGridIndex = value; - this.setBoundsChangedFlag(); - } - }, - enumerable: true, - configurable: true - }); - GGroup.prototype.setBoundsChangedFlag = function (positionChangedOnly) { - if (this._updating == 0 && this._parent) { - if (!positionChangedOnly) - this._percentReady = false; - if (!this._boundsChanged) { - this._boundsChanged = true; - if (this._layout != fgui.GroupLayoutType.None) - fgui.GTimers.inst.callLater(this.ensureBoundsCorrect, this); - } - } - }; - GGroup.prototype.ensureSizeCorrect = function () { - if (this._parent == null || !this._boundsChanged || this._layout == 0) - return; - this._boundsChanged = false; - if (this._autoSizeDisabled) - this.resizeChildren(0, 0); - else { - this.handleLayout(); - this.updateBounds(); - } - }; - GGroup.prototype.ensureBoundsCorrect = function () { - if (this._parent == null || !this._boundsChanged) - return; - this._boundsChanged = false; - if (this._layout == 0) - this.updateBounds(); - else { - if (this._autoSizeDisabled) - this.resizeChildren(0, 0); - else { - this.handleLayout(); - this.updateBounds(); - } - } - }; - GGroup.prototype.updateBounds = function () { - fgui.GTimers.inst.remove(this.ensureBoundsCorrect, this); - var cnt = this._parent.numChildren; - var i; - var child; - var ax = Number.POSITIVE_INFINITY, ay = Number.POSITIVE_INFINITY; - var ar = Number.NEGATIVE_INFINITY, ab = Number.NEGATIVE_INFINITY; - var tmp; - var empty = true; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this || this._excludeInvisibles && !child.internalVisible3) - continue; - tmp = child.xMin; - if (tmp < ax) - ax = tmp; - tmp = child.yMin; - if (tmp < ay) - ay = tmp; - tmp = child.xMin + child.width; - if (tmp > ar) - ar = tmp; - tmp = child.yMin + child.height; - if (tmp > ab) - ab = tmp; - empty = false; - } - var w = 0, h = 0; - if (!empty) { - this._updating |= 1; - this.setXY(ax, ay); - this._updating &= 2; - w = ar - ax; - h = ab - ay; - } - if ((this._updating & 2) == 0) { - this._updating |= 2; - this.setSize(w, h); - this._updating &= 1; - } - else { - this._updating &= 1; - this.resizeChildren(this._width - w, this._height - h); - } - }; - GGroup.prototype.handleLayout = function () { - this._updating |= 1; - var child; - var i; - var cnt; - if (this._layout == fgui.GroupLayoutType.Horizontal) { - var curX = this.x; - cnt = this._parent.numChildren; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (this._excludeInvisibles && !child.internalVisible3) - continue; - child.xMin = curX; - if (child.width != 0) - curX += child.width + this._columnGap; - } - } - else if (this._layout == fgui.GroupLayoutType.Vertical) { - var curY = this.y; - cnt = this._parent.numChildren; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (this._excludeInvisibles && !child.internalVisible3) - continue; - child.yMin = curY; - if (child.height != 0) - curY += child.height + this._lineGap; - } - } - this._updating &= 2; - }; - GGroup.prototype.moveChildren = function (dx, dy) { - if ((this._updating & 1) != 0 || this._parent == null) - return; - this._updating |= 1; - var cnt = this._parent.numChildren; - var i; - var child; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group == this) { - child.setXY(child.x + dx, child.y + dy); - } - } - this._updating &= 2; - }; - GGroup.prototype.resizeChildren = function (dw, dh) { - if (this._layout == fgui.GroupLayoutType.None || (this._updating & 2) != 0 || this._parent == null) - return; - this._updating |= 2; - if (this._boundsChanged) { - this._boundsChanged = false; - if (!this._autoSizeDisabled) { - this.updateBounds(); - return; - } - } - var cnt = this._parent.numChildren; - var i; - var child; - if (!this._percentReady) { - this._percentReady = true; - this._numChildren = 0; - this._totalSize = 0; - this._mainChildIndex = -1; - var j = 0; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (!this._excludeInvisibles || child.internalVisible3) { - if (j == this._mainGridIndex) - this._mainChildIndex = i; - this._numChildren++; - if (this._layout == 1) - this._totalSize += child.width; - else - this._totalSize += child.height; - } - j++; - } - if (this._mainChildIndex != -1) { - if (this._layout == 1) { - child = this._parent.getChildAt(this._mainChildIndex); - this._totalSize += this._mainGridMinSize - child.width; - child._sizePercentInGroup = this._mainGridMinSize / this._totalSize; - } - else { - child = this._parent.getChildAt(this._mainChildIndex); - this._totalSize += this._mainGridMinSize - child.height; - child._sizePercentInGroup = this._mainGridMinSize / this._totalSize; - } - } - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (i == this._mainChildIndex) - continue; - if (this._totalSize > 0) - child._sizePercentInGroup = (this._layout == 1 ? child.width : child.height) / this._totalSize; - else - child._sizePercentInGroup = 0; - } - } - var remainSize = 0; - var remainPercent = 1; - var priorHandled = false; - if (this._layout == 1) { - remainSize = this.width - (this._numChildren - 1) * this._columnGap; - if (this._mainChildIndex != -1 && remainSize >= this._totalSize) { - child = this._parent.getChildAt(this._mainChildIndex); - child.setSize(remainSize - (this._totalSize - this._mainGridMinSize), child._rawHeight + dh, true); - remainSize -= child.width; - remainPercent -= child._sizePercentInGroup; - priorHandled = true; - } - var curX = this.x; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (this._excludeInvisibles && !child.internalVisible3) { - child.setSize(child._rawWidth, child._rawHeight + dh, true); - continue; - } - if (!priorHandled || i != this._mainChildIndex) { - child.setSize(Math.round(child._sizePercentInGroup / remainPercent * remainSize), child._rawHeight + dh, true); - remainPercent -= child._sizePercentInGroup; - remainSize -= child.width; - } - child.xMin = curX; - if (child.width != 0) - curX += child.width + this._columnGap; - } - } - else { - remainSize = this.height - (this._numChildren - 1) * this._lineGap; - if (this._mainChildIndex != -1 && remainSize >= this._totalSize) { - child = this._parent.getChildAt(this._mainChildIndex); - child.setSize(child._rawWidth + dw, remainSize - (this._totalSize - this._mainGridMinSize), true); - remainSize -= child.height; - remainPercent -= child._sizePercentInGroup; - priorHandled = true; - } - var curY = this.y; - for (i = 0; i < cnt; i++) { - child = this._parent.getChildAt(i); - if (child.group != this) - continue; - if (this._excludeInvisibles && !child.internalVisible3) { - child.setSize(child._rawWidth + dw, child._rawHeight, true); - continue; - } - if (!priorHandled || i != this._mainChildIndex) { - child.setSize(child._rawWidth + dw, Math.round(child._sizePercentInGroup / remainPercent * remainSize), true); - remainPercent -= child._sizePercentInGroup; - remainSize -= child.height; - } - child.yMin = curY; - if (child.height != 0) - curY += child.height + this._lineGap; - } - } - this._updating &= 1; - }; - GGroup.prototype.handleAlphaChanged = function () { - if (this._underConstruct) - return; - var cnt = this._parent.numChildren; - for (var i = 0; i < cnt; i++) { - var child = this._parent.getChildAt(i); - if (child.group == this) - child.alpha = this.alpha; - } - }; - GGroup.prototype.handleVisibleChanged = function () { - if (!this._parent) - return; - var cnt = this._parent.numChildren; - for (var i = 0; i < cnt; i++) { - var child = this._parent.getChildAt(i); - if (child.group == this) - child.handleVisibleChanged(); - } - }; - GGroup.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._layout = buffer.readByte(); - this._lineGap = buffer.readInt(); - this._columnGap = buffer.readInt(); - if (buffer.version >= 2) { - this._excludeInvisibles = buffer.readBool(); - this._autoSizeDisabled = buffer.readBool(); - this._mainChildIndex = buffer.readInt(); - } - }; - GGroup.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!this.visible) - this.handleVisibleChanged(); - }; - return GGroup; - }(fgui.GObject)); - fgui.GGroup = GGroup; -})(fgui || (fgui = {})); - -(function (fgui) { - var GImage = (function (_super_1) { - __extends(GImage, _super_1); - function GImage() { - var _this = _super_1.call(this) || this; - _this._flip = fgui.FlipType.None; - return _this; - } - Object.defineProperty(GImage.prototype, "color", { - get: function () { - return this._content.color; - }, - set: function (value) { - if (this._content.color != value) { - this._content.color = value; - this.updateGear(4); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "flip", { - get: function () { - return this._flip; - }, - set: function (value) { - if (this._flip != value) { - this._flip = value; - var sx = 1, sy = 1; - if (this._flip == fgui.FlipType.Horizontal || this._flip == fgui.FlipType.Both) - sx = -1; - if (this._flip == fgui.FlipType.Vertical || this._flip == fgui.FlipType.Both) - sy = -1; - this._content.scaleX = sx; - this._content.scaleY = sy; - this.handleXYChanged(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "fillMethod", { - get: function () { - return this._content.fillMethod; - }, - set: function (value) { - this._content.fillMethod = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "fillOrigin", { - get: function () { - return this._content.fillOrigin; - }, - set: function (value) { - this._content.fillOrigin = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "fillClockwise", { - get: function () { - return this._content.fillClockwise; - }, - set: function (value) { - this._content.fillClockwise = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "fillAmount", { - get: function () { - return this._content.fillAmount; - }, - set: function (value) { - this._content.fillAmount = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GImage.prototype, "texture", { - get: function () { - return this._content.texture; - }, - set: function (value) { - if (value) { - this.sourceWidth = value.textureWidth; - this.sourceHeight = value.textureHeight; - } - else { - this.sourceWidth = 0; - this.sourceHeight = 0; - } - this.initWidth = this.sourceWidth; - this.initHeight = this.sourceHeight; - this._content.scale9Grid = null; - this._content.fillMode = egret.BitmapFillMode.SCALE; - this._content.texture = value; - }, - enumerable: true, - configurable: true - }); - GImage.prototype.createDisplayObject = function () { - this._content = new fgui.Image(); - this._content.touchEnabled = false; - this.setDisplayObject(this._content); - }; - GImage.prototype.constructFromResource = function () { - var contentItem = this.packageItem.getBranch(); - this.sourceWidth = contentItem.width; - this.sourceHeight = contentItem.height; - this.initWidth = this.sourceWidth; - this.initHeight = this.sourceHeight; - this.setSize(this.sourceWidth, this.sourceHeight); - contentItem = contentItem.getHighResolution(); - contentItem.load(); - this._content.scale9Grid = contentItem.scale9Grid; - this._content.smoothing = contentItem.smoothing; - if (contentItem.scaleByTile) - this._content.fillMode = egret.BitmapFillMode.REPEAT; - this.setSize(this.sourceWidth, this.sourceHeight); - this._content.texture = contentItem.asset; - }; - GImage.prototype.handleXYChanged = function () { - _super_1.prototype.handleXYChanged.call(this); - if (this._flip != fgui.FlipType.None) { - if (this._content.scaleX == -1) - this._content.x += this.width; - if (this._content.scaleY == -1) - this._content.y += this.height; - } - }; - GImage.prototype.getProp = function (index) { - if (index == fgui.ObjectPropID.Color) - return this.color; - else - return _super_1.prototype.getProp.call(this, index); - }; - GImage.prototype.setProp = function (index, value) { - if (index == fgui.ObjectPropID.Color) - this.color = value; - else - _super_1.prototype.setProp.call(this, index, value); - }; - GImage.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - if (buffer.readBool()) - this.color = buffer.readColor(); - this.flip = buffer.readByte(); - this._content.fillMethod = buffer.readByte(); - if (this._content.fillMethod != 0) { - this._content.fillOrigin = buffer.readByte(); - this._content.fillClockwise = buffer.readBool(); - this._content.fillAmount = buffer.readFloat(); - } - }; - return GImage; - }(fgui.GObject)); - fgui.GImage = GImage; -})(fgui || (fgui = {})); - -(function (fgui) { - var GLabel = (function (_super_1) { - __extends(GLabel, _super_1); - function GLabel() { - return _super_1.call(this) || this; - } - Object.defineProperty(GLabel.prototype, "icon", { - get: function () { - if (this._iconObject) - return this._iconObject.icon; - }, - set: function (value) { - if (this._iconObject) - this._iconObject.icon = value; - this.updateGear(7); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLabel.prototype, "title", { - get: function () { - if (this._titleObject) - return this._titleObject.text; - else - return null; - }, - set: function (value) { - if (this._titleObject) - this._titleObject.text = value; - this.updateGear(6); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLabel.prototype, "text", { - get: function () { - return this.title; - }, - set: function (value) { - this.title = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLabel.prototype, "titleColor", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.color; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.color = value; - this.updateGear(4); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLabel.prototype, "titleFontSize", { - get: function () { - var tf = this.getTextField(); - if (tf) - return tf.fontSize; - else - return 0; - }, - set: function (value) { - var tf = this.getTextField(); - if (tf) - tf.fontSize = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLabel.prototype, "editable", { - get: function () { - if (this._titleObject && (this._titleObject instanceof fgui.GTextInput)) - return this._titleObject.asTextInput.editable; - else - return false; - }, - set: function (val) { - if (this._titleObject) - this._titleObject.asTextInput.editable = val; - }, - enumerable: true, - configurable: true - }); - GLabel.prototype.getTextField = function () { - if (this._titleObject instanceof fgui.GTextField) - return this._titleObject; - else if ((this._titleObject instanceof GLabel) || (this._titleObject instanceof fgui.GButton)) - return this._titleObject.getTextField(); - else - return null; - }; - GLabel.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.titleColor; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - return tf.strokeColor; - else - return 0; - } - case fgui.ObjectPropID.FontSize: - return this.titleFontSize; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GLabel.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.titleColor = value; - break; - case fgui.ObjectPropID.OutlineColor: - { - var tf = this.getTextField(); - if (tf) - tf.strokeColor = value; - } - break; - case fgui.ObjectPropID.FontSize: - this.titleFontSize = value; - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GLabel.prototype.constructExtension = function (buffer) { - this._titleObject = this.getChild("title"); - this._iconObject = this.getChild("icon"); - }; - GLabel.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!buffer.seek(beginPos, 6)) - return; - if (buffer.readByte() != this.packageItem.objectType) - return; - var str; - str = buffer.readS(); - if (str != null) - this.title = str; - str = buffer.readS(); - if (str != null) - this.icon = str; - if (buffer.readBool()) - this.titleColor = buffer.readColor(); - var iv = buffer.readInt(); - if (iv != 0) - this.titleFontSize = iv; - if (buffer.readBool()) { - var input = this.getTextField(); - if (input instanceof fgui.GTextInput) { - str = buffer.readS(); - if (str != null) - input.promptText = str; - str = buffer.readS(); - if (str != null) - input.restrict = str; - iv = buffer.readInt(); - if (iv != 0) - input.maxLength = iv; - iv = buffer.readInt(); - if (iv != 0) { - } - if (buffer.readBool()) - input.password = true; - } - else - buffer.skip(13); - } - }; - return GLabel; - }(fgui.GComponent)); - fgui.GLabel = GLabel; -})(fgui || (fgui = {})); - -(function (fgui) { - var GList = (function (_super_1) { - __extends(GList, _super_1); - function GList() { - var _this = _super_1.call(this) || this; - _this.scrollItemToViewOnClick = true; - _this.foldInvisibleItems = false; - _this._lineCount = 0; - _this._columnCount = 0; - _this._lineGap = 0; - _this._columnGap = 0; - _this._lastSelectedIndex = 0; - _this._numItems = 0; - _this._realNumItems = 0; - _this._firstIndex = 0; - _this._curLineItemCount = 0; - _this._curLineItemCount2 = 0; - _this._virtualListChanged = 0; - _this.itemInfoVer = 0; - _this._trackBounds = true; - _this._pool = new fgui.GObjectPool(); - _this._layout = fgui.ListLayoutType.SingleColumn; - _this._autoResizeItem = true; - _this._lastSelectedIndex = -1; - _this._selectionMode = fgui.ListSelectionMode.Single; - _this.opaque = true; - _this._align = fgui.AlignType.Left; - _this._verticalAlign = fgui.VertAlignType.Top; - _this._container = new egret.DisplayObjectContainer(); - _this._rootContainer.addChild(_this._container); - return _this; - } - GList.prototype.dispose = function () { - this._pool.clear(); - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GList.prototype, "layout", { - get: function () { - return this._layout; - }, - set: function (value) { - if (this._layout != value) { - this._layout = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "lineCount", { - get: function () { - return this._lineCount; - }, - set: function (value) { - if (this._lineCount != value) { - this._lineCount = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "columnCount", { - get: function () { - return this._columnCount; - }, - set: function (value) { - if (this._columnCount != value) { - this._columnCount = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "lineGap", { - get: function () { - return this._lineGap; - }, - set: function (value) { - if (this._lineGap != value) { - this._lineGap = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "columnGap", { - get: function () { - return this._columnGap; - }, - set: function (value) { - if (this._columnGap != value) { - this._columnGap = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "align", { - get: function () { - return this._align; - }, - set: function (value) { - if (this._align != value) { - this._align = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "verticalAlign", { - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign != value) { - this._verticalAlign = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "virtualItemSize", { - get: function () { - return this._itemSize; - }, - set: function (value) { - if (this._virtual) { - if (!this._itemSize) - this._itemSize = new egret.Point(); - this._itemSize.copyFrom(value); - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "defaultItem", { - get: function () { - return this._defaultItem; - }, - set: function (val) { - this._defaultItem = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "autoResizeItem", { - get: function () { - return this._autoResizeItem; - }, - set: function (value) { - if (this._autoResizeItem != value) { - this._autoResizeItem = value; - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "selectionMode", { - get: function () { - return this._selectionMode; - }, - set: function (value) { - this._selectionMode = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "selectionController", { - get: function () { - return this._selectionController; - }, - set: function (value) { - this._selectionController = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GList.prototype, "itemPool", { - get: function () { - return this._pool; - }, - enumerable: true, - configurable: true - }); - GList.prototype.getFromPool = function (url) { - if (!url) - url = this._defaultItem; - var obj = this._pool.getObject(url); - if (obj) - obj.visible = true; - return obj; - }; - GList.prototype.returnToPool = function (obj) { - obj.displayObject.cacheAsBitmap = false; - this._pool.returnObject(obj); - }; - GList.prototype.addChildAt = function (child, index) { - _super_1.prototype.addChildAt.call(this, child, index); - if (child instanceof fgui.GButton) { - child.selected = false; - child.changeStateOnClick = false; - } - child.addEventListener(egret.TouchEvent.TOUCH_TAP, this.__clickItem, this); - return child; - }; - GList.prototype.addItem = function (url) { - if (!url) - url = this._defaultItem; - return this.addChild(fgui.UIPackage.createObjectFromURL(url)); - }; - GList.prototype.addItemFromPool = function (url) { - return this.addChild(this.getFromPool(url)); - }; - GList.prototype.removeChildAt = function (index, dispose) { - var child = _super_1.prototype.removeChildAt.call(this, index, dispose); - child.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.__clickItem, this); - return child; - }; - GList.prototype.removeChildToPoolAt = function (index) { - var child = _super_1.prototype.removeChildAt.call(this, index); - this.returnToPool(child); - }; - GList.prototype.removeChildToPool = function (child) { - _super_1.prototype.removeChild.call(this, child); - this.returnToPool(child); - }; - GList.prototype.removeChildrenToPool = function (beginIndex, endIndex) { - if (beginIndex == undefined) - beginIndex = 0; - if (endIndex == undefined) - endIndex = -1; - if (endIndex < 0 || endIndex >= this._children.length) - endIndex = this._children.length - 1; - for (var i = beginIndex; i <= endIndex; ++i) - this.removeChildToPoolAt(beginIndex); - }; - Object.defineProperty(GList.prototype, "selectedIndex", { - get: function () { - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if ((ii.obj instanceof fgui.GButton) && ii.obj.selected - || ii.obj == null && ii.selected) { - if (this._loop) - return i % this._numItems; - else - return i; - } - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if ((obj instanceof fgui.GButton) && obj.selected) - return i; - } - } - return -1; - }, - set: function (value) { - if (value >= 0 && value < this.numItems) { - if (this._selectionMode != fgui.ListSelectionMode.Single) - this.clearSelection(); - this.addSelection(value); - } - else - this.clearSelection(); - }, - enumerable: true, - configurable: true - }); - GList.prototype.getSelection = function (result) { - if (!result) - result = new Array(); - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if ((ii.obj instanceof fgui.GButton) && ii.obj.selected - || ii.obj == null && ii.selected) { - var j = i; - if (this._loop) { - j = i % this._numItems; - if (result.indexOf(j) != -1) - continue; - } - result.push(j); - } - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if ((obj instanceof fgui.GButton) && obj.selected) - result.push(i); - } - } - return result; - }; - GList.prototype.addSelection = function (index, scrollItToView) { - if (this._selectionMode == fgui.ListSelectionMode.None) - return; - this.checkVirtualList(); - if (this._selectionMode == fgui.ListSelectionMode.Single) - this.clearSelection(); - if (scrollItToView) - this.scrollToView(index); - this._lastSelectedIndex = index; - var obj; - if (this._virtual) { - var ii = this._virtualItems[index]; - if (ii.obj) - obj = ii.obj; - ii.selected = true; - } - else - obj = this.getChildAt(index); - if ((obj instanceof fgui.GButton) && !obj.selected) { - obj.selected = true; - this.updateSelectionController(index); - } - }; - GList.prototype.removeSelection = function (index) { - if (this._selectionMode == fgui.ListSelectionMode.None) - return; - var obj; - if (this._virtual) { - var ii = this._virtualItems[index]; - if (ii.obj) - obj = ii.obj; - ii.selected = false; - } - else - obj = this.getChildAt(index); - if (obj instanceof fgui.GButton) - obj.selected = false; - }; - GList.prototype.clearSelection = function () { - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if (ii.obj instanceof fgui.GButton) - ii.obj.selected = false; - ii.selected = false; - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if (obj instanceof fgui.GButton) - obj.selected = false; - } - } - }; - GList.prototype.clearSelectionExcept = function (g) { - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if (ii.obj != g) { - if ((ii.obj instanceof fgui.GButton)) - ii.obj.selected = false; - ii.selected = false; - } - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if ((obj instanceof fgui.GButton) && obj != g) - obj.selected = false; - } - } - }; - GList.prototype.selectAll = function () { - this.checkVirtualList(); - var last = -1; - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if ((ii.obj instanceof fgui.GButton) && !ii.obj.selected) { - ii.obj.selected = true; - last = i; - } - ii.selected = true; - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if ((obj instanceof fgui.GButton) && !obj.selected) { - obj.selected = true; - last = i; - } - } - } - if (last != -1) - this.updateSelectionController(last); - }; - GList.prototype.selectNone = function () { - this.clearSelection(); - }; - GList.prototype.selectReverse = function () { - this.checkVirtualList(); - var last = -1; - var i; - if (this._virtual) { - for (i = 0; i < this._realNumItems; i++) { - var ii = this._virtualItems[i]; - if (ii.obj instanceof fgui.GButton) { - ii.obj.selected = !ii.obj.selected; - if (ii.obj.selected) - last = i; - } - ii.selected = !ii.selected; - } - } - else { - var cnt = this._children.length; - for (i = 0; i < cnt; i++) { - var obj = this._children[i]; - if (obj instanceof fgui.GButton) { - obj.selected = !obj.selected; - if (obj.selected) - last = i; - } - } - } - if (last != -1) - this.updateSelectionController(last); - }; - GList.prototype.handleArrowKey = function (dir) { - var index = this.selectedIndex; - if (index == -1) - return; - switch (dir) { - case 1: - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowVertical) { - index--; - if (index >= 0) { - this.clearSelection(); - this.addSelection(index, true); - } - } - else if (this._layout == fgui.ListLayoutType.FlowHorizontal || this._layout == fgui.ListLayoutType.Pagination) { - var current = this._children[index]; - var k = 0; - for (var i = index - 1; i >= 0; i--) { - var obj = this._children[i]; - if (obj.y != current.y) { - current = obj; - break; - } - k++; - } - for (; i >= 0; i--) { - obj = this._children[i]; - if (obj.y != current.y) { - this.clearSelection(); - this.addSelection(i + k + 1, true); - break; - } - } - } - break; - case 3: - if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowHorizontal || this._layout == fgui.ListLayoutType.Pagination) { - index++; - if (index < this._children.length) { - this.clearSelection(); - this.addSelection(index, true); - } - } - else if (this._layout == fgui.ListLayoutType.FlowVertical) { - current = this._children[index]; - k = 0; - var cnt = this._children.length; - for (i = index + 1; i < cnt; i++) { - obj = this._children[i]; - if (obj.x != current.x) { - current = obj; - break; - } - k++; - } - for (; i < cnt; i++) { - obj = this._children[i]; - if (obj.x != current.x) { - this.clearSelection(); - this.addSelection(i - k - 1, true); - break; - } - } - } - break; - case 5: - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowVertical) { - index++; - if (index < this._children.length) { - this.clearSelection(); - this.addSelection(index, true); - } - } - else if (this._layout == fgui.ListLayoutType.FlowHorizontal || this._layout == fgui.ListLayoutType.Pagination) { - current = this._children[index]; - k = 0; - cnt = this._children.length; - for (i = index + 1; i < cnt; i++) { - obj = this._children[i]; - if (obj.y != current.y) { - current = obj; - break; - } - k++; - } - for (; i < cnt; i++) { - obj = this._children[i]; - if (obj.y != current.y) { - this.clearSelection(); - this.addSelection(i - k - 1, true); - break; - } - } - } - break; - case 7: - if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowHorizontal || this._layout == fgui.ListLayoutType.Pagination) { - index--; - if (index >= 0) { - this.clearSelection(); - this.addSelection(index, true); - } - } - else if (this._layout == fgui.ListLayoutType.FlowVertical) { - current = this._children[index]; - k = 0; - for (i = index - 1; i >= 0; i--) { - obj = this._children[i]; - if (obj.x != current.x) { - current = obj; - break; - } - k++; - } - for (; i >= 0; i--) { - obj = this._children[i]; - if (obj.x != current.x) { - this.clearSelection(); - this.addSelection(i + k + 1, true); - break; - } - } - } - break; - } - }; - GList.prototype.__clickItem = function (evt) { - if (this._scrollPane && this._scrollPane.isDragged) - return; - var item = (evt.currentTarget); - this.setSelectionOnEvent(item); - if (this._scrollPane && this.scrollItemToViewOnClick) - this._scrollPane.scrollToView(item, true); - var ie = new fgui.ItemEvent(fgui.ItemEvent.CLICK, item); - ie.stageX = evt.stageX; - ie.stageY = evt.stageY; - this.dispatchItemEvent(ie); - }; - GList.prototype.dispatchItemEvent = function (evt) { - this.dispatchEvent(evt); - }; - GList.prototype.setSelectionOnEvent = function (item) { - if (!(item instanceof fgui.GButton) || this._selectionMode == fgui.ListSelectionMode.None) - return; - var dontChangeLastIndex = false; - var index = this.childIndexToItemIndex(this.getChildIndex(item)); - if (this._selectionMode == fgui.ListSelectionMode.Single) { - if (!item.selected) { - this.clearSelectionExcept(item); - item.selected = true; - } - } - else { - if (fgui.GRoot.shiftKeyDown) { - if (!item.selected) { - if (this._lastSelectedIndex != -1) { - var min = Math.min(this._lastSelectedIndex, index); - var max = Math.max(this._lastSelectedIndex, index); - max = Math.min(max, this.numItems - 1); - var i; - if (this._virtual) { - for (i = min; i <= max; i++) { - var ii = this._virtualItems[i]; - if (ii.obj instanceof fgui.GButton) - ii.obj.selected = true; - ii.selected = true; - } - } - else { - for (i = min; i <= max; i++) { - var obj = this.getChildAt(i); - if (obj instanceof fgui.GButton) - obj.selected = true; - } - } - dontChangeLastIndex = true; - } - else { - item.selected = true; - } - } - } - else if (fgui.GRoot.ctrlKeyDown || this._selectionMode == fgui.ListSelectionMode.Multiple_SingleClick) { - item.selected = !item.selected; - } - else { - if (!item.selected) { - this.clearSelectionExcept(item); - item.selected = true; - } - else - this.clearSelectionExcept(item); - } - } - if (!dontChangeLastIndex) - this._lastSelectedIndex = index; - if (item.selected) - this.updateSelectionController(index); - }; - GList.prototype.resizeToFit = function (itemCount, minSize) { - if (itemCount === void 0) { itemCount = Number.POSITIVE_INFINITY; } - if (minSize === void 0) { minSize = 0; } - this.ensureBoundsCorrect(); - var curCount = this.numItems; - if (itemCount > curCount) - itemCount = curCount; - if (this._virtual) { - var lineCount = Math.ceil(itemCount / this._curLineItemCount); - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) - this.viewHeight = lineCount * this._itemSize.y + Math.max(0, lineCount - 1) * this._lineGap; - else - this.viewWidth = lineCount * this._itemSize.x + Math.max(0, lineCount - 1) * this._columnGap; - } - else if (itemCount == 0) { - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) - this.viewHeight = minSize; - else - this.viewWidth = minSize; - } - else { - var i = itemCount - 1; - var obj; - while (i >= 0) { - obj = this.getChildAt(i); - if (!this.foldInvisibleItems || obj.visible) - break; - i--; - } - if (i < 0) { - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) - this.viewHeight = minSize; - else - this.viewWidth = minSize; - } - else { - var size = 0; - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - size = obj.y + obj.height; - if (size < minSize) - size = minSize; - this.viewHeight = size; - } - else { - size = obj.x + obj.width; - if (size < minSize) - size = minSize; - this.viewWidth = size; - } - } - } - }; - GList.prototype.getMaxItemWidth = function () { - var cnt = this._children.length; - var max = 0; - for (var i = 0; i < cnt; i++) { - var child = this.getChildAt(i); - if (child.width > max) - max = child.width; - } - return max; - }; - GList.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - this.setBoundsChangedFlag(); - if (this._virtual) - this.setVirtualListChangedFlag(true); - }; - GList.prototype.handleControllerChanged = function (c) { - _super_1.prototype.handleControllerChanged.call(this, c); - if (this._selectionController == c) - this.selectedIndex = c.selectedIndex; - }; - GList.prototype.updateSelectionController = function (index) { - if (this._selectionController && !this._selectionController.changing - && index < this._selectionController.pageCount) { - var c = this._selectionController; - this._selectionController = null; - c.selectedIndex = index; - this._selectionController = c; - } - }; - GList.prototype.getSnappingPosition = function (xValue, yValue, result) { - if (this._virtual) { - if (!result) - result = new egret.Point(); - var saved; - var index; - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - saved = yValue; - s_n = yValue; - index = this.getIndexOnPos1(false); - yValue = s_n; - if (index < this._virtualItems.length && saved - yValue > this._virtualItems[index].height / 2 && index < this._realNumItems) - yValue += this._virtualItems[index].height + this._lineGap; - } - else if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowVertical) { - saved = xValue; - s_n = xValue; - index = this.getIndexOnPos2(false); - xValue = s_n; - if (index < this._virtualItems.length && saved - xValue > this._virtualItems[index].width / 2 && index < this._realNumItems) - xValue += this._virtualItems[index].width + this._columnGap; - } - else { - saved = xValue; - s_n = xValue; - index = this.getIndexOnPos3(false); - xValue = s_n; - if (index < this._virtualItems.length && saved - xValue > this._virtualItems[index].width / 2 && index < this._realNumItems) - xValue += this._virtualItems[index].width + this._columnGap; - } - result.x = xValue; - result.y = yValue; - return result; - } - else { - return _super_1.prototype.getSnappingPosition.call(this, xValue, yValue, result); - } - }; - GList.prototype.scrollToView = function (index, ani, setFirst) { - if (this._virtual) { - if (this._numItems == 0) - return; - this.checkVirtualList(); - if (index >= this._virtualItems.length) - throw "Invalid child index: " + index + ">" + this._virtualItems.length; - if (this._loop) - index = Math.floor(this._firstIndex / this._numItems) * this._numItems + index; - var rect; - var ii = this._virtualItems[index]; - var pos = 0; - var i; - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - for (i = this._curLineItemCount - 1; i < index; i += this._curLineItemCount) - pos += this._virtualItems[i].height + this._lineGap; - rect = new egret.Rectangle(0, pos, this._itemSize.x, ii.height); - } - else if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowVertical) { - for (i = this._curLineItemCount - 1; i < index; i += this._curLineItemCount) - pos += this._virtualItems[i].width + this._columnGap; - rect = new egret.Rectangle(pos, 0, ii.width, this._itemSize.y); - } - else { - var page = index / (this._curLineItemCount * this._curLineItemCount2); - rect = new egret.Rectangle(page * this.viewWidth + (index % this._curLineItemCount) * (ii.width + this._columnGap), (index / this._curLineItemCount) % this._curLineItemCount2 * (ii.height + this._lineGap), ii.width, ii.height); - } - if (this._scrollPane) - this._scrollPane.scrollToView(rect, ani, setFirst); - } - else { - var obj = this.getChildAt(index); - if (obj) { - if (this._scrollPane) - this._scrollPane.scrollToView(obj, ani, setFirst); - else if (this.parent && this.parent.scrollPane) - this.parent.scrollPane.scrollToView(obj, ani, setFirst); - } - } - }; - GList.prototype.getFirstChildInView = function () { - return this.childIndexToItemIndex(_super_1.prototype.getFirstChildInView.call(this)); - }; - GList.prototype.childIndexToItemIndex = function (index) { - if (!this._virtual) - return index; - if (this._layout == fgui.ListLayoutType.Pagination) { - for (var i = this._firstIndex; i < this._realNumItems; i++) { - if (this._virtualItems[i].obj) { - index--; - if (index < 0) - return i; - } - } - return index; - } - else { - index += this._firstIndex; - if (this._loop && this._numItems > 0) - index = index % this._numItems; - return index; - } - }; - GList.prototype.itemIndexToChildIndex = function (index) { - if (!this._virtual) - return index; - if (this._layout == fgui.ListLayoutType.Pagination) { - return this.getChildIndex(this._virtualItems[index].obj); - } - else { - if (this._loop && this._numItems > 0) { - var j = this._firstIndex % this._numItems; - if (index >= j) - index = index - j; - else - index = this._numItems - j + index; - } - else - index -= this._firstIndex; - return index; - } - }; - GList.prototype.setVirtual = function () { - this._setVirtual(false); - }; - GList.prototype.setVirtualAndLoop = function () { - this._setVirtual(true); - }; - GList.prototype._setVirtual = function (loop) { - if (!this._virtual) { - if (this._scrollPane == null) - throw "Virtual list must be scrollable!"; - if (loop) { - if (this._layout == fgui.ListLayoutType.FlowHorizontal || this._layout == fgui.ListLayoutType.FlowVertical) - throw "Loop list is not supported for FlowHorizontal or FlowVertical layout!"; - this._scrollPane.bouncebackEffect = false; - } - this._virtual = true; - this._loop = loop; - this._virtualItems = new Array(); - this.removeChildrenToPool(); - if (this._itemSize == null) { - this._itemSize = new egret.Point(); - var obj = this.getFromPool(null); - if (obj == null) { - throw "Virtual List must have a default list item resource."; - } - else { - this._itemSize.x = obj.width; - this._itemSize.y = obj.height; - } - this.returnToPool(obj); - } - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - this._scrollPane.scrollStep = this._itemSize.y; - if (this._loop) - this._scrollPane._loop = 2; - } - else { - this._scrollPane.scrollStep = this._itemSize.x; - if (this._loop) - this._scrollPane._loop = 1; - } - this._scrollPane.addEventListener(fgui.ScrollPane.SCROLL, this.__scrolled, this); - this.setVirtualListChangedFlag(true); - } - }; - Object.defineProperty(GList.prototype, "numItems", { - get: function () { - if (this._virtual) - return this._numItems; - else - return this._children.length; - }, - set: function (value) { - if (this._virtual) { - if (this.itemRenderer == null) - throw "Set itemRenderer first!"; - this._numItems = value; - if (this._loop) - this._realNumItems = this._numItems * 6; - else - this._realNumItems = this._numItems; - var oldCount = this._virtualItems.length; - if (this._realNumItems > oldCount) { - for (i = oldCount; i < this._realNumItems; i++) { - var ii = { - width: this._itemSize.x, - height: this._itemSize.y, - updateFlag: 0 - }; - this._virtualItems.push(ii); - } - } - else { - for (i = this._realNumItems; i < oldCount; i++) - this._virtualItems[i].selected = false; - } - if (this._virtualListChanged != 0) - fgui.GTimers.inst.remove(this._refreshVirtualList, this); - this._refreshVirtualList(); - } - else { - var cnt = this._children.length; - if (value > cnt) { - for (var i = cnt; i < value; i++) { - if (this.itemProvider == null) - this.addItemFromPool(); - else - this.addItemFromPool(this.itemProvider.call(this.callbackThisObj, i)); - } - } - else { - this.removeChildrenToPool(value, cnt); - } - if (this.itemRenderer != null) { - for (i = 0; i < value; i++) - this.itemRenderer.call(this.callbackThisObj, i, this.getChildAt(i)); - } - } - }, - enumerable: true, - configurable: true - }); - GList.prototype.refreshVirtualList = function () { - this.setVirtualListChangedFlag(false); - }; - GList.prototype.checkVirtualList = function () { - if (this._virtualListChanged != 0) { - this._refreshVirtualList(); - fgui.GTimers.inst.remove(this._refreshVirtualList, this); - } - }; - GList.prototype.setVirtualListChangedFlag = function (layoutChanged) { - if (layoutChanged) - this._virtualListChanged = 2; - else if (this._virtualListChanged == 0) - this._virtualListChanged = 1; - fgui.GTimers.inst.callLater(this._refreshVirtualList, this); - }; - GList.prototype._refreshVirtualList = function () { - var layoutChanged = this._virtualListChanged == 2; - this._virtualListChanged = 0; - this._eventLocked = true; - if (layoutChanged) { - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.SingleRow) - this._curLineItemCount = 1; - else if (this._layout == fgui.ListLayoutType.FlowHorizontal) { - if (this._columnCount > 0) - this._curLineItemCount = this._columnCount; - else { - this._curLineItemCount = Math.floor((this._scrollPane.viewWidth + this._columnGap) / (this._itemSize.x + this._columnGap)); - if (this._curLineItemCount <= 0) - this._curLineItemCount = 1; - } - } - else if (this._layout == fgui.ListLayoutType.FlowVertical) { - if (this._lineCount > 0) - this._curLineItemCount = this._lineCount; - else { - this._curLineItemCount = Math.floor((this._scrollPane.viewHeight + this._lineGap) / (this._itemSize.y + this._lineGap)); - if (this._curLineItemCount <= 0) - this._curLineItemCount = 1; - } - } - else { - if (this._columnCount > 0) - this._curLineItemCount = this._columnCount; - else { - this._curLineItemCount = Math.floor((this._scrollPane.viewWidth + this._columnGap) / (this._itemSize.x + this._columnGap)); - if (this._curLineItemCount <= 0) - this._curLineItemCount = 1; - } - if (this._lineCount > 0) - this._curLineItemCount2 = this._lineCount; - else { - this._curLineItemCount2 = Math.floor((this._scrollPane.viewHeight + this._lineGap) / (this._itemSize.y + this._lineGap)); - if (this._curLineItemCount2 <= 0) - this._curLineItemCount2 = 1; - } - } - } - var ch = 0, cw = 0; - if (this._realNumItems > 0) { - var i; - var len = Math.ceil(this._realNumItems / this._curLineItemCount) * this._curLineItemCount; - var len2 = Math.min(this._curLineItemCount, this._realNumItems); - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - for (i = 0; i < len; i += this._curLineItemCount) - ch += this._virtualItems[i].height + this._lineGap; - if (ch > 0) - ch -= this._lineGap; - if (this._autoResizeItem) - cw = this._scrollPane.viewWidth; - else { - for (i = 0; i < len2; i++) - cw += this._virtualItems[i].width + this._columnGap; - if (cw > 0) - cw -= this._columnGap; - } - } - else if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowVertical) { - for (i = 0; i < len; i += this._curLineItemCount) - cw += this._virtualItems[i].width + this._columnGap; - if (cw > 0) - cw -= this._columnGap; - if (this._autoResizeItem) - ch = this._scrollPane.viewHeight; - else { - for (i = 0; i < len2; i++) - ch += this._virtualItems[i].height + this._lineGap; - if (ch > 0) - ch -= this._lineGap; - } - } - else { - var pageCount = Math.ceil(len / (this._curLineItemCount * this._curLineItemCount2)); - cw = pageCount * this.viewWidth; - ch = this.viewHeight; - } - } - this.handleAlign(cw, ch); - this._scrollPane.setContentSize(cw, ch); - this._eventLocked = false; - this.handleScroll(true); - }; - GList.prototype.__scrolled = function (evt) { - this.handleScroll(false); - }; - GList.prototype.getIndexOnPos1 = function (forceUpdate) { - if (this._realNumItems < this._curLineItemCount) { - s_n = 0; - return 0; - } - var i; - var pos2; - var pos3; - if (this.numChildren > 0 && !forceUpdate) { - pos2 = this.getChildAt(0).y; - if (pos2 > s_n) { - for (i = this._firstIndex - this._curLineItemCount; i >= 0; i -= this._curLineItemCount) { - pos2 -= (this._virtualItems[i].height + this._lineGap); - if (pos2 <= s_n) { - s_n = pos2; - return i; - } - } - s_n = 0; - return 0; - } - else { - for (i = this._firstIndex; i < this._realNumItems; i += this._curLineItemCount) { - pos3 = pos2 + this._virtualItems[i].height + this._lineGap; - if (pos3 > s_n) { - s_n = pos2; - return i; - } - pos2 = pos3; - } - s_n = pos2; - return this._realNumItems - this._curLineItemCount; - } - } - else { - pos2 = 0; - for (i = 0; i < this._realNumItems; i += this._curLineItemCount) { - pos3 = pos2 + this._virtualItems[i].height + this._lineGap; - if (pos3 > s_n) { - s_n = pos2; - return i; - } - pos2 = pos3; - } - s_n = pos2; - return this._realNumItems - this._curLineItemCount; - } - }; - GList.prototype.getIndexOnPos2 = function (forceUpdate) { - if (this._realNumItems < this._curLineItemCount) { - s_n = 0; - return 0; - } - var i; - var pos2; - var pos3; - if (this.numChildren > 0 && !forceUpdate) { - pos2 = this.getChildAt(0).x; - if (pos2 > s_n) { - for (i = this._firstIndex - this._curLineItemCount; i >= 0; i -= this._curLineItemCount) { - pos2 -= (this._virtualItems[i].width + this._columnGap); - if (pos2 <= s_n) { - s_n = pos2; - return i; - } - } - s_n = 0; - return 0; - } - else { - for (i = this._firstIndex; i < this._realNumItems; i += this._curLineItemCount) { - pos3 = pos2 + this._virtualItems[i].width + this._columnGap; - if (pos3 > s_n) { - s_n = pos2; - return i; - } - pos2 = pos3; - } - s_n = pos2; - return this._realNumItems - this._curLineItemCount; - } - } - else { - pos2 = 0; - for (i = 0; i < this._realNumItems; i += this._curLineItemCount) { - pos3 = pos2 + this._virtualItems[i].width + this._columnGap; - if (pos3 > s_n) { - s_n = pos2; - return i; - } - pos2 = pos3; - } - s_n = pos2; - return this._realNumItems - this._curLineItemCount; - } - }; - GList.prototype.getIndexOnPos3 = function (forceUpdate) { - if (this._realNumItems < this._curLineItemCount) { - s_n = 0; - return 0; - } - var viewWidth = this.viewWidth; - var page = Math.floor(s_n / viewWidth); - var startIndex = page * (this._curLineItemCount * this._curLineItemCount2); - var pos2 = page * viewWidth; - var i; - var pos3; - for (i = 0; i < this._curLineItemCount; i++) { - pos3 = pos2 + this._virtualItems[startIndex + i].width + this._columnGap; - if (pos3 > s_n) { - s_n = pos2; - return startIndex + i; - } - pos2 = pos3; - } - s_n = pos2; - return startIndex + this._curLineItemCount - 1; - }; - GList.prototype.handleScroll = function (forceUpdate) { - if (this._eventLocked) - return; - if (this._layout == fgui.ListLayoutType.SingleColumn || this._layout == fgui.ListLayoutType.FlowHorizontal) { - var enterCounter = 0; - while (this.handleScroll1(forceUpdate)) { - enterCounter++; - forceUpdate = false; - if (enterCounter > 20) { - console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size."); - break; - } - } - this.handleArchOrder1(); - } - else if (this._layout == fgui.ListLayoutType.SingleRow || this._layout == fgui.ListLayoutType.FlowVertical) { - enterCounter = 0; - while (this.handleScroll2(forceUpdate)) { - enterCounter++; - forceUpdate = false; - if (enterCounter > 20) { - console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size."); - break; - } - } - this.handleArchOrder2(); - } - else { - this.handleScroll3(forceUpdate); - } - this._boundsChanged = false; - }; - GList.prototype.handleScroll1 = function (forceUpdate) { - var pos = this._scrollPane.scrollingPosY; - var max = pos + this._scrollPane.viewHeight; - var end = max == this._scrollPane.contentHeight; - s_n = pos; - var newFirstIndex = this.getIndexOnPos1(forceUpdate); - pos = s_n; - if (newFirstIndex == this._firstIndex && !forceUpdate) { - return false; - } - var oldFirstIndex = this._firstIndex; - this._firstIndex = newFirstIndex; - var curIndex = newFirstIndex; - var forward = oldFirstIndex > newFirstIndex; - var childCount = this.numChildren; - var lastIndex = oldFirstIndex + childCount - 1; - var reuseIndex = forward ? lastIndex : oldFirstIndex; - var curX = 0, curY = pos; - var needRender; - var deltaSize = 0; - var firstItemDeltaSize = 0; - var url = this.defaultItem; - var ii, ii2; - var i, j; - var partSize = (this._scrollPane.viewWidth - this._columnGap * (this._curLineItemCount - 1)) / this._curLineItemCount; - this.itemInfoVer++; - while (curIndex < this._realNumItems && (end || curY < max)) { - ii = this._virtualItems[curIndex]; - if (ii.obj == null || forceUpdate) { - if (this.itemProvider != null) { - url = this.itemProvider.call(this.callbackThisObj, curIndex % this._numItems); - if (url == null) - url = this._defaultItem; - url = fgui.UIPackage.normalizeURL(url); - } - if (ii.obj && ii.obj.resourceURL != url) { - if (ii.obj instanceof fgui.GButton) - ii.selected = ii.obj.selected; - this.removeChildToPool(ii.obj); - ii.obj = null; - } - } - if (ii.obj == null) { - if (forward) { - for (j = reuseIndex; j >= oldFirstIndex; j--) { - ii2 = this._virtualItems[j]; - if (ii2.obj && ii2.updateFlag != this.itemInfoVer && ii2.obj.resourceURL == url) { - if (ii2.obj instanceof fgui.GButton) - ii2.selected = ii2.obj.selected; - ii.obj = ii2.obj; - ii2.obj = null; - if (j == reuseIndex) - reuseIndex--; - break; - } - } - } - else { - for (j = reuseIndex; j <= lastIndex; j++) { - ii2 = this._virtualItems[j]; - if (ii2.obj && ii2.updateFlag != this.itemInfoVer && ii2.obj.resourceURL == url) { - if (ii2.obj instanceof fgui.GButton) - ii2.selected = ii2.obj.selected; - ii.obj = ii2.obj; - ii2.obj = null; - if (j == reuseIndex) - reuseIndex++; - break; - } - } - } - if (ii.obj) { - this.setChildIndex(ii.obj, forward ? curIndex - newFirstIndex : this.numChildren); - } - else { - ii.obj = this._pool.getObject(url); - if (forward) - this.addChildAt(ii.obj, curIndex - newFirstIndex); - else - this.addChild(ii.obj); - } - if (ii.obj instanceof fgui.GButton) - ii.obj.selected = ii.selected; - needRender = true; - } - else - needRender = forceUpdate; - if (needRender) { - if (this._autoResizeItem && (this._layout == fgui.ListLayoutType.SingleColumn || this._columnCount > 0)) - ii.obj.setSize(partSize, ii.obj.height, true); - this.itemRenderer.call(this.callbackThisObj, curIndex % this._numItems, ii.obj); - if (curIndex % this._curLineItemCount == 0) { - deltaSize += Math.ceil(ii.obj.height) - ii.height; - if (curIndex == newFirstIndex && oldFirstIndex > newFirstIndex) { - firstItemDeltaSize = Math.ceil(ii.obj.height) - ii.height; - } - } - ii.width = Math.ceil(ii.obj.width); - ii.height = Math.ceil(ii.obj.height); - } - ii.updateFlag = this.itemInfoVer; - ii.obj.setXY(curX, curY); - if (curIndex == newFirstIndex) - max += ii.height; - curX += ii.width + this._columnGap; - if (curIndex % this._curLineItemCount == this._curLineItemCount - 1) { - curX = 0; - curY += ii.height + this._lineGap; - } - curIndex++; - } - for (i = 0; i < childCount; i++) { - ii = this._virtualItems[oldFirstIndex + i]; - if (ii.updateFlag != this.itemInfoVer && ii.obj) { - if (ii.obj instanceof fgui.GButton) - ii.selected = ii.obj.selected; - this.removeChildToPool(ii.obj); - ii.obj = null; - } - } - childCount = this._children.length; - for (i = 0; i < childCount; i++) { - var obj = this._virtualItems[newFirstIndex + i].obj; - if (this._children[i] != obj) - this.setChildIndex(obj, i); - } - if (deltaSize != 0 || firstItemDeltaSize != 0) - this._scrollPane.changeContentSizeOnScrolling(0, deltaSize, 0, firstItemDeltaSize); - if (curIndex > 0 && this.numChildren > 0 && this._container.y <= 0 && this.getChildAt(0).y > -this._container.y) - return true; - else - return false; - }; - GList.prototype.handleScroll2 = function (forceUpdate) { - var pos = this._scrollPane.scrollingPosX; - var max = pos + this._scrollPane.viewWidth; - var end = pos == this._scrollPane.contentWidth; - s_n = pos; - var newFirstIndex = this.getIndexOnPos2(forceUpdate); - pos = s_n; - if (newFirstIndex == this._firstIndex && !forceUpdate) { - return false; - } - var oldFirstIndex = this._firstIndex; - this._firstIndex = newFirstIndex; - var curIndex = newFirstIndex; - var forward = oldFirstIndex > newFirstIndex; - var childCount = this.numChildren; - var lastIndex = oldFirstIndex + childCount - 1; - var reuseIndex = forward ? lastIndex : oldFirstIndex; - var curX = pos, curY = 0; - var needRender; - var deltaSize = 0; - var firstItemDeltaSize = 0; - var url = this.defaultItem; - var ii, ii2; - var i, j; - var partSize = (this._scrollPane.viewHeight - this._lineGap * (this._curLineItemCount - 1)) / this._curLineItemCount; - this.itemInfoVer++; - while (curIndex < this._realNumItems && (end || curX < max)) { - ii = this._virtualItems[curIndex]; - if (ii.obj == null || forceUpdate) { - if (this.itemProvider != null) { - url = this.itemProvider.call(this.callbackThisObj, curIndex % this._numItems); - if (url == null) - url = this._defaultItem; - url = fgui.UIPackage.normalizeURL(url); - } - if (ii.obj && ii.obj.resourceURL != url) { - if (ii.obj instanceof fgui.GButton) - ii.selected = ii.obj.selected; - this.removeChildToPool(ii.obj); - ii.obj = null; - } - } - if (ii.obj == null) { - if (forward) { - for (j = reuseIndex; j >= oldFirstIndex; j--) { - ii2 = this._virtualItems[j]; - if (ii2.obj && ii2.updateFlag != this.itemInfoVer && ii2.obj.resourceURL == url) { - if (ii2.obj instanceof fgui.GButton) - ii2.selected = ii2.obj.selected; - ii.obj = ii2.obj; - ii2.obj = null; - if (j == reuseIndex) - reuseIndex--; - break; - } - } - } - else { - for (j = reuseIndex; j <= lastIndex; j++) { - ii2 = this._virtualItems[j]; - if (ii2.obj && ii2.updateFlag != this.itemInfoVer && ii2.obj.resourceURL == url) { - if (ii2.obj instanceof fgui.GButton) - ii2.selected = ii2.obj.selected; - ii.obj = ii2.obj; - ii2.obj = null; - if (j == reuseIndex) - reuseIndex++; - break; - } - } - } - if (ii.obj) { - this.setChildIndex(ii.obj, forward ? curIndex - newFirstIndex : this.numChildren); - } - else { - ii.obj = this._pool.getObject(url); - if (forward) - this.addChildAt(ii.obj, curIndex - newFirstIndex); - else - this.addChild(ii.obj); - } - if (ii.obj instanceof fgui.GButton) - ii.obj.selected = ii.selected; - needRender = true; - } - else - needRender = forceUpdate; - if (needRender) { - if (this._autoResizeItem && (this._layout == fgui.ListLayoutType.SingleRow || this._lineCount > 0)) - ii.obj.setSize(ii.obj.width, partSize, true); - this.itemRenderer.call(this.callbackThisObj, curIndex % this._numItems, ii.obj); - if (curIndex % this._curLineItemCount == 0) { - deltaSize += Math.ceil(ii.obj.width) - ii.width; - if (curIndex == newFirstIndex && oldFirstIndex > newFirstIndex) { - firstItemDeltaSize = Math.ceil(ii.obj.width) - ii.width; - } - } - ii.width = Math.ceil(ii.obj.width); - ii.height = Math.ceil(ii.obj.height); - } - ii.updateFlag = this.itemInfoVer; - ii.obj.setXY(curX, curY); - if (curIndex == newFirstIndex) - max += ii.width; - curY += ii.height + this._lineGap; - if (curIndex % this._curLineItemCount == this._curLineItemCount - 1) { - curY = 0; - curX += ii.width + this._columnGap; - } - curIndex++; - } - for (i = 0; i < childCount; i++) { - ii = this._virtualItems[oldFirstIndex + i]; - if (ii.updateFlag != this.itemInfoVer && ii.obj) { - if (ii.obj instanceof fgui.GButton) - ii.selected = ii.obj.selected; - this.removeChildToPool(ii.obj); - ii.obj = null; - } - } - childCount = this._children.length; - for (i = 0; i < childCount; i++) { - var obj = this._virtualItems[newFirstIndex + i].obj; - if (this._children[i] != obj) - this.setChildIndex(obj, i); - } - if (deltaSize != 0 || firstItemDeltaSize != 0) - this._scrollPane.changeContentSizeOnScrolling(deltaSize, 0, firstItemDeltaSize, 0); - if (curIndex > 0 && this.numChildren > 0 && this._container.x <= 0 && this.getChildAt(0).x > -this._container.x) - return true; - else - return false; - }; - GList.prototype.handleScroll3 = function (forceUpdate) { - var pos = this._scrollPane.scrollingPosX; - s_n = pos; - var newFirstIndex = this.getIndexOnPos3(forceUpdate); - pos = s_n; - if (newFirstIndex == this._firstIndex && !forceUpdate) - return; - var oldFirstIndex = this._firstIndex; - this._firstIndex = newFirstIndex; - var reuseIndex = oldFirstIndex; - var virtualItemCount = this._virtualItems.length; - var pageSize = this._curLineItemCount * this._curLineItemCount2; - var startCol = newFirstIndex % this._curLineItemCount; - var viewWidth = this.viewWidth; - var page = Math.floor(newFirstIndex / pageSize); - var startIndex = page * pageSize; - var lastIndex = startIndex + pageSize * 2; - var needRender; - var i; - var ii, ii2; - var col; - var url = this._defaultItem; - var partWidth = (this._scrollPane.viewWidth - this._columnGap * (this._curLineItemCount - 1)) / this._curLineItemCount; - var partHeight = (this._scrollPane.viewHeight - this._lineGap * (this._curLineItemCount2 - 1)) / this._curLineItemCount2; - this.itemInfoVer++; - for (i = startIndex; i < lastIndex; i++) { - if (i >= this._realNumItems) - continue; - col = i % this._curLineItemCount; - if (i - startIndex < pageSize) { - if (col < startCol) - continue; - } - else { - if (col > startCol) - continue; - } - ii = this._virtualItems[i]; - ii.updateFlag = this.itemInfoVer; - } - var lastObj; - var insertIndex = 0; - for (i = startIndex; i < lastIndex; i++) { - if (i >= this._realNumItems) - continue; - ii = this._virtualItems[i]; - if (ii.updateFlag != this.itemInfoVer) - continue; - if (ii.obj == null) { - while (reuseIndex < virtualItemCount) { - ii2 = this._virtualItems[reuseIndex]; - if (ii2.obj && ii2.updateFlag != this.itemInfoVer) { - if (ii2.obj instanceof fgui.GButton) - ii2.selected = ii2.obj.selected; - ii.obj = ii2.obj; - ii2.obj = null; - break; - } - reuseIndex++; - } - if (insertIndex == -1) - insertIndex = this.getChildIndex(lastObj) + 1; - if (ii.obj == null) { - if (this.itemProvider != null) { - url = this.itemProvider.call(this.callbackThisObj, i % this._numItems); - if (url == null) - url = this._defaultItem; - url = fgui.UIPackage.normalizeURL(url); - } - ii.obj = this._pool.getObject(url); - this.addChildAt(ii.obj, insertIndex); - } - else { - insertIndex = this.setChildIndexBefore(ii.obj, insertIndex); - } - insertIndex++; - if (ii.obj instanceof fgui.GButton) - ii.obj.selected = ii.selected; - needRender = true; - } - else { - needRender = forceUpdate; - insertIndex = -1; - lastObj = ii.obj; - } - if (needRender) { - if (this._autoResizeItem) { - if (this._curLineItemCount == this._columnCount && this._curLineItemCount2 == this._lineCount) - ii.obj.setSize(partWidth, partHeight, true); - else if (this._curLineItemCount == this._columnCount) - ii.obj.setSize(partWidth, ii.obj.height, true); - else if (this._curLineItemCount2 == this._lineCount) - ii.obj.setSize(ii.obj.width, partHeight, true); - } - this.itemRenderer.call(this.callbackThisObj, i % this._numItems, ii.obj); - ii.width = Math.ceil(ii.obj.width); - ii.height = Math.ceil(ii.obj.height); - } - } - var borderX = (startIndex / pageSize) * viewWidth; - var xx = borderX; - var yy = 0; - var lineHeight = 0; - for (i = startIndex; i < lastIndex; i++) { - if (i >= this._realNumItems) - continue; - ii = this._virtualItems[i]; - if (ii.updateFlag == this.itemInfoVer) - ii.obj.setXY(xx, yy); - if (ii.height > lineHeight) - lineHeight = ii.height; - if (i % this._curLineItemCount == this._curLineItemCount - 1) { - xx = borderX; - yy += lineHeight + this._lineGap; - lineHeight = 0; - if (i == startIndex + pageSize - 1) { - borderX += viewWidth; - xx = borderX; - yy = 0; - } - } - else - xx += ii.width + this._columnGap; - } - for (i = reuseIndex; i < virtualItemCount; i++) { - ii = this._virtualItems[i]; - if (ii.updateFlag != this.itemInfoVer && ii.obj) { - if (ii.obj instanceof fgui.GButton) - ii.selected = ii.obj.selected; - this.removeChildToPool(ii.obj); - ii.obj = null; - } - } - }; - GList.prototype.handleArchOrder1 = function () { - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Arch) { - var mid = this._scrollPane.posY + this.viewHeight / 2; - var minDist = Number.POSITIVE_INFINITY; - var dist = 0; - var apexIndex = 0; - var cnt = this.numChildren; - for (var i = 0; i < cnt; i++) { - var obj = this.getChildAt(i); - if (!this.foldInvisibleItems || obj.visible) { - dist = Math.abs(mid - obj.y - obj.height / 2); - if (dist < minDist) { - minDist = dist; - apexIndex = i; - } - } - } - this.apexIndex = apexIndex; - } - }; - GList.prototype.handleArchOrder2 = function () { - if (this._childrenRenderOrder == fgui.ChildrenRenderOrder.Arch) { - var mid = this._scrollPane.posX + this.viewWidth / 2; - var minDist = Number.POSITIVE_INFINITY; - var dist = 0; - var apexIndex = 0; - var cnt = this.numChildren; - for (var i = 0; i < cnt; i++) { - var obj = this.getChildAt(i); - if (!this.foldInvisibleItems || obj.visible) { - dist = Math.abs(mid - obj.x - obj.width / 2); - if (dist < minDist) { - minDist = dist; - apexIndex = i; - } - } - } - this.apexIndex = apexIndex; - } - }; - GList.prototype.handleAlign = function (contentWidth, contentHeight) { - var newOffsetX = 0; - var newOffsetY = 0; - if (contentHeight < this.viewHeight) { - if (this._verticalAlign == fgui.VertAlignType.Middle) - newOffsetY = Math.floor((this.viewHeight - contentHeight) / 2); - else if (this._verticalAlign == fgui.VertAlignType.Bottom) - newOffsetY = this.viewHeight - contentHeight; - } - if (contentWidth < this.viewWidth) { - if (this._align == fgui.AlignType.Center) - newOffsetX = Math.floor((this.viewWidth - contentWidth) / 2); - else if (this._align == fgui.AlignType.Right) - newOffsetX = this.viewWidth - contentWidth; - } - if (newOffsetX != this._alignOffset.x || newOffsetY != this._alignOffset.y) { - this._alignOffset.setTo(newOffsetX, newOffsetY); - if (this._scrollPane) - this._scrollPane.adjustMaskContainer(); - else { - this._container.x = this._margin.left + this._alignOffset.x; - this._container.y = this._margin.top + this._alignOffset.y; - } - } - }; - GList.prototype.updateBounds = function () { - if (this._virtual) - return; - var i; - var child; - var curX = 0; - var curY = 0; - var maxWidth = 0; - var maxHeight = 0; - var cw = 0, ch = 0; - var j = 0; - var page = 0; - var k = 0; - var cnt = this._children.length; - var viewWidth = this.viewWidth; - var viewHeight = this.viewHeight; - var lineSize = 0; - var lineStart = 0; - var ratio = 0; - if (this._layout == fgui.ListLayoutType.SingleColumn) { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (curY != 0) - curY += this._lineGap; - child.y = curY; - if (this._autoResizeItem) - child.setSize(viewWidth, child.height, true); - curY += Math.ceil(child.height); - if (child.width > maxWidth) - maxWidth = child.width; - } - ch = curY; - if (ch <= viewHeight && this._autoResizeItem && this._scrollPane && this._scrollPane._displayInDemand && this._scrollPane.vtScrollBar) { - viewWidth += this._scrollPane.vtScrollBar.width; - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - child.setSize(viewWidth, child.height, true); - if (child.width > maxWidth) - maxWidth = child.width; - } - } - cw = Math.ceil(maxWidth); - } - else if (this._layout == fgui.ListLayoutType.SingleRow) { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (curX != 0) - curX += this._columnGap; - child.x = curX; - if (this._autoResizeItem) - child.setSize(child.width, viewHeight, true); - curX += Math.ceil(child.width); - if (child.height > maxHeight) - maxHeight = child.height; - } - cw = curX; - if (cw <= viewWidth && this._autoResizeItem && this._scrollPane && this._scrollPane._displayInDemand && this._scrollPane.hzScrollBar) { - viewHeight += this._scrollPane.hzScrollBar.height; - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - child.setSize(child.width, viewHeight, true); - if (child.height > maxHeight) - maxHeight = child.height; - } - } - ch = Math.ceil(maxHeight); - } - else if (this._layout == fgui.ListLayoutType.FlowHorizontal) { - if (this._autoResizeItem && this._columnCount > 0) { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - lineSize += child.sourceWidth; - j++; - if (j == this._columnCount || i == cnt - 1) { - ratio = (viewWidth - lineSize - (j - 1) * this._columnGap) / lineSize; - curX = 0; - for (j = lineStart; j <= i; j++) { - child = this.getChildAt(j); - if (this.foldInvisibleItems && !child.visible) - continue; - child.setXY(curX, curY); - if (j < i) { - child.setSize(child.sourceWidth + Math.round(child.sourceWidth * ratio), child.height, true); - curX += Math.ceil(child.width) + this._columnGap; - } - else { - child.setSize(viewWidth - curX, child.height, true); - } - if (child.height > maxHeight) - maxHeight = child.height; - } - curY += Math.ceil(maxHeight) + this._lineGap; - maxHeight = 0; - j = 0; - lineStart = i + 1; - lineSize = 0; - } - } - ch = curY + Math.ceil(maxHeight); - cw = viewWidth; - } - else { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (curX != 0) - curX += this._columnGap; - if (this._columnCount != 0 && j >= this._columnCount - || this._columnCount == 0 && curX + child.width > viewWidth && maxHeight != 0) { - curX = 0; - curY += Math.ceil(maxHeight) + this._lineGap; - maxHeight = 0; - j = 0; - } - child.setXY(curX, curY); - curX += Math.ceil(child.width); - if (curX > maxWidth) - maxWidth = curX; - if (child.height > maxHeight) - maxHeight = child.height; - j++; - } - ch = curY + Math.ceil(maxHeight); - cw = Math.ceil(maxWidth); - } - } - else if (this._layout == fgui.ListLayoutType.FlowVertical) { - if (this._autoResizeItem && this._lineCount > 0) { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - lineSize += child.sourceHeight; - j++; - if (j == this._lineCount || i == cnt - 1) { - ratio = (viewHeight - lineSize - (j - 1) * this._lineGap) / lineSize; - curY = 0; - for (j = lineStart; j <= i; j++) { - child = this.getChildAt(j); - if (this.foldInvisibleItems && !child.visible) - continue; - child.setXY(curX, curY); - if (j < i) { - child.setSize(child.width, child.sourceHeight + Math.round(child.sourceHeight * ratio), true); - curY += Math.ceil(child.height) + this._lineGap; - } - else { - child.setSize(child.width, viewHeight - curY, true); - } - if (child.width > maxWidth) - maxWidth = child.width; - } - curX += Math.ceil(maxWidth) + this._columnGap; - maxWidth = 0; - j = 0; - lineStart = i + 1; - lineSize = 0; - } - } - cw = curX + Math.ceil(maxWidth); - ch = viewHeight; - } - else { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (curY != 0) - curY += this._lineGap; - if (this._lineCount != 0 && j >= this._lineCount - || this._lineCount == 0 && curY + child.height > viewHeight && maxWidth != 0) { - curY = 0; - curX += Math.ceil(maxWidth) + this._columnGap; - maxWidth = 0; - j = 0; - } - child.setXY(curX, curY); - curY += Math.ceil(child.height); - if (curY > maxHeight) - maxHeight = curY; - if (child.width > maxWidth) - maxWidth = child.width; - j++; - } - cw = curX + Math.ceil(maxWidth); - ch = Math.ceil(maxHeight); - } - } - else { - var eachHeight; - if (this._autoResizeItem && this._lineCount > 0) - eachHeight = Math.floor((viewHeight - (this._lineCount - 1) * this._lineGap) / this._lineCount); - if (this._autoResizeItem && this._columnCount > 0) { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (j == 0 && (this._lineCount != 0 && k >= this._lineCount - || this._lineCount == 0 && curY + (this._lineCount > 0 ? eachHeight : child.height) > viewHeight)) { - page++; - curY = 0; - k = 0; - } - lineSize += child.sourceWidth; - j++; - if (j == this._columnCount || i == cnt - 1) { - ratio = (viewWidth - lineSize - (j - 1) * this._columnGap) / lineSize; - curX = 0; - for (j = lineStart; j <= i; j++) { - child = this.getChildAt(j); - if (this.foldInvisibleItems && !child.visible) - continue; - child.setXY(page * viewWidth + curX, curY); - if (j < i) { - child.setSize(child.sourceWidth + Math.round(child.sourceWidth * ratio), this._lineCount > 0 ? eachHeight : child.height, true); - curX += Math.ceil(child.width) + this._columnGap; - } - else { - child.setSize(viewWidth - curX, this._lineCount > 0 ? eachHeight : child.height, true); - } - if (child.height > maxHeight) - maxHeight = child.height; - } - curY += Math.ceil(maxHeight) + this._lineGap; - maxHeight = 0; - j = 0; - lineStart = i + 1; - lineSize = 0; - k++; - } - } - } - else { - for (i = 0; i < cnt; i++) { - child = this.getChildAt(i); - if (this.foldInvisibleItems && !child.visible) - continue; - if (curX != 0) - curX += this._columnGap; - if (this._autoResizeItem && this._lineCount > 0) - child.setSize(child.width, eachHeight, true); - if (this._columnCount != 0 && j >= this._columnCount - || this._columnCount == 0 && curX + child.width > viewWidth && maxHeight != 0) { - curX = 0; - curY += Math.ceil(maxHeight) + this._lineGap; - maxHeight = 0; - j = 0; - k++; - if (this._lineCount != 0 && k >= this._lineCount - || this._lineCount == 0 && curY + child.height > viewHeight && maxWidth != 0) { - page++; - curY = 0; - k = 0; - } - } - child.setXY(page * viewWidth + curX, curY); - curX += Math.ceil(child.width); - if (curX > maxWidth) - maxWidth = curX; - if (child.height > maxHeight) - maxHeight = child.height; - j++; - } - } - ch = page > 0 ? viewHeight : curY + Math.ceil(maxHeight); - cw = (page + 1) * viewWidth; - } - this.handleAlign(cw, ch); - this.setBounds(0, 0, cw, ch); - }; - GList.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._layout = buffer.readByte(); - this._selectionMode = buffer.readByte(); - this._align = buffer.readByte(); - this._verticalAlign = buffer.readByte(); - this._lineGap = buffer.readShort(); - this._columnGap = buffer.readShort(); - this._lineCount = buffer.readShort(); - this._columnCount = buffer.readShort(); - this._autoResizeItem = buffer.readBool(); - this._childrenRenderOrder = buffer.readByte(); - this._apexIndex = buffer.readShort(); - if (buffer.readBool()) { - this._margin.top = buffer.readInt(); - this._margin.bottom = buffer.readInt(); - this._margin.left = buffer.readInt(); - this._margin.right = buffer.readInt(); - } - var overflow = buffer.readByte(); - if (overflow == fgui.OverflowType.Scroll) { - var savedPos = buffer.position; - buffer.seek(beginPos, 7); - this.setupScroll(buffer); - buffer.position = savedPos; - } - else - this.setupOverflow(overflow); - if (buffer.readBool()) - buffer.skip(8); - if (buffer.version >= 2) { - this.scrollItemToViewOnClick = buffer.readBool(); - this.foldInvisibleItems = buffer.readBool(); - } - buffer.seek(beginPos, 8); - this._defaultItem = buffer.readS(); - this.readItems(buffer); - }; - GList.prototype.readItems = function (buffer) { - var cnt; - var i; - var nextPos; - var str; - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - str = buffer.readS(); - if (str == null) { - str = this.defaultItem; - if (!str) { - buffer.position = nextPos; - continue; - } - } - var obj = this.getFromPool(str); - if (obj != null) { - this.addChild(obj); - this.setupItem(buffer, obj); - } - buffer.position = nextPos; - } - }; - GList.prototype.setupItem = function (buffer, obj) { - var str; - str = buffer.readS(); - if (str != null) - obj.text = str; - str = buffer.readS(); - if (str != null && (obj instanceof fgui.GButton)) - obj.selectedTitle = str; - str = buffer.readS(); - if (str != null) - obj.icon = str; - str = buffer.readS(); - if (str != null && (obj instanceof fgui.GButton)) - obj.selectedIcon = str; - str = buffer.readS(); - if (str != null) - obj.name = str; - var cnt; - var i; - if (obj instanceof fgui.GComponent) { - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - var cc = obj.getController(buffer.readS()); - str = buffer.readS(); - if (cc) - cc.selectedPageId = str; - } - if (buffer.version >= 2) { - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - var target = buffer.readS(); - var propertyId = buffer.readShort(); - var value = buffer.readS(); - var obj2 = obj.getChildByPath(target); - if (obj2) - obj2.setProp(propertyId, value); - } - } - } - }; - GList.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 6); - var i = buffer.readShort(); - if (i != -1) - this._selectionController = this.parent.getControllerAt(i); - }; - return GList; - }(fgui.GComponent)); - fgui.GList = GList; - var s_n = 0; -})(fgui || (fgui = {})); - -(function (fgui) { - var GObjectPool = (function () { - function GObjectPool() { - this._count = 0; - this._pool = {}; - } - GObjectPool.prototype.clear = function () { - for (var i1 in this._pool) { - var arr = this._pool[i1]; - var cnt = arr.length; - for (var i = 0; i < cnt; i++) - arr[i].dispose(); - } - this._pool = {}; - this._count = 0; - }; - Object.defineProperty(GObjectPool.prototype, "count", { - get: function () { - return this._count; - }, - enumerable: true, - configurable: true - }); - GObjectPool.prototype.getObject = function (url) { - url = fgui.UIPackage.normalizeURL(url); - if (url == null) - return null; - var arr = this._pool[url]; - if (arr && arr.length) { - this._count--; - return arr.shift(); - } - var child = fgui.UIPackage.createObjectFromURL(url); - return child; - }; - GObjectPool.prototype.returnObject = function (obj) { - var url = obj.resourceURL; - if (!url) - return; - var arr = this._pool[url]; - if (arr == null) { - arr = new Array(); - this._pool[url] = arr; - } - this._count++; - arr.push(obj); - }; - return GObjectPool; - }()); - fgui.GObjectPool = GObjectPool; -})(fgui || (fgui = {})); - -(function (fgui) { - var GLoader = (function (_super_1) { - __extends(GLoader, _super_1); - function GLoader() { - var _this = _super_1.call(this) || this; - _this._url = ""; - _this._fill = fgui.LoaderFillType.None; - _this._align = fgui.AlignType.Left; - _this._verticalAlign = fgui.VertAlignType.Top; - _this._showErrorSign = true; - return _this; - } - GLoader.prototype.createDisplayObject = function () { - this._container = new fgui.UIContainer(); - this._container.opaque = true; - this.setDisplayObject(this._container); - this._content = new fgui.MovieClip(); - this._container.addChild(this._content); - }; - GLoader.prototype.dispose = function () { - if (!this._contentItem) { - var texture = this._content.texture; - if (texture) - this.freeExternal(texture); - } - if (this._content2) - this._content2.dispose(); - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GLoader.prototype, "url", { - get: function () { - return this._url; - }, - set: function (value) { - if (this._url == value) - return; - this.clearContent(); - this._url = value; - this.loadContent(); - this.updateGear(7); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "icon", { - get: function () { - return this._url; - }, - set: function (value) { - this.url = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "align", { - get: function () { - return this._align; - }, - set: function (value) { - if (this._align != value) { - this._align = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "verticalAlign", { - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign != value) { - this._verticalAlign = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "fill", { - get: function () { - return this._fill; - }, - set: function (value) { - if (this._fill != value) { - this._fill = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "shrinkOnly", { - get: function () { - return this._shrinkOnly; - }, - set: function (value) { - if (this._shrinkOnly != value) { - this._shrinkOnly = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "autoSize", { - get: function () { - return this._autoSize; - }, - set: function (value) { - if (this._autoSize != value) { - this._autoSize = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "playing", { - get: function () { - return this._content.playing; - }, - set: function (value) { - if (this._content.playing != value) { - this._content.playing = value; - this.updateGear(5); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "frame", { - get: function () { - return this._content.frame; - }, - set: function (value) { - if (this._content.frame != value) { - this._content.frame = value; - this.updateGear(5); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "color", { - get: function () { - return this._content.color; - }, - set: function (value) { - if (this._content.color != value) { - this._content.color = value; - this.updateGear(4); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "showErrorSign", { - get: function () { - return this._showErrorSign; - }, - set: function (value) { - this._showErrorSign = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "content", { - get: function () { - return this._content; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "component", { - get: function () { - return this._content2; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "texture", { - get: function () { - return this._content.texture; - }, - set: function (value) { - this.url = null; - this._content.frames = null; - this._content.texture = value; - if (value) { - this.sourceWidth = value.textureWidth; - this.sourceHeight = value.textureHeight; - } - else { - this.sourceWidth = this.sourceHeight = 0; - } - this.updateLayout(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "fillMethod", { - get: function () { - return this._content.fillMethod; - }, - set: function (value) { - this._content.fillMethod = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "fillOrigin", { - get: function () { - return this._content.fillOrigin; - }, - set: function (value) { - this._content.fillOrigin = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "fillClockwise", { - get: function () { - return this._content.fillClockwise; - }, - set: function (value) { - this._content.fillClockwise = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader.prototype, "fillAmount", { - get: function () { - return this._content.fillAmount; - }, - set: function (value) { - this._content.fillAmount = value; - }, - enumerable: true, - configurable: true - }); - GLoader.prototype.loadContent = function () { - if (!this._url) - return; - if (fgui.ToolSet.startsWith(this._url, "ui://")) - this.loadFromPackage(this._url); - else - this.loadExternal(); - }; - GLoader.prototype.loadFromPackage = function (itemURL) { - this._contentItem = fgui.UIPackage.getItemByURL(itemURL); - if (this._contentItem) { - this._contentItem = this._contentItem.getBranch(); - this.sourceWidth = this._contentItem.width; - this.sourceHeight = this._contentItem.height; - this._contentItem = this._contentItem.getHighResolution(); - this._contentItem.load(); - if (this._autoSize) - this.setSize(this.sourceWidth, this.sourceHeight); - if (this._contentItem.type == fgui.PackageItemType.Image) { - if (this._contentItem.asset == null) { - this.setErrorState(); - } - else { - this._content.texture = this._contentItem.asset; - this._content.scale9Grid = this._contentItem.scale9Grid; - if (this._contentItem.scaleByTile) - this._content.fillMode = egret.BitmapFillMode.REPEAT; - else - this._content.fillMode = egret.BitmapFillMode.SCALE; - this.updateLayout(); - } - } - else if (this._contentItem.type == fgui.PackageItemType.MovieClip) { - this._content.interval = this._contentItem.interval; - this._content.swing = this._contentItem.swing; - this._content.repeatDelay = this._contentItem.repeatDelay; - this._content.frames = this._contentItem.frames; - this.updateLayout(); - } - else if (this._contentItem.type == fgui.PackageItemType.Component) { - var obj = fgui.UIPackage.createObjectFromURL(itemURL); - if (!obj) - this.setErrorState(); - else if (!(obj instanceof fgui.GComponent)) { - obj.dispose(); - this.setErrorState(); - } - else { - this._content2 = obj.asCom; - this._container.addChild(this._content2.displayObject); - this.updateLayout(); - } - } - else - this.setErrorState(); - } - else - this.setErrorState(); - }; - GLoader.prototype.loadExternal = function () { - RES.getResByUrl(this._url, this.__getResCompleted, this); - }; - GLoader.prototype.freeExternal = function (texture) { - }; - GLoader.prototype.onExternalLoadSuccess = function (texture) { - this._content.texture = texture; - this._content.scale9Grid = null; - this._content.fillMode = egret.BitmapFillMode.SCALE; - this.sourceWidth = texture.textureWidth; - this.sourceHeight = texture.textureHeight; - this.updateLayout(); - }; - GLoader.prototype.onExternalLoadFailed = function () { - this.setErrorState(); - }; - GLoader.prototype.__getResCompleted = function (res, key) { - if (res instanceof egret.Texture) - this.onExternalLoadSuccess(res); - else - this.onExternalLoadFailed(); - }; - GLoader.prototype.setErrorState = function () { - if (!this._showErrorSign) - return; - if (this._errorSign == null) { - if (fgui.UIConfig.loaderErrorSign != null) { - this._errorSign = GLoader._errorSignPool.getObject(fgui.UIConfig.loaderErrorSign); - } - } - if (this._errorSign) { - this._errorSign.setSize(this.width, this.height); - this._container.addChild(this._errorSign.displayObject); - } - }; - GLoader.prototype.clearErrorState = function () { - if (this._errorSign) { - this._container.removeChild(this._errorSign.displayObject); - GLoader._errorSignPool.returnObject(this._errorSign); - this._errorSign = null; - } - }; - GLoader.prototype.updateLayout = function () { - if (!this._content2 && !this._content) { - if (this._autoSize) { - this._updatingLayout = true; - this.setSize(50, 30); - this._updatingLayout = false; - } - return; - } - var cw = this.sourceWidth; - var ch = this.sourceHeight; - if (this._autoSize) { - this._updatingLayout = true; - if (cw == 0) - cw = 50; - if (ch == 0) - ch = 30; - this.setSize(cw, ch); - this._updatingLayout = false; - if (cw == this._width && ch == this._height) { - if (this._content2) { - this._content2.setXY(0, 0); - this._content2.setScale(1, 1); - } - else { - this._content.x = 0; - this._content.y = 0; - this._content.width = cw; - this._content.height = ch; - } - return; - } - } - var sx = 1, sy = 1; - if (this._fill != fgui.LoaderFillType.None) { - sx = this.width / this.sourceWidth; - sy = this.height / this.sourceHeight; - if (sx != 1 || sy != 1) { - if (this._fill == fgui.LoaderFillType.ScaleMatchHeight) - sx = sy; - else if (this._fill == fgui.LoaderFillType.ScaleMatchWidth) - sy = sx; - else if (this._fill == fgui.LoaderFillType.Scale) { - if (sx > sy) - sx = sy; - else - sy = sx; - } - else if (this._fill == fgui.LoaderFillType.ScaleNoBorder) { - if (sx > sy) - sy = sx; - else - sx = sy; - } - if (this._shrinkOnly) { - if (sx > 1) - sx = 1; - if (sy > 1) - sy = 1; - } - cw = this.sourceWidth * sx; - ch = this.sourceHeight * sy; - } - } - if (this._content2) { - this._content2.setScale(sx, sy); - } - else { - this._content.width = cw; - this._content.height = ch; - } - var nx, ny; - if (this._align == fgui.AlignType.Center) - nx = Math.floor((this.width - cw) / 2); - else if (this._align == fgui.AlignType.Right) - nx = this.width - cw; - else - nx = 0; - if (this._verticalAlign == fgui.VertAlignType.Middle) - ny = Math.floor((this.height - ch) / 2); - else if (this._verticalAlign == fgui.VertAlignType.Bottom) - ny = this.height - ch; - else - ny = 0; - if (this._content2) - this._content2.setXY(nx, ny); - else { - this._content.x = nx; - this._content.y = ny; - } - }; - GLoader.prototype.clearContent = function () { - this.clearErrorState(); - if (!this._contentItem && this._content.texture) { - this.freeExternal(this._content.texture); - } - this._content.texture = null; - this._content.frames = null; - if (this._content2) { - this._container.removeChild(this._content2.displayObject); - this._content2.dispose(); - this._content2 = null; - } - this._contentItem = null; - }; - GLoader.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (!this._updatingLayout) - this.updateLayout(); - }; - GLoader.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.color; - case fgui.ObjectPropID.Playing: - return this.playing; - case fgui.ObjectPropID.Frame: - return this.frame; - case fgui.ObjectPropID.TimeScale: - return this._content.timeScale; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GLoader.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.color = value; - break; - case fgui.ObjectPropID.Playing: - this.playing = value; - break; - case fgui.ObjectPropID.Frame: - this.frame = value; - break; - case fgui.ObjectPropID.TimeScale: - this._content.timeScale = value; - break; - case fgui.ObjectPropID.DeltaTime: - this._content.advance(value); - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GLoader.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._url = buffer.readS(); - this._align = buffer.readByte(); - this._verticalAlign = buffer.readByte(); - this._fill = buffer.readByte(); - this._shrinkOnly = buffer.readBool(); - this._autoSize = buffer.readBool(); - this._showErrorSign = buffer.readBool(); - this._content.playing = buffer.readBool(); - this._content.frame = buffer.readInt(); - if (buffer.readBool()) - this.color = buffer.readColor(); - this._content.fillMethod = buffer.readByte(); - if (this._content.fillMethod != 0) { - this._content.fillOrigin = buffer.readByte(); - this._content.fillClockwise = buffer.readBool(); - this._content.fillAmount = buffer.readFloat(); - } - if (this._url) - this.loadContent(); - }; - GLoader._errorSignPool = new fgui.GObjectPool(); - return GLoader; - }(fgui.GObject)); - fgui.GLoader = GLoader; -})(fgui || (fgui = {})); - -(function (fgui) { - var GLoader3D = (function (_super_1) { - __extends(GLoader3D, _super_1); - function GLoader3D() { - var _this = _super_1.call(this) || this; - _this._frame = 0; - _this._playing = true; - _this._url = ""; - _this._fill = fgui.LoaderFillType.None; - _this._align = fgui.AlignType.Left; - _this._verticalAlign = fgui.VertAlignType.Top; - _this._color = 0xFFFFFF; - return _this; - } - GLoader3D.prototype.createDisplayObject = function () { - var d = new fgui.UIContainer(); - d.opaque = true; - this.setDisplayObject(d); - this._container = new egret.DisplayObjectContainer(); - d.addChild(this._container); - }; - GLoader3D.prototype.dispose = function () { - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GLoader3D.prototype, "url", { - get: function () { - return this._url; - }, - set: function (value) { - if (this._url == value) - return; - this._url = value; - this.loadContent(); - this.updateGear(7); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "icon", { - get: function () { - return this._url; - }, - set: function (value) { - this.url = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "align", { - get: function () { - return this._align; - }, - set: function (value) { - if (this._align != value) { - this._align = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "verticalAlign", { - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign != value) { - this._verticalAlign = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "fill", { - get: function () { - return this._fill; - }, - set: function (value) { - if (this._fill != value) { - this._fill = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "shrinkOnly", { - get: function () { - return this._shrinkOnly; - }, - set: function (value) { - if (this._shrinkOnly != value) { - this._shrinkOnly = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "autoSize", { - get: function () { - return this._autoSize; - }, - set: function (value) { - if (this._autoSize != value) { - this._autoSize = value; - this.updateLayout(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "playing", { - get: function () { - return this._playing; - }, - set: function (value) { - if (this._playing != value) { - this._playing = value; - this.updateGear(5); - this.onChange(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "frame", { - get: function () { - return this._frame; - }, - set: function (value) { - if (this._frame != value) { - this._frame = value; - this.updateGear(5); - this.onChange(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "animationName", { - get: function () { - return this._animationName; - }, - set: function (value) { - if (this._animationName != value) { - this._animationName = value; - this.onChange(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "skinName", { - get: function () { - return this._skinName; - }, - set: function (value) { - if (this._skinName != value) { - this._skinName = value; - this.onChange(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "loop", { - get: function () { - return this._loop; - }, - set: function (value) { - if (this._loop != value) { - this._loop = value; - this.onChange(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "color", { - get: function () { - return this._color; - }, - set: function (value) { - if (this._color != value) { - this._color = value; - this.updateGear(4); - if (this._content) - this._content.tint = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GLoader3D.prototype, "content", { - get: function () { - return; - }, - enumerable: true, - configurable: true - }); - GLoader3D.prototype.loadContent = function () { - this.clearContent(); - if (!this._url) - return; - if (fgui.ToolSet.startsWith(this._url, "ui://")) - this.loadFromPackage(this._url); - else - this.loadExternal(); - }; - GLoader3D.prototype.loadFromPackage = function (itemURL) { - this._contentItem = fgui.UIPackage.getItemByURL(itemURL); - if (this._contentItem) { - this._contentItem = this._contentItem.getBranch(); - this.sourceWidth = this._contentItem.width; - this.sourceHeight = this._contentItem.height; - this._contentItem = this._contentItem.getHighResolution(); - if (this._autoSize) - this.setSize(this.sourceWidth, this.sourceHeight); - if (this._contentItem.type == fgui.PackageItemType.Spine || this._contentItem.type == fgui.PackageItemType.DragonBones) - this._contentItem.owner.getItemAssetAsync(this._contentItem, this.onLoaded.bind(this)); - } - }; - GLoader3D.prototype.onLoaded = function (err, item) { - if (this._contentItem != item) - return; - if (err) - console.warn(err); - if (!this._contentItem.asset) - return; - if (this._contentItem.type == fgui.PackageItemType.DragonBones) - this.setDragonBones(this._contentItem.armatureName, this._contentItem.asset.name, this._contentItem.atlasAsset.name, this._skinName, this._contentItem.skeletonAnchor); - }; - GLoader3D.prototype.setDragonBones = function (armatureName, dragonBonesName, skinName, textureAtlasName, anchor) { - this.url = null; - var egretFactory = dragonBones.EgretFactory.factory; - this._content = egretFactory.buildArmatureDisplay(armatureName, dragonBonesName, skinName, textureAtlasName); - this._container.addChild(this._content); - this._content.x = anchor.x; - this._content.y = anchor.y; - this._content.tint = this._color; - this.onChangeDragonBones(); - this.updateLayout(); - }; - GLoader3D.prototype.onChange = function () { - this.onChangeDragonBones(); - }; - GLoader3D.prototype.onChangeDragonBones = function () { - if (!(this._content instanceof dragonBones.EgretArmatureDisplay)) - return; - if (this._animationName) { - if (this._playing) - this._content.animation.play(this._animationName, this._loop ? 0 : 1); - else - this._content.animation.gotoAndStopByFrame(this._animationName, this._frame); - } - else - this._content.animation.reset(); - }; - GLoader3D.prototype.loadExternal = function () { - }; - GLoader3D.prototype.updateLayout = function () { - var cw = this.sourceWidth; - var ch = this.sourceHeight; - if (this._autoSize) { - this._updatingLayout = true; - if (cw == 0) - cw = 50; - if (ch == 0) - ch = 30; - this.setSize(cw, ch); - this._updatingLayout = false; - if (cw == this._width && ch == this._height) { - this._container.scaleX = this._container.scaleY = 1; - this._container.x = this._container.y = 0; - return; - } - } - var sx = 1, sy = 1; - if (this._fill != fgui.LoaderFillType.None) { - sx = this.width / this.sourceWidth; - sy = this.height / this.sourceHeight; - if (sx != 1 || sy != 1) { - if (this._fill == fgui.LoaderFillType.ScaleMatchHeight) - sx = sy; - else if (this._fill == fgui.LoaderFillType.ScaleMatchWidth) - sy = sx; - else if (this._fill == fgui.LoaderFillType.Scale) { - if (sx > sy) - sx = sy; - else - sy = sx; - } - else if (this._fill == fgui.LoaderFillType.ScaleNoBorder) { - if (sx > sy) - sy = sx; - else - sx = sy; - } - if (this._shrinkOnly) { - if (sx > 1) - sx = 1; - if (sy > 1) - sy = 1; - } - cw = this.sourceWidth * sx; - ch = this.sourceHeight * sy; - } - } - this._container.scaleX = sx; - this._container.scaleY = sy; - var nx, ny; - if (this._align == fgui.AlignType.Center) - nx = Math.floor((this.width - cw) / 2); - else if (this._align == fgui.AlignType.Right) - nx = this.width - cw; - else - nx = 0; - if (this._verticalAlign == fgui.VertAlignType.Middle) - ny = Math.floor((this.height - ch) / 2); - else if (this._verticalAlign == fgui.VertAlignType.Bottom) - ny = this.height - ch; - else - ny = 0; - this._container.x = nx; - this._container.y = ny; - }; - GLoader3D.prototype.clearContent = function () { - this._contentItem = null; - if (this._content) { - this._container.removeChild(this._content); - if ('dispose' in this._content) - this._content.dispose(); - this._content = null; - } - }; - GLoader3D.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (!this._updatingLayout) - this.updateLayout(); - }; - GLoader3D.prototype.handleGrayedChanged = function () { - }; - GLoader3D.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.color; - case fgui.ObjectPropID.Playing: - return this.playing; - case fgui.ObjectPropID.Frame: - return this.frame; - case fgui.ObjectPropID.TimeScale: - return 1; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GLoader3D.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.color = value; - break; - case fgui.ObjectPropID.Playing: - this.playing = value; - break; - case fgui.ObjectPropID.Frame: - this.frame = value; - break; - case fgui.ObjectPropID.TimeScale: - break; - case fgui.ObjectPropID.DeltaTime: - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GLoader3D.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._url = buffer.readS(); - this._align = buffer.readByte(); - this._verticalAlign = buffer.readByte(); - this._fill = buffer.readByte(); - this._shrinkOnly = buffer.readBool(); - this._autoSize = buffer.readBool(); - this._animationName = buffer.readS(); - this._skinName = buffer.readS(); - this._playing = buffer.readBool(); - this._frame = buffer.readInt(); - this._loop = buffer.readBool(); - if (buffer.readBool()) - this.color = buffer.readColor(); - if (this._url) - this.loadContent(); - }; - return GLoader3D; - }(fgui.GObject)); - fgui.GLoader3D = GLoader3D; -})(fgui || (fgui = {})); - -(function (fgui) { - var GMovieClip = (function (_super_1) { - __extends(GMovieClip, _super_1); - function GMovieClip() { - return _super_1.call(this) || this; - } - Object.defineProperty(GMovieClip.prototype, "color", { - get: function () { - return this._content.color; - }, - set: function (value) { - if (this._content.color != value) { - this._content.color = value; - this.updateGear(4); - } - }, - enumerable: true, - configurable: true - }); - GMovieClip.prototype.createDisplayObject = function () { - this._content = new fgui.MovieClip(); - this._content.touchEnabled = false; - this.setDisplayObject(this._content); - }; - Object.defineProperty(GMovieClip.prototype, "playing", { - get: function () { - return this._content.playing; - }, - set: function (value) { - if (this._content.playing != value) { - this._content.playing = value; - this.updateGear(5); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GMovieClip.prototype, "frame", { - get: function () { - return this._content.frame; - }, - set: function (value) { - if (this._content.frame != value) { - this._content.frame = value; - this.updateGear(5); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GMovieClip.prototype, "timeScale", { - get: function () { - return this._content.timeScale; - }, - set: function (value) { - this._content.timeScale = value; - }, - enumerable: true, - configurable: true - }); - GMovieClip.prototype.rewind = function () { - this._content.rewind(); - }; - GMovieClip.prototype.syncStatus = function (anotherMc) { - this._content.syncStatus(anotherMc._content); - }; - GMovieClip.prototype.advance = function (timeInMiniseconds) { - this._content.advance(timeInMiniseconds); - }; - GMovieClip.prototype.setPlaySettings = function (start, end, times, endAt, endCallback, callbackObj) { - this._content.setPlaySettings(start, end, times, endAt, endCallback, callbackObj); - }; - GMovieClip.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.color; - case fgui.ObjectPropID.Playing: - return this.playing; - case fgui.ObjectPropID.Frame: - return this.frame; - case fgui.ObjectPropID.TimeScale: - return this.timeScale; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GMovieClip.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.color = value; - break; - case fgui.ObjectPropID.Playing: - this.playing = value; - break; - case fgui.ObjectPropID.Frame: - this.frame = value; - break; - case fgui.ObjectPropID.TimeScale: - this.timeScale = value; - break; - case fgui.ObjectPropID.DeltaTime: - this.advance(value); - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GMovieClip.prototype.constructFromResource = function () { - var contentItem = this.packageItem.getBranch(); - this.sourceWidth = contentItem.width; - this.sourceHeight = contentItem.height; - this.initWidth = this.sourceWidth; - this.initHeight = this.sourceHeight; - this.setSize(this.sourceWidth, this.sourceHeight); - contentItem = contentItem.getHighResolution(); - contentItem.load(); - this._content.interval = contentItem.interval; - this._content.swing = contentItem.swing; - this._content.repeatDelay = contentItem.repeatDelay; - this._content.frames = contentItem.frames; - this._content.smoothing = contentItem.smoothing; - }; - GMovieClip.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - if (buffer.readBool()) - this.color = buffer.readColor(); - buffer.readByte(); - this._content.frame = buffer.readInt(); - this._content.playing = buffer.readBool(); - }; - return GMovieClip; - }(fgui.GObject)); - fgui.GMovieClip = GMovieClip; -})(fgui || (fgui = {})); - -(function (fgui) { - var GProgressBar = (function (_super_1) { - __extends(GProgressBar, _super_1); - function GProgressBar() { - var _this = _super_1.call(this) || this; - _this._min = 0; - _this._max = 0; - _this._value = 0; - _this._barMaxWidth = 0; - _this._barMaxHeight = 0; - _this._barMaxWidthDelta = 0; - _this._barMaxHeightDelta = 0; - _this._barStartX = 0; - _this._barStartY = 0; - _this._titleType = fgui.ProgressTitleType.Percent; - _this._value = 50; - _this._max = 100; - return _this; - } - Object.defineProperty(GProgressBar.prototype, "titleType", { - get: function () { - return this._titleType; - }, - set: function (value) { - if (this._titleType != value) { - this._titleType = value; - this.update(this._value); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GProgressBar.prototype, "min", { - get: function () { - return this._min; - }, - set: function (value) { - if (this._min != value) { - this._min = value; - this.update(this._value); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GProgressBar.prototype, "max", { - get: function () { - return this._max; - }, - set: function (value) { - if (this._max != value) { - this._max = value; - this.update(this._value); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GProgressBar.prototype, "value", { - get: function () { - return this._value; - }, - set: function (value) { - if (this._value != value) { - fgui.GTween.kill(this, false, this.update); - this._value = value; - this.update(value); - } - }, - enumerable: true, - configurable: true - }); - GProgressBar.prototype.tweenValue = function (value, duration) { - var oldValule; - var tweener = fgui.GTween.getTween(this, this.update); - if (tweener) { - oldValule = tweener.value.x; - tweener.kill(); - } - else - oldValule = this._value; - this._value = value; - return fgui.GTween.to(oldValule, this._value, duration).setTarget(this, this.update).setEase(fgui.EaseType.Linear); - }; - GProgressBar.prototype.update = function (newValue) { - var percent = fgui.ToolSet.clamp01((newValue - this._min) / (this._max - this._min)); - if (this._titleObject) { - switch (this._titleType) { - case fgui.ProgressTitleType.Percent: - this._titleObject.text = Math.floor(percent * 100) + "%"; - break; - case fgui.ProgressTitleType.ValueAndMax: - this._titleObject.text = Math.floor(newValue) + "/" + Math.floor(this._max); - break; - case fgui.ProgressTitleType.Value: - this._titleObject.text = "" + Math.floor(newValue); - break; - case fgui.ProgressTitleType.Max: - this._titleObject.text = "" + Math.floor(this._max); - break; - } - } - var fullWidth = this.width - this._barMaxWidthDelta; - var fullHeight = this.height - this._barMaxHeightDelta; - if (!this._reverse) { - if (this._barObjectH) { - if (!this.setFillAmount(this._barObjectH, percent)) - this._barObjectH.width = Math.round(fullWidth * percent); - } - if (this._barObjectV) { - if (!this.setFillAmount(this._barObjectV, percent)) - this._barObjectV.height = Math.round(fullHeight * percent); - } - } - else { - if (this._barObjectH) { - if (!this.setFillAmount(this._barObjectH, 1 - percent)) { - this._barObjectH.width = Math.round(fullWidth * percent); - this._barObjectH.x = this._barStartX + (fullWidth - this._barObjectH.width); - } - } - if (this._barObjectV) { - if (!this.setFillAmount(this._barObjectV, 1 - percent)) { - this._barObjectV.height = Math.round(fullHeight * percent); - this._barObjectV.y = this._barStartY + (fullHeight - this._barObjectV.height); - } - } - } - if (this._aniObject) - this._aniObject.setProp(fgui.ObjectPropID.Frame, Math.floor(percent * 100)); - }; - GProgressBar.prototype.setFillAmount = function (bar, percent) { - if (((bar instanceof fgui.GImage) || (bar instanceof fgui.GLoader)) && bar.fillMethod != fgui.FillMethod.None) { - bar.fillAmount = percent; - return true; - } - else - return false; - }; - GProgressBar.prototype.constructExtension = function (buffer) { - buffer.seek(0, 6); - this._titleType = buffer.readByte(); - this._reverse = buffer.readBool(); - this._titleObject = this.getChild("title"); - this._barObjectH = this.getChild("bar"); - this._barObjectV = this.getChild("bar_v"); - this._aniObject = this.getChild("ani"); - if (this._barObjectH) { - this._barMaxWidth = this._barObjectH.width; - this._barMaxWidthDelta = this.width - this._barMaxWidth; - this._barStartX = this._barObjectH.x; - } - if (this._barObjectV) { - this._barMaxHeight = this._barObjectV.height; - this._barMaxHeightDelta = this.height - this._barMaxHeight; - this._barStartY = this._barObjectV.y; - } - }; - GProgressBar.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (this._barObjectH) - this._barMaxWidth = this.width - this._barMaxWidthDelta; - if (this._barObjectV) - this._barMaxHeight = this.height - this._barMaxHeightDelta; - if (!this._underConstruct) - this.update(this._value); - }; - GProgressBar.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!buffer.seek(beginPos, 6)) { - this.update(this._value); - return; - } - if (buffer.readByte() != this.packageItem.objectType) { - this.update(this._value); - return; - } - this._value = buffer.readInt(); - this._max = buffer.readInt(); - if (buffer.version >= 2) - this._min = buffer.readInt(); - this.update(this._value); - }; - return GProgressBar; - }(fgui.GComponent)); - fgui.GProgressBar = GProgressBar; -})(fgui || (fgui = {})); - -(function (fgui) { - var GTextField = (function (_super_1) { - __extends(GTextField, _super_1); - function GTextField() { - var _this = _super_1.call(this) || this; - _this._fontSize = 0; - _this._leading = 0; - _this._letterSpacing = 0; - _this._textWidth = 0; - _this._textHeight = 0; - _this._fontSize = 12; - _this._align = fgui.AlignType.Left; - _this._verticalAlign = fgui.VertAlignType.Top; - _this._text = ""; - _this._leading = 3; - _this._color = 0; - _this._autoSize = fgui.AutoSizeType.Both; - _this._widthAutoSize = true; - _this._heightAutoSize = true; - return _this; - } - GTextField.prototype.createDisplayObject = function () { - this._textField = new egret.TextField(); - this._textField.touchEnabled = false; - this.setDisplayObject(this._textField); - }; - GTextField.prototype.switchBitmapMode = function (val) { - if (val && this.displayObject == this._textField) { - if (this._bitmapContainer == null) - this._bitmapContainer = new egret.Sprite(); - this.switchDisplayObject(this._bitmapContainer); - } - else if (!val && this.displayObject == this._bitmapContainer) - this.switchDisplayObject(this._textField); - }; - GTextField.prototype.dispose = function () { - _super_1.prototype.dispose.call(this); - this._bitmapFont = null; - this._requireRender = false; - }; - Object.defineProperty(GTextField.prototype, "text", { - get: function () { - return this._text; - }, - set: function (value) { - this._text = value; - if (this._text == null) - this._text = ""; - this.updateGear(6); - if (this.parent && this.parent._underConstruct) - this.renderNow(); - else - this.render(); - }, - enumerable: true, - configurable: true - }); - GTextField.prototype.updateTextFieldText = function () { - var text2 = this._text; - if (this._templateVars) - text2 = this.parseTemplate(text2); - if (this._ubbEnabled) { - var arr = GTextField._htmlParser.parser(fgui.UBBParser.inst.parse(fgui.ToolSet.encodeHTML(text2))); - if (this._underline) { - for (var i = 0; i < arr.length; i++) { - var element = arr[i]; - if (element.style) - element.style.underline = true; - else - element.style = { underline: true }; - } - } - this._textField.textFlow = arr; - } - else if (this._underline) { - var arr = new Array(1); - arr[0] = { text: text2, style: { underline: true } }; - this._textField.textFlow = arr; - } - else - this._textField.text = text2; - }; - Object.defineProperty(GTextField.prototype, "font", { - get: function () { - return this._font; - }, - set: function (value) { - if (this._font != value) { - this._font = value; - this.updateTextFormat(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "fontSize", { - get: function () { - return this._fontSize; - }, - set: function (value) { - if (value < 0) - return; - if (this._fontSize != value) { - this._fontSize = value; - this.updateTextFormat(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "color", { - get: function () { - return this._color; - }, - set: function (value) { - if (this._color != value) { - this._color = value; - this.updateGear(4); - this.updateTextFormat(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "align", { - get: function () { - return this._align; - }, - set: function (value) { - if (this._align != value) { - this._align = value; - this._textField.textAlign = this.getAlignTypeString(this._align); - if (this._bitmapFont && !this._underConstruct) - this.render(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "verticalAlign", { - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign != value) { - this._verticalAlign = value; - this._textField.verticalAlign = this.getVertAlignTypeString(this._verticalAlign); - if (this._bitmapFont && !this._underConstruct) - this.render(); - } - }, - enumerable: true, - configurable: true - }); - GTextField.prototype.getAlignTypeString = function (type) { - return type == fgui.AlignType.Left ? egret.HorizontalAlign.LEFT : - (type == fgui.AlignType.Center ? egret.HorizontalAlign.CENTER : egret.HorizontalAlign.RIGHT); - }; - GTextField.prototype.getVertAlignTypeString = function (type) { - return type == fgui.VertAlignType.Top ? egret.VerticalAlign.TOP : - (type == fgui.VertAlignType.Middle ? egret.VerticalAlign.MIDDLE : egret.VerticalAlign.BOTTOM); - }; - Object.defineProperty(GTextField.prototype, "leading", { - get: function () { - return this._leading; - }, - set: function (value) { - if (this._leading != value) { - this._leading = value; - this.updateTextFormat(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "letterSpacing", { - get: function () { - return this._letterSpacing; - }, - set: function (value) { - if (this._letterSpacing != value) { - this._letterSpacing = value; - this.updateTextFormat(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "underline", { - get: function () { - return this._underline; - }, - set: function (value) { - this._underline = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "bold", { - get: function () { - return this._textField.bold; - }, - set: function (value) { - this._textField.bold = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "italic", { - get: function () { - return this._textField.italic; - }, - set: function (value) { - this._textField.italic = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "singleLine", { - get: function () { - return !this._textField.multiline; - }, - set: function (value) { - value = !value; - if (this._textField.multiline != value) { - this._textField.multiline = value; - this.render(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "stroke", { - get: function () { - return this._textField.stroke; - }, - set: function (value) { - this._textField.stroke = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "strokeColor", { - get: function () { - return this._textField.strokeColor; - }, - set: function (value) { - this._textField.strokeColor = value; - this.updateGear(4); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "ubbEnabled", { - get: function () { - return this._ubbEnabled; - }, - set: function (value) { - if (this._ubbEnabled != value) { - this._ubbEnabled = value; - this.render(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "autoSize", { - get: function () { - return this._autoSize; - }, - set: function (value) { - if (this._autoSize != value) { - this._autoSize = value; - this._widthAutoSize = value == fgui.AutoSizeType.Both; - this._heightAutoSize = value == fgui.AutoSizeType.Both || value == fgui.AutoSizeType.Height; - this.render(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextField.prototype, "textWidth", { - get: function () { - if (this._requireRender) - this.renderNow(); - return this._textWidth; - }, - enumerable: true, - configurable: true - }); - GTextField.prototype.ensureSizeCorrect = function () { - if (this._sizeDirty && this._requireRender) - this.renderNow(); - }; - GTextField.prototype.updateTextFormat = function () { - this._textField.size = this._fontSize; - this._bitmapFont = null; - if (fgui.ToolSet.startsWith(this._font, "ui://")) { - var pi = fgui.UIPackage.getItemByURL(this._font); - if (pi) - this._bitmapFont = pi.owner.getItemAsset(pi); - } - if (this._bitmapFont == null) { - if (this._font) - this._textField.fontFamily = this._font; - else - this._textField.fontFamily = fgui.UIConfig.defaultFont; - } - if (this.grayed) - this._textField.textColor = 0xAAAAAA; - else - this._textField.textColor = this._color; - this._textField.lineSpacing = this._leading; - if (!this._underConstruct) - this.render(); - }; - GTextField.prototype.render = function () { - if (!this._requireRender) { - this._requireRender = true; - egret.callLater(this.__render, this); - } - if (!this._sizeDirty && (this._widthAutoSize || this._heightAutoSize)) { - this._sizeDirty = true; - this.dispatchEventWith(fgui.GObject.SIZE_DELAY_CHANGE); - } - }; - GTextField.prototype.__render = function () { - if (this._requireRender) - this.renderNow(); - }; - GTextField.prototype.renderNow = function (updateBounds) { - if (updateBounds === void 0) { updateBounds = true; } - this._requireRender = false; - this._sizeDirty = false; - if (this._bitmapFont) { - this.renderWithBitmapFont(updateBounds); - return; - } - this.switchBitmapMode(false); - this._textField.width = this._widthAutoSize ? (this.maxWidth <= 0 ? 10000 : this.maxWidth) : Math.ceil(this.width); - this.updateTextFieldText(); - this._textWidth = Math.ceil(this._textField.textWidth); - if (this._textWidth > 0) - this._textWidth += 4; - this._textHeight = Math.ceil(this._textField.textHeight); - if (this._textHeight > 0) - this._textHeight += 4; - var w, h = 0; - if (this._widthAutoSize) { - w = this._textWidth; - this._textField.width = w; - } - else - w = this.width; - if (this._heightAutoSize) { - h = this._textHeight; - if (this._textField.height != this._textHeight) - this._textField.height = this._textHeight; - } - else { - h = this.height; - if (this._textHeight > h) - this._textHeight = h; - } - if (updateBounds) { - this._updatingSize = true; - this.setSize(w, h); - this._updatingSize = false; - } - }; - GTextField.prototype.renderWithBitmapFont = function (updateBounds) { - this.switchBitmapMode(true); - if (!this._bitmapPool) - this._bitmapPool = []; - var cnt = this._bitmapContainer.numChildren; - for (var i = 0; i < cnt; i++) { - var obj = this._bitmapContainer.getChildAt(i); - this._bitmapPool.push(obj); - } - this._bitmapContainer.removeChildren(); - if (!this._lines) - this._lines = new Array(); - else - returnList(this._lines); - var letterSpacing = this._letterSpacing; - var lineSpacing = this._leading - 1; - var rectWidth = this.width - GUTTER_X * 2; - var lineWidth = 0, lineHeight = 0, lineTextHeight = 0; - var glyphWidth = 0, glyphHeight = 0; - var wordChars = 0, wordStart = 0, wordEnd = 0; - var lastLineHeight = 0; - var lineBuffer = ""; - var lineY = GUTTER_Y; - var line; - var wordWrap = !this._widthAutoSize && this._textField.multiline; - var fontScale = this._bitmapFont.resizable ? this._fontSize / this._bitmapFont.size : 1; - var tint = this._bitmapFont.tint; - this._textWidth = 0; - this._textHeight = 0; - var text2 = this._text; - if (this._templateVars) - text2 = this.parseTemplate(text2); - var textLength = text2.length; - for (var offset = 0; offset < textLength; ++offset) { - var ch = text2.charAt(offset); - var cc = ch.charCodeAt(0); - if (cc == 10) { - lineBuffer += ch; - line = borrow(); - line.width = lineWidth; - if (lineTextHeight == 0) { - if (lastLineHeight == 0) - lastLineHeight = this._fontSize; - if (lineHeight == 0) - lineHeight = lastLineHeight; - lineTextHeight = lineHeight; - } - line.height = lineHeight; - lastLineHeight = lineHeight; - line.textHeight = lineTextHeight; - line.text = lineBuffer; - line.y = lineY; - lineY += (line.height + lineSpacing); - if (line.width > this._textWidth) - this._textWidth = line.width; - this._lines.push(line); - lineBuffer = ""; - lineWidth = 0; - lineHeight = 0; - lineTextHeight = 0; - wordChars = 0; - wordStart = 0; - wordEnd = 0; - continue; - } - if (cc >= 65 && cc <= 90 || cc >= 97 && cc <= 122) { - if (wordChars == 0) - wordStart = lineWidth; - wordChars++; - } - else { - if (wordChars > 0) - wordEnd = lineWidth; - wordChars = 0; - } - if (cc == 32) { - glyphWidth = Math.ceil(this._fontSize / 2); - glyphHeight = this._fontSize; - } - else { - var glyph = this._bitmapFont.glyphs[ch]; - if (glyph) { - glyphWidth = Math.ceil(glyph.advance * fontScale); - glyphHeight = Math.ceil(glyph.lineHeight * fontScale); - } - else { - glyphWidth = 0; - glyphHeight = 0; - } - } - if (glyphHeight > lineTextHeight) - lineTextHeight = glyphHeight; - if (glyphHeight > lineHeight) - lineHeight = glyphHeight; - if (lineWidth != 0) - lineWidth += letterSpacing; - lineWidth += glyphWidth; - if (!wordWrap || lineWidth <= rectWidth) { - lineBuffer += ch; - } - else { - line = borrow(); - line.height = lineHeight; - line.textHeight = lineTextHeight; - if (lineBuffer.length == 0) { - line.text = ch; - } - else if (wordChars > 0 && wordEnd > 0) { - lineBuffer += ch; - var len = lineBuffer.length - wordChars; - line.text = fgui.ToolSet.trimRight(lineBuffer.substr(0, len)); - line.width = wordEnd; - lineBuffer = lineBuffer.substr(len); - lineWidth -= wordStart; - } - else { - line.text = lineBuffer; - line.width = lineWidth - (glyphWidth + letterSpacing); - lineBuffer = ch; - lineWidth = glyphWidth; - lineHeight = glyphHeight; - lineTextHeight = glyphHeight; - } - line.y = lineY; - lineY += (line.height + lineSpacing); - if (line.width > this._textWidth) - this._textWidth = line.width; - wordChars = 0; - wordStart = 0; - wordEnd = 0; - this._lines.push(line); - } - } - if (lineBuffer.length > 0) { - line = borrow(); - line.width = lineWidth; - if (lineHeight == 0) - lineHeight = lastLineHeight; - if (lineTextHeight == 0) - lineTextHeight = lineHeight; - line.height = lineHeight; - line.textHeight = lineTextHeight; - line.text = lineBuffer; - line.y = lineY; - if (line.width > this._textWidth) - this._textWidth = line.width; - this._lines.push(line); - } - if (this._textWidth > 0) - this._textWidth += GUTTER_X * 2; - var count = this._lines.length; - if (count == 0) { - this._textHeight = 0; - } - else { - line = this._lines[this._lines.length - 1]; - this._textHeight = line.y + line.height + GUTTER_Y; - } - var w, h = 0; - if (this._widthAutoSize) { - if (this._textWidth == 0) - w = 0; - else - w = this._textWidth; - } - else - w = this.width; - if (this._heightAutoSize) { - if (this._textHeight == 0) - h = 0; - else - h = this._textHeight; - } - else - h = this.height; - if (updateBounds) { - this._updatingSize = true; - this.setSize(w, h); - this._updatingSize = false; - } - if (w == 0 || h == 0) - return; - var charX = GUTTER_X; - var lineIndent = 0; - var charIndent = 0; - rectWidth = this.width - GUTTER_X * 2; - var lineCount = this._lines.length; - for (var i = 0; i < lineCount; i++) { - line = this._lines[i]; - charX = GUTTER_X; - if (this._align == fgui.AlignType.Center) - lineIndent = (rectWidth - line.width) / 2; - else if (this._align == fgui.AlignType.Right) - lineIndent = rectWidth - line.width; - else - lineIndent = 0; - textLength = line.text.length; - for (var j = 0; j < textLength; j++) { - ch = line.text.charAt(j); - cc = ch.charCodeAt(0); - if (cc == 10) - continue; - if (cc == 32) { - charX += letterSpacing + Math.ceil(this._fontSize / 2); - continue; - } - glyph = this._bitmapFont.glyphs[ch]; - if (glyph) { - charIndent = (line.height + line.textHeight) / 2 - Math.ceil(glyph.lineHeight * fontScale); - var bm; - if (this._bitmapPool.length) - bm = this._bitmapPool.pop(); - else { - bm = new egret.Bitmap(); - bm.smoothing = true; - } - bm.x = charX + lineIndent + Math.ceil(glyph.x * fontScale); - bm.y = line.y + charIndent + Math.ceil(glyph.y * fontScale); - bm["$backupY"] = bm.y; - bm.texture = glyph.texture; - bm.scaleX = fontScale; - bm.scaleY = fontScale; - if (tint) - bm.tint = this._color; - else - bm.tint = 0xFFFFFF; - this._bitmapContainer.addChild(bm); - charX += letterSpacing + Math.ceil(glyph.advance * fontScale); - } - else { - charX += letterSpacing; - } - } - } - this.doAlign(); - }; - GTextField.prototype.handleSizeChanged = function () { - if (this._updatingSize) - return; - if (this._bitmapFont) { - if (!this._widthAutoSize) - this.render(); - else - this.doAlign(); - } - else { - if (this._underConstruct) { - this._textField.width = this.width; - this._textField.height = this.height; - } - else { - if (!this._widthAutoSize) { - if (!this._heightAutoSize) { - this._textField.width = this.width; - this._textField.height = this.height; - } - else - this._textField.width = this.width; - } - } - } - }; - GTextField.prototype.parseTemplate = function (template) { - var pos1 = 0, pos2, pos3; - var tag; - var value; - var result = ""; - while ((pos2 = template.indexOf("{", pos1)) != -1) { - if (pos2 > 0 && template.charCodeAt(pos2 - 1) == 92) { - result += template.substring(pos1, pos2 - 1); - result += "{"; - pos1 = pos2 + 1; - continue; - } - result += template.substring(pos1, pos2); - pos1 = pos2; - pos2 = template.indexOf("}", pos1); - if (pos2 == -1) - break; - if (pos2 == pos1 + 1) { - result += template.substr(pos1, 2); - pos1 = pos2 + 1; - continue; - } - tag = template.substring(pos1 + 1, pos2); - pos3 = tag.indexOf("="); - if (pos3 != -1) { - value = this._templateVars[tag.substring(0, pos3)]; - if (value == null) - result += tag.substring(pos3 + 1); - else - result += value; - } - else { - value = this._templateVars[tag]; - if (value != null) - result += value; - } - pos1 = pos2 + 1; - } - if (pos1 < template.length) - result += template.substr(pos1); - return result; - }; - Object.defineProperty(GTextField.prototype, "templateVars", { - get: function () { - return this._templateVars; - }, - set: function (value) { - if (!this._templateVars && !value) - return; - this._templateVars = value; - this.flushVars(); - }, - enumerable: true, - configurable: true - }); - GTextField.prototype.setVar = function (name, value) { - if (!this._templateVars) - this._templateVars = {}; - this._templateVars[name] = value; - return this; - }; - GTextField.prototype.flushVars = function () { - this.render(); - }; - GTextField.prototype.handleGrayedChanged = function () { - _super_1.prototype.handleGrayedChanged.call(this); - this.updateTextFormat(); - }; - GTextField.prototype.doAlign = function () { - var yOffset; - if (this._verticalAlign == fgui.VertAlignType.Top || this._textHeight == 0) - yOffset = GUTTER_Y; - else { - var dh = this.height - this._textHeight; - if (dh < 0) - dh = 0; - if (this._verticalAlign == fgui.VertAlignType.Middle) - yOffset = Math.floor(dh / 2); - else - yOffset = Math.floor(dh); - } - var cnt = this._bitmapContainer.numChildren; - for (var i = 0; i < cnt; i++) { - var obj = this._bitmapContainer.getChildAt(i); - obj.y = obj["$backupY"] + yOffset; - } - }; - GTextField.prototype.getProp = function (index) { - switch (index) { - case fgui.ObjectPropID.Color: - return this.color; - case fgui.ObjectPropID.OutlineColor: - return this.strokeColor; - case fgui.ObjectPropID.FontSize: - return this.fontSize; - default: - return _super_1.prototype.getProp.call(this, index); - } - }; - GTextField.prototype.setProp = function (index, value) { - switch (index) { - case fgui.ObjectPropID.Color: - this.color = value; - break; - case fgui.ObjectPropID.OutlineColor: - this.strokeColor = value; - break; - case fgui.ObjectPropID.FontSize: - this.fontSize = value; - break; - default: - _super_1.prototype.setProp.call(this, index, value); - break; - } - }; - GTextField.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 5); - this._font = buffer.readS(); - this._fontSize = buffer.readShort(); - this._color = buffer.readColor(); - this.align = buffer.readByte(); - this.verticalAlign = buffer.readByte(); - this._leading = buffer.readShort(); - this._letterSpacing = buffer.readShort(); - this._ubbEnabled = buffer.readBool(); - this._autoSize = buffer.readByte(); - this._widthAutoSize = this._autoSize == fgui.AutoSizeType.Both; - this._heightAutoSize = this._autoSize == fgui.AutoSizeType.Both || this._autoSize == fgui.AutoSizeType.Height; - this._underline = buffer.readBool(); - this._textField.italic = buffer.readBool(); - this._textField.bold = buffer.readBool(); - this._textField.multiline = !buffer.readBool(); - if (buffer.readBool()) { - this._textField.strokeColor = buffer.readColor(); - this.stroke = buffer.readFloat() + 1; - } - if (buffer.readBool()) - buffer.skip(12); - if (buffer.readBool()) - this._templateVars = {}; - }; - GTextField.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - this.updateTextFormat(); - buffer.seek(beginPos, 6); - var str = buffer.readS(); - if (str != null) - this.text = str; - this._sizeDirty = false; - }; - GTextField._htmlParser = new egret.HtmlTextParser(); - return GTextField; - }(fgui.GObject)); - fgui.GTextField = GTextField; - var pool = []; - function borrow() { - if (pool.length) { - var ret = pool.pop(); - ret.width = 0; - ret.height = 0; - ret.textHeight = 0; - ret.text = null; - ret.y = 0; - return ret; - } - else - return { - width: 0, - height: 0, - textHeight: 0, - text: null, - y: 0 - }; - } - function returnList(value) { - var length = value.length; - for (var i = 0; i < length; i++) { - var li = value[i]; - pool.push(li); - } - value.length = 0; - } - var GUTTER_X = 2; - var GUTTER_Y = 2; -})(fgui || (fgui = {})); - -(function (fgui) { - var GRichTextField = (function (_super_1) { - __extends(GRichTextField, _super_1); - function GRichTextField() { - var _this = _super_1.call(this) || this; - _this._textField.touchEnabled = true; - return _this; - } - GRichTextField.prototype.updateTextFieldText = function () { - var text2 = this._text; - if (this._templateVars) - text2 = this.parseTemplate(text2); - var arr; - if (this._ubbEnabled) - arr = fgui.GTextField._htmlParser.parser(fgui.UBBParser.inst.parse(text2)); - else - arr = fgui.GTextField._htmlParser.parser(text2); - if (this._underline) { - for (var i = 0; i < arr.length; i++) { - var element = arr[i]; - if (element.style) - element.style.underline = true; - else - element.style = { underline: true }; - } - } - this._textField.textFlow = arr; - }; - return GRichTextField; - }(fgui.GTextField)); - fgui.GRichTextField = GRichTextField; -})(fgui || (fgui = {})); - -(function (fgui) { - var GRoot = (function (_super_1) { - __extends(GRoot, _super_1); - function GRoot() { - var _this = _super_1.call(this) || this; - if (GRoot._inst == null) - GRoot._inst = _this; - _this.opaque = false; - _this._volumeScale = 1; - _this._popupStack = new Array(); - _this._justClosedPopups = new Array(); - _this.displayObject.addEventListener(egret.Event.ADDED_TO_STAGE, _this.__addedToStage, _this); - return _this; - } - Object.defineProperty(GRoot, "inst", { - get: function () { - if (GRoot._inst == null) - new GRoot(); - return GRoot._inst; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GRoot.prototype, "nativeStage", { - get: function () { - return this._nativeStage; - }, - enumerable: true, - configurable: true - }); - GRoot.prototype.showWindow = function (win) { - this.addChild(win); - win.requestFocus(); - if (win.x > this.width) - win.x = this.width - win.width; - else if (win.x + win.width < 0) - win.x = 0; - if (win.y > this.height) - win.y = this.height - win.height; - else if (win.y + win.height < 0) - win.y = 0; - this.adjustModalLayer(); - }; - GRoot.prototype.hideWindow = function (win) { - win.hide(); - }; - GRoot.prototype.hideWindowImmediately = function (win) { - if (win.parent == this) - this.removeChild(win); - this.adjustModalLayer(); - }; - GRoot.prototype.bringToFront = function (win) { - var cnt = this.numChildren; - var i; - if (this._modalLayer.parent != null && !win.modal) - i = this.getChildIndex(this._modalLayer) - 1; - else - i = cnt - 1; - for (; i >= 0; i--) { - var g = this.getChildAt(i); - if (g == win) - return; - if (g instanceof fgui.Window) - break; - } - if (i >= 0) - this.setChildIndex(win, i); - }; - GRoot.prototype.showModalWait = function (msg) { - if (fgui.UIConfig.globalModalWaiting != null) { - if (this._modalWaitPane == null) - this._modalWaitPane = fgui.UIPackage.createObjectFromURL(fgui.UIConfig.globalModalWaiting); - this._modalWaitPane.setSize(this.width, this.height); - this._modalWaitPane.addRelation(this, fgui.RelationType.Size); - this.addChild(this._modalWaitPane); - this._modalWaitPane.text = msg; - } - }; - GRoot.prototype.closeModalWait = function () { - if (this._modalWaitPane != null && this._modalWaitPane.parent != null) - this.removeChild(this._modalWaitPane); - }; - GRoot.prototype.closeAllExceptModals = function () { - var arr = this._children.slice(); - var cnt = arr.length; - for (var i = 0; i < cnt; i++) { - var g = arr[i]; - if ((g instanceof fgui.Window) && !g.modal) - g.hide(); - } - }; - GRoot.prototype.closeAllWindows = function () { - var arr = this._children.slice(); - var cnt = arr.length; - for (var i = 0; i < cnt; i++) { - var g = arr[i]; - if (g instanceof fgui.Window) - g.hide(); - } - }; - GRoot.prototype.getTopWindow = function () { - var cnt = this.numChildren; - for (var i = cnt - 1; i >= 0; i--) { - var g = this.getChildAt(i); - if (g instanceof fgui.Window) { - return g; - } - } - return null; - }; - Object.defineProperty(GRoot.prototype, "modalLayer", { - get: function () { - return this._modalLayer; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GRoot.prototype, "hasModalWindow", { - get: function () { - return this._modalLayer.parent != null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GRoot.prototype, "modalWaiting", { - get: function () { - return this._modalWaitPane && this._modalWaitPane.inContainer; - }, - enumerable: true, - configurable: true - }); - GRoot.prototype.showPopup = function (popup, target, dir) { - if (this._popupStack.length > 0) { - var k = this._popupStack.indexOf(popup); - if (k != -1) { - for (var i = this._popupStack.length - 1; i >= k; i--) - this.removeChild(this._popupStack.pop()); - } - } - this._popupStack.push(popup); - if (target) { - var p = target; - while (p) { - if (p.parent == this) { - if (popup.sortingOrder < p.sortingOrder) { - popup.sortingOrder = p.sortingOrder; - } - break; - } - p = p.parent; - } - } - this.addChild(popup); - this.adjustModalLayer(); - var pos; - var sizeW = 0, sizeH = 0; - if (target) { - pos = target.localToRoot(); - sizeW = target.width; - sizeH = target.height; - } - else { - pos = this.globalToLocal(GRoot.mouseX, GRoot.mouseY); - } - var xx, yy; - xx = pos.x; - if (xx + popup.width > this.width) - xx = xx + sizeW - popup.width; - yy = pos.y + sizeH; - if (((dir === undefined || dir === fgui.PopupDirection.Auto) && pos.y + popup.height > this.height) - || dir === false || dir === fgui.PopupDirection.Up) { - yy = pos.y - popup.height - 1; - if (yy < 0) { - yy = 0; - xx += sizeW / 2; - } - } - popup.x = xx; - popup.y = yy; - }; - GRoot.prototype.togglePopup = function (popup, target, dir) { - if (this._justClosedPopups.indexOf(popup) != -1) - return; - this.showPopup(popup, target, dir); - }; - GRoot.prototype.hidePopup = function (popup) { - if (popup) { - var k = this._popupStack.indexOf(popup); - if (k != -1) { - for (var i = this._popupStack.length - 1; i >= k; i--) - this.closePopup(this._popupStack.pop()); - } - } - else { - var cnt = this._popupStack.length; - for (i = cnt - 1; i >= 0; i--) - this.closePopup(this._popupStack[i]); - this._popupStack.length = 0; - } - }; - Object.defineProperty(GRoot.prototype, "hasAnyPopup", { - get: function () { - return this._popupStack.length != 0; - }, - enumerable: true, - configurable: true - }); - GRoot.prototype.closePopup = function (target) { - if (target.parent) { - if (target instanceof fgui.Window) - target.hide(); - else - this.removeChild(target); - } - }; - GRoot.prototype.showTooltips = function (msg) { - if (this._defaultTooltipWin == null) { - var resourceURL = fgui.UIConfig.tooltipsWin; - if (!resourceURL) { - console.error("UIConfig.tooltipsWin not defined"); - return; - } - this._defaultTooltipWin = fgui.UIPackage.createObjectFromURL(resourceURL); - } - this._defaultTooltipWin.text = msg; - this.showTooltipsWin(this._defaultTooltipWin); - }; - GRoot.prototype.showTooltipsWin = function (tooltipWin, position) { - this.hideTooltips(); - this._tooltipWin = tooltipWin; - var xx = 0; - var yy = 0; - if (!position) { - xx = GRoot.mouseX + 10; - yy = GRoot.mouseY + 20; - } - else { - xx = position.x; - yy = position.y; - } - var pt = this.globalToLocal(xx, yy); - xx = pt.x; - yy = pt.y; - if (xx + this._tooltipWin.width > this.width) { - xx = xx - this._tooltipWin.width - 1; - if (xx < 0) - xx = 10; - } - if (yy + this._tooltipWin.height > this.height) { - yy = yy - this._tooltipWin.height - 1; - if (xx - this._tooltipWin.width - 1 > 0) - xx = xx - this._tooltipWin.width - 1; - if (yy < 0) - yy = 10; - } - this._tooltipWin.x = xx; - this._tooltipWin.y = yy; - this.addChild(this._tooltipWin); - }; - GRoot.prototype.hideTooltips = function () { - if (this._tooltipWin) { - if (this._tooltipWin.parent) - this.removeChild(this._tooltipWin); - this._tooltipWin = null; - } - }; - GRoot.prototype.getObjectUnderPoint = function (globalX, globalY) { - var ret = this._nativeStage.$hitTest(globalX, globalY); - if (ret) - return fgui.ToolSet.displayObjectToGObject(ret); - else - return null; - }; - Object.defineProperty(GRoot.prototype, "focus", { - get: function () { - return null; - }, - set: function (value) { - }, - enumerable: true, - configurable: true - }); - GRoot.prototype.setFocus = function (value) { - }; - Object.defineProperty(GRoot.prototype, "volumeScale", { - get: function () { - return this._volumeScale; - }, - set: function (value) { - this._volumeScale = value; - }, - enumerable: true, - configurable: true - }); - GRoot.prototype.playOneShotSound = function (sound, volumeScale) { - volumeScale = volumeScale || 1; - var vs = this._volumeScale * volumeScale; - var channel = sound.play(0, 1); - channel.volume = vs; - }; - GRoot.prototype.adjustModalLayer = function () { - var cnt = this.numChildren; - if (this._modalWaitPane && this._modalWaitPane.parent) - this.setChildIndex(this._modalWaitPane, cnt - 1); - for (var i = cnt - 1; i >= 0; i--) { - var g = this.getChildAt(i); - if ((g instanceof fgui.Window) && g.modal) { - if (this._modalLayer.parent == null) - this.addChildAt(this._modalLayer, i); - else - this.setChildIndexBefore(this._modalLayer, i); - return; - } - } - if (this._modalLayer.parent) - this.removeChild(this._modalLayer); - }; - GRoot.prototype.__addedToStage = function (evt) { - this.displayObject.removeEventListener(egret.Event.ADDED_TO_STAGE, this.__addedToStage, this); - this._nativeStage = this.displayObject.stage; - this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__stageMouseDownCapture, this, true); - this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_END, this.__stageMouseUpCapture, this, true); - this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__stageMouseMoveCapture, this, true); - this._modalLayer = new fgui.GGraph(); - this._modalLayer.setSize(this.width, this.height); - this._modalLayer.drawRect(0, 0, 0, fgui.UIConfig.modalLayerColor, fgui.UIConfig.modalLayerAlpha); - this._modalLayer.addRelation(this, fgui.RelationType.Size); - this.displayObject.stage.addEventListener(egret.Event.RESIZE, this.__winResize, this); - this.__winResize(null); - }; - GRoot.prototype.__stageMouseDownCapture = function (evt) { - GRoot.mouseX = evt.stageX; - GRoot.mouseY = evt.stageY; - GRoot.touchDown = true; - if (this._tooltipWin) - this.hideTooltips(); - this._justClosedPopups.length = 0; - if (this._popupStack.length > 0) { - var mc = (evt.target); - while (mc != this.displayObject.stage && mc) { - if (mc["$owner"]) { - var pindex = this._popupStack.indexOf(mc["$owner"]); - if (pindex != -1) { - for (var i = this._popupStack.length - 1; i > pindex; i--) { - var popup = this._popupStack.pop(); - this.closePopup(popup); - this._justClosedPopups.push(popup); - } - return; - } - } - mc = mc.parent; - } - var cnt = this._popupStack.length; - for (i = cnt - 1; i >= 0; i--) { - popup = this._popupStack[i]; - this.closePopup(popup); - this._justClosedPopups.push(popup); - } - this._popupStack.length = 0; - } - }; - GRoot.prototype.__stageMouseMoveCapture = function (evt) { - GRoot.mouseX = evt.stageX; - GRoot.mouseY = evt.stageY; - }; - GRoot.prototype.__stageMouseUpCapture = function (evt) { - GRoot.touchDown = false; - }; - GRoot.prototype.__winResize = function (evt) { - this.setSize(this._nativeStage.stageWidth, this._nativeStage.stageHeight); - }; - GRoot.prototype.updateContentScaleLevel = function () { - var ss = 1; - if (ss >= 3.5) - GRoot.contentScaleLevel = 3; - else if (ss >= 2.5) - GRoot.contentScaleLevel = 2; - else if (ss >= 1.5) - GRoot.contentScaleLevel = 1; - else - GRoot.contentScaleLevel = 0; - }; - GRoot.contentScaleLevel = 0; - GRoot.contentScaleFactor = 1; - return GRoot; - }(fgui.GComponent)); - fgui.GRoot = GRoot; -})(fgui || (fgui = {})); - -(function (fgui) { - var GScrollBar = (function (_super_1) { - __extends(GScrollBar, _super_1); - function GScrollBar() { - var _this = _super_1.call(this) || this; - _this._dragOffset = new egret.Point(); - _this._scrollPerc = 0; - return _this; - } - GScrollBar.prototype.setScrollPane = function (target, vertical) { - this._target = target; - this._vertical = vertical; - }; - GScrollBar.prototype.setDisplayPerc = function (value) { - if (this._vertical) { - if (!this._fixedGripSize) - this._grip.height = Math.floor(value * this._bar.height); - this._grip.y = this._bar.y + (this._bar.height - this._grip.height) * this._scrollPerc; - } - else { - if (!this._fixedGripSize) - this._grip.width = Math.floor(value * this._bar.width); - this._grip.x = this._bar.x + (this._bar.width - this._grip.width) * this._scrollPerc; - } - this._grip.visible = value != 0 && value != 1; - }; - GScrollBar.prototype.setScrollPerc = function (val) { - this._scrollPerc = val; - if (this._vertical) - this._grip.y = this._bar.y + (this._bar.height - this._grip.height) * this._scrollPerc; - else - this._grip.x = this._bar.x + (this._bar.width - this._grip.width) * this._scrollPerc; - }; - Object.defineProperty(GScrollBar.prototype, "minSize", { - get: function () { - if (this._vertical) - return (this._arrowButton1 ? this._arrowButton1.height : 0) + (this._arrowButton2 ? this._arrowButton2.height : 0); - else - return (this._arrowButton1 ? this._arrowButton1.width : 0) + (this._arrowButton2 ? this._arrowButton2.width : 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GScrollBar.prototype, "gripDragging", { - get: function () { - return this._gripDragging; - }, - enumerable: true, - configurable: true - }); - GScrollBar.prototype.constructExtension = function (buffer) { - buffer.seek(0, 6); - this._fixedGripSize = buffer.readBool(); - this._grip = this.getChild("grip"); - if (!this._grip) { - console.error("需要定义grip"); - return; - } - this._bar = this.getChild("bar"); - if (!this._bar) { - console.error("需要定义bar"); - return; - } - this._arrowButton1 = this.getChild("arrow1"); - this._arrowButton2 = this.getChild("arrow2"); - this._grip.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__gripMouseDown, this); - if (this._arrowButton1) - this._arrowButton1.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__arrowButton1Click, this); - if (this._arrowButton2) - this._arrowButton2.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__arrowButton2Click, this); - this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__barMouseDown, this); - }; - GScrollBar.prototype.__gripMouseDown = function (evt) { - this._gripDragging = true; - this._target.updateScrollBarVisible(); - evt.stopPropagation(); - this.globalToLocal(evt.stageX, evt.stageY, this._dragOffset); - this._dragOffset.x -= this._grip.x; - this._dragOffset.y -= this._grip.y; - this._grip.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__gripMouseMove, this); - this._grip.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.__gripMouseUp, this); - }; - GScrollBar.prototype.__gripMouseMove = function (evt) { - if (!this.onStage) - return; - var pt = this.globalToLocal(evt.stageX, evt.stageY, s_vec2); - if (this._vertical) { - var curY = pt.y - this._dragOffset.y; - this._target.setPercY((curY - this._bar.y) / (this._bar.height - this._grip.height), false); - } - else { - var curX = pt.x - this._dragOffset.x; - this._target.setPercX((curX - this._bar.x) / (this._bar.width - this._grip.width), false); - } - }; - GScrollBar.prototype.__gripMouseUp = function (evt) { - var st = evt.currentTarget; - st.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.__gripMouseMove, this); - st.removeEventListener(egret.TouchEvent.TOUCH_END, this.__gripMouseUp, this); - if (this.onStage) - return; - this._gripDragging = false; - this._target.updateScrollBarVisible(); - }; - GScrollBar.prototype.__arrowButton1Click = function (evt) { - evt.stopPropagation(); - if (this._vertical) - this._target.scrollUp(); - else - this._target.scrollLeft(); - }; - GScrollBar.prototype.__arrowButton2Click = function (evt) { - evt.stopPropagation(); - if (this._vertical) - this._target.scrollDown(); - else - this._target.scrollRight(); - }; - GScrollBar.prototype.__barMouseDown = function (evt) { - var pt = this._grip.globalToLocal(evt.stageX, evt.stageY, s_vec2); - if (this._vertical) { - if (pt.y < 0) - this._target.scrollUp(4); - else - this._target.scrollDown(4); - } - else { - if (pt.x < 0) - this._target.scrollLeft(4); - else - this._target.scrollRight(4); - } - }; - return GScrollBar; - }(fgui.GComponent)); - fgui.GScrollBar = GScrollBar; - var s_vec2 = new egret.Point(); -})(fgui || (fgui = {})); - -(function (fgui) { - var GSlider = (function (_super_1) { - __extends(GSlider, _super_1); - function GSlider() { - var _this = _super_1.call(this) || this; - _this._min = 0; - _this._max = 0; - _this._value = 0; - _this._barMaxWidth = 0; - _this._barMaxHeight = 0; - _this._barMaxWidthDelta = 0; - _this._barMaxHeightDelta = 0; - _this._clickPercent = 0; - _this._barStartX = 0; - _this._barStartY = 0; - _this.changeOnClick = true; - _this.canDrag = true; - _this._titleType = fgui.ProgressTitleType.Percent; - _this._value = 50; - _this._max = 100; - _this._clickPos = new egret.Point(); - return _this; - } - Object.defineProperty(GSlider.prototype, "titleType", { - get: function () { - return this._titleType; - }, - set: function (value) { - this._titleType = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GSlider.prototype, "wholeNumbers", { - get: function () { - return this._wholeNumbers; - }, - set: function (value) { - if (this._wholeNumbers != value) { - this._wholeNumbers = value; - this.update(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GSlider.prototype, "min", { - get: function () { - return this._min; - }, - set: function (value) { - if (this._min != value) { - this._min = value; - this.update(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GSlider.prototype, "max", { - get: function () { - return this._max; - }, - set: function (value) { - if (this._max != value) { - this._max = value; - this.update(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GSlider.prototype, "value", { - get: function () { - return this._value; - }, - set: function (value) { - if (this._value != value) { - this._value = value; - this.update(); - } - }, - enumerable: true, - configurable: true - }); - GSlider.prototype.update = function () { - this.updateWithPercent((this._value - this._min) / (this._max - this._min)); - }; - GSlider.prototype.updateWithPercent = function (percent, manual) { - percent = fgui.ToolSet.clamp01(percent); - if (manual) { - var newValue = fgui.ToolSet.clamp(this._min + (this._max - this._min) * percent, this._min, this._max); - if (this._wholeNumbers) { - newValue = Math.round(newValue); - percent = fgui.ToolSet.clamp01((newValue - this._min) / (this._max - this._min)); - } - if (newValue != this._value) { - this._value = newValue; - this.dispatchEvent(new fgui.StateChangeEvent(fgui.StateChangeEvent.CHANGED)); - } - } - if (this._titleObject) { - switch (this._titleType) { - case fgui.ProgressTitleType.Percent: - this._titleObject.text = Math.floor(percent * 100) + "%"; - break; - case fgui.ProgressTitleType.ValueAndMax: - this._titleObject.text = this._value + "/" + this._max; - break; - case fgui.ProgressTitleType.Value: - this._titleObject.text = "" + this._value; - break; - case fgui.ProgressTitleType.Max: - this._titleObject.text = "" + this._max; - break; - } - } - var fullWidth = this.width - this._barMaxWidthDelta; - var fullHeight = this.height - this._barMaxHeightDelta; - if (!this._reverse) { - if (this._barObjectH) - this._barObjectH.width = Math.round(fullWidth * percent); - if (this._barObjectV) - this._barObjectV.height = Math.round(fullHeight * percent); - } - else { - if (this._barObjectH) { - this._barObjectH.width = Math.round(fullWidth * percent); - this._barObjectH.x = this._barStartX + (fullWidth - this._barObjectH.width); - } - if (this._barObjectV) { - this._barObjectV.height = Math.round(fullHeight * percent); - this._barObjectV.y = this._barStartY + (fullHeight - this._barObjectV.height); - } - } - }; - GSlider.prototype.constructExtension = function (buffer) { - buffer.seek(0, 6); - this._titleType = buffer.readByte(); - this._reverse = buffer.readBool(); - if (buffer.version >= 2) { - this._wholeNumbers = buffer.readBool(); - this.changeOnClick = buffer.readBool(); - } - this._titleObject = (this.getChild("title")); - this._barObjectH = this.getChild("bar"); - this._barObjectV = this.getChild("bar_v"); - this._gripObject = this.getChild("grip"); - if (this._barObjectH) { - this._barMaxWidth = this._barObjectH.width; - this._barMaxWidthDelta = this.width - this._barMaxWidth; - this._barStartX = this._barObjectH.x; - } - if (this._barObjectV) { - this._barMaxHeight = this._barObjectV.height; - this._barMaxHeightDelta = this.height - this._barMaxHeight; - this._barStartY = this._barObjectV.y; - } - if (this._gripObject) { - this._gripObject.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__gripMouseDown, this); - } - this.displayObject.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__barMouseDown, this); - }; - GSlider.prototype.handleSizeChanged = function () { - _super_1.prototype.handleSizeChanged.call(this); - if (this._barObjectH) - this._barMaxWidth = this.width - this._barMaxWidthDelta; - if (this._barObjectV) - this._barMaxHeight = this.height - this._barMaxHeightDelta; - if (!this._underConstruct) - this.update(); - }; - GSlider.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!buffer.seek(beginPos, 6)) { - this.update(); - return; - } - if (buffer.readByte() != this.packageItem.objectType) { - this.update(); - return; - } - this._value = buffer.readInt(); - this._max = buffer.readInt(); - if (buffer.version >= 2) - this._min = buffer.readInt(); - this.update(); - }; - GSlider.prototype.__gripMouseDown = function (evt) { - this.canDrag = true; - evt.stopPropagation(); - this._clickPos = this.globalToLocal(evt.stageX, evt.stageY); - this._clickPercent = fgui.ToolSet.clamp01((this._value - this._min) / (this._max - this._min)); - this._gripObject.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__gripMouseMove, this); - this._gripObject.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.__gripMouseUp, this); - }; - GSlider.prototype.__gripMouseMove = function (evt) { - if (!this.canDrag) { - return; - } - var pt = this.globalToLocal(evt.stageX, evt.stageY, s_vec2); - var deltaX = pt.x - this._clickPos.x; - var deltaY = pt.y - this._clickPos.y; - if (this._reverse) { - deltaX = -deltaX; - deltaY = -deltaY; - } - var percent; - if (this._barObjectH) - percent = this._clickPercent + deltaX / this._barMaxWidth; - else - percent = this._clickPercent + deltaY / this._barMaxHeight; - this.updateWithPercent(percent, true); - }; - GSlider.prototype.__gripMouseUp = function (evt) { - evt.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.__gripMouseMove, this); - evt.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END, this.__gripMouseUp, this); - }; - GSlider.prototype.__barMouseDown = function (evt) { - if (!this.changeOnClick) - return; - var pt = this._gripObject.globalToLocal(evt.stageX, evt.stageY, s_vec2); - var percent = fgui.ToolSet.clamp01((this._value - this._min) / (this._max - this._min)); - var delta; - if (this._barObjectH) - delta = pt.x / this._barMaxWidth; - if (this._barObjectV) - delta = pt.y / this._barMaxHeight; - if (this._reverse) - percent -= delta; - else - percent += delta; - this.updateWithPercent(percent, true); - }; - return GSlider; - }(fgui.GComponent)); - fgui.GSlider = GSlider; - var s_vec2 = new egret.Point(); -})(fgui || (fgui = {})); - -(function (fgui) { - var GTextInput = (function (_super_1) { - __extends(GTextInput, _super_1); - function GTextInput() { - var _this = _super_1.call(this) || this; - _this._widthAutoSize = false; - _this._heightAutoSize = false; - _this.displayObject.touchChildren = true; - _this._textField.type = egret.TextFieldType.INPUT; - _this._textField.addEventListener(egret.Event.CHANGE, _this.__textChanged, _this); - _this._textField.addEventListener(egret.FocusEvent.FOCUS_IN, _this.__focusIn, _this); - _this._textField.addEventListener(egret.FocusEvent.FOCUS_OUT, _this.__focusOut, _this); - return _this; - } - GTextInput.prototype.dispose = function () { - _super_1.prototype.dispose.call(this); - }; - Object.defineProperty(GTextInput.prototype, "editable", { - get: function () { - return this._textField.type == egret.TextFieldType.INPUT; - }, - set: function (val) { - if (val) - this._textField.type = egret.TextFieldType.INPUT; - else - this._textField.type = egret.TextFieldType.DYNAMIC; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextInput.prototype, "maxLength", { - get: function () { - return this._textField.maxChars; - }, - set: function (val) { - this._textField.maxChars = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextInput.prototype, "promptText", { - get: function () { - return this._promptText; - }, - set: function (val) { - this._promptText = val; - this.updateTextFieldText(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextInput.prototype, "restrict", { - get: function () { - return this._textField.restrict; - }, - set: function (value) { - this._textField.restrict = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextInput.prototype, "password", { - get: function () { - return this._password; - }, - set: function (val) { - if (this._password != val) { - this._password = val; - this._textField.displayAsPassword = this._password; - if (val) - this._textField.inputType = egret.TextFieldInputType.PASSWORD; - else - this._textField.inputType = egret.TextFieldInputType.TEXT; - this.render(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTextInput.prototype, "verticalAlign", { - get: function () { - return this._verticalAlign; - }, - set: function (value) { - if (this._verticalAlign != value) { - this._verticalAlign = value; - this.updateVertAlign(); - } - }, - enumerable: true, - configurable: true - }); - GTextInput.prototype.updateVertAlign = function () { - switch (this._verticalAlign) { - case fgui.VertAlignType.Top: - this._textField.verticalAlign = egret.VerticalAlign.TOP; - break; - case fgui.VertAlignType.Middle: - this._textField.verticalAlign = egret.VerticalAlign.MIDDLE; - break; - case fgui.VertAlignType.Bottom: - this._textField.verticalAlign = egret.VerticalAlign.BOTTOM; - break; - } - }; - GTextInput.prototype.updateTextFieldText = function () { - if (!this._text && this._promptText) { - this._textField.displayAsPassword = false; - this._textField.textFlow = (new egret.HtmlTextParser).parser(fgui.UBBParser.inst.parse(this._promptText)); - } - else { - this._textField.displayAsPassword = this._password; - if (this._ubbEnabled) - this._textField.textFlow = (new egret.HtmlTextParser).parser(fgui.UBBParser.inst.parse(fgui.ToolSet.encodeHTML(this._text))); - else - this._textField.text = this._text; - } - }; - GTextInput.prototype.handleSizeChanged = function () { - if (!this._updatingSize) { - this._textField.width = Math.ceil(this.width); - this._textField.height = Math.ceil(this.height); - } - }; - GTextInput.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 4); - var str = buffer.readS(); - if (str != null) - this._promptText = str; - str = buffer.readS(); - if (str != null) - this._textField.restrict = str; - var iv = buffer.readInt(); - if (iv != 0) - this._textField.maxChars = iv; - iv = buffer.readInt(); - if (iv != 0) { - } - if (buffer.readBool()) - this.password = true; - this.updateVertAlign(); - }; - GTextInput.prototype.setup_afterAdd = function (buffer, beginPos) { - _super_1.prototype.setup_afterAdd.call(this, buffer, beginPos); - if (!this._text && this._promptText) { - this._textField.displayAsPassword = false; - this._textField.textFlow = (new egret.HtmlTextParser).parser(fgui.UBBParser.inst.parse(fgui.ToolSet.encodeHTML(this._promptText))); - } - }; - GTextInput.prototype.__textChanged = function (evt) { - this._text = this._textField.text; - }; - GTextInput.prototype.__focusIn = function (evt) { - if (!this._text && this._promptText) { - this._textField.displayAsPassword = this._password; - this._textField.text = ""; - } - }; - GTextInput.prototype.__focusOut = function (evt) { - this._text = this._textField.text; - if (!this._text && this._promptText) { - this._textField.displayAsPassword = false; - this._textField.textFlow = (new egret.HtmlTextParser).parser(fgui.UBBParser.inst.parse(fgui.ToolSet.encodeHTML(this._promptText))); - } - }; - return GTextInput; - }(fgui.GTextField)); - fgui.GTextInput = GTextInput; -})(fgui || (fgui = {})); - -(function (fgui) { - var GTree = (function (_super_1) { - __extends(GTree, _super_1); - function GTree() { - var _this = _super_1.call(this) || this; - _this._indent = 15; - _this._rootNode = new fgui.GTreeNode(true); - _this._rootNode._setTree(_this); - _this._rootNode.expanded = true; - return _this; - } - Object.defineProperty(GTree.prototype, "rootNode", { - get: function () { - return this._rootNode; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTree.prototype, "indent", { - get: function () { - return this._indent; - }, - set: function (value) { - this._indent = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTree.prototype, "clickToExpand", { - get: function () { - return this._clickToExpand; - }, - set: function (value) { - this._clickToExpand = value; - }, - enumerable: true, - configurable: true - }); - GTree.prototype.getSelectedNode = function () { - if (this.selectedIndex != -1) - return this.getChildAt(this.selectedIndex)._treeNode; - else - return null; - }; - GTree.prototype.getSelectedNodes = function (result) { - if (!result) - result = new Array(); - s_list.length = 0; - _super_1.prototype.getSelection.call(this, s_list); - var cnt = s_list.length; - var ret = new Array(); - for (var i = 0; i < cnt; i++) { - var node = this.getChildAt(s_list[i])._treeNode; - ret.push(node); - } - return ret; - }; - GTree.prototype.selectNode = function (node, scrollItToView) { - var parentNode = node.parent; - while (parentNode && parentNode != this._rootNode) { - parentNode.expanded = true; - parentNode = parentNode.parent; - } - if (!node._cell) - return; - this.addSelection(this.getChildIndex(node._cell), scrollItToView); - }; - GTree.prototype.unselectNode = function (node) { - if (!node._cell) - return; - this.removeSelection(this.getChildIndex(node._cell)); - }; - GTree.prototype.expandAll = function (folderNode) { - if (!folderNode) - folderNode = this._rootNode; - folderNode.expanded = true; - var cnt = folderNode.numChildren; - for (var i = 0; i < cnt; i++) { - var node = folderNode.getChildAt(i); - if (node.isFolder) - this.expandAll(node); - } - }; - GTree.prototype.collapseAll = function (folderNode) { - if (!folderNode) - folderNode = this._rootNode; - if (folderNode != this._rootNode) - folderNode.expanded = false; - var cnt = folderNode.numChildren; - for (var i = 0; i < cnt; i++) { - var node = folderNode.getChildAt(i); - if (node.isFolder) - this.collapseAll(node); - } - }; - GTree.prototype.createCell = function (node) { - var child = this.getFromPool(node._resURL ? node._resURL : this.defaultItem); - if (!(child instanceof fgui.GComponent)) - throw new Error("cannot create tree node object."); - child._treeNode = node; - node._cell = child; - var indentObj = child.getChild("indent"); - if (indentObj != null) - indentObj.width = (node.level - 1) * this._indent; - var cc; - cc = child.getController("expanded"); - if (cc) { - cc.addEventListener(fgui.StateChangeEvent.CHANGED, this.__expandedStateChanged, this); - cc.selectedIndex = node.expanded ? 1 : 0; - } - cc = child.getController("leaf"); - if (cc) - cc.selectedIndex = node.isFolder ? 0 : 1; - if (node.isFolder) - child.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.__cellMouseDown, this); - if (this.treeNodeRender) - this.treeNodeRender.call(this.callbackThisObj, node, child); - }; - GTree.prototype._afterInserted = function (node) { - if (!node._cell) - this.createCell(node); - var index = this.getInsertIndexForNode(node); - this.addChildAt(node._cell, index); - if (this.treeNodeRender) - this.treeNodeRender.call(this.callbackThisObj, node, node._cell); - if (node.isFolder && node.expanded) - this.checkChildren(node, index); - }; - GTree.prototype.getInsertIndexForNode = function (node) { - var prevNode = node.getPrevSibling(); - if (prevNode == null) - prevNode = node.parent; - var insertIndex = this.getChildIndex(prevNode._cell) + 1; - var myLevel = node.level; - var cnt = this.numChildren; - for (var i = insertIndex; i < cnt; i++) { - var testNode = this.getChildAt(i)._treeNode; - if (testNode.level <= myLevel) - break; - insertIndex++; - } - return insertIndex; - }; - GTree.prototype._afterRemoved = function (node) { - this.removeNode(node); - }; - GTree.prototype._afterExpanded = function (node) { - if (node == this._rootNode) { - this.checkChildren(this._rootNode, 0); - return; - } - if (this.treeNodeWillExpand != null) - this.treeNodeWillExpand.call(this.callbackThisObj, node, true); - if (node._cell == null) - return; - if (this.treeNodeRender) - this.treeNodeRender.call(this.callbackThisObj, node, node._cell); - var cc = node._cell.getController("expanded"); - if (cc) - cc.selectedIndex = 1; - if (node._cell.parent) - this.checkChildren(node, this.getChildIndex(node._cell)); - }; - GTree.prototype._afterCollapsed = function (node) { - if (node == this._rootNode) { - this.checkChildren(this._rootNode, 0); - return; - } - if (this.treeNodeWillExpand) - this.treeNodeWillExpand.call(this.callbackThisObj, node, false); - if (node._cell == null) - return; - if (this.treeNodeRender) - this.treeNodeRender.call(this.callbackThisObj, node, node._cell); - var cc = node._cell.getController("expanded"); - if (cc) - cc.selectedIndex = 0; - if (node._cell.parent) - this.hideFolderNode(node); - }; - GTree.prototype._afterMoved = function (node) { - var startIndex = this.getChildIndex(node._cell); - var endIndex; - if (node.isFolder) - endIndex = this.getFolderEndIndex(startIndex, node.level); - else - endIndex = startIndex + 1; - var insertIndex = this.getInsertIndexForNode(node); - var i; - var cnt = endIndex - startIndex; - var obj; - if (insertIndex < startIndex) { - for (i = 0; i < cnt; i++) { - obj = this.getChildAt(startIndex + i); - this.setChildIndex(obj, insertIndex + i); - } - } - else { - for (i = 0; i < cnt; i++) { - obj = this.getChildAt(startIndex); - this.setChildIndex(obj, insertIndex); - } - } - }; - GTree.prototype.getFolderEndIndex = function (startIndex, level) { - var cnt = this.numChildren; - for (var i = startIndex + 1; i < cnt; i++) { - var node = this.getChildAt(i)._treeNode; - if (node.level <= level) - return i; - } - return cnt; - }; - GTree.prototype.checkChildren = function (folderNode, index) { - var cnt = folderNode.numChildren; - for (var i = 0; i < cnt; i++) { - index++; - var node = folderNode.getChildAt(i); - if (node._cell == null) - this.createCell(node); - if (!node._cell.parent) - this.addChildAt(node._cell, index); - if (node.isFolder && node.expanded) - index = this.checkChildren(node, index); - } - return index; - }; - GTree.prototype.hideFolderNode = function (folderNode) { - var cnt = folderNode.numChildren; - for (var i = 0; i < cnt; i++) { - var node = folderNode.getChildAt(i); - if (node._cell) - this.removeChild(node._cell); - if (node.isFolder && node.expanded) - this.hideFolderNode(node); - } - }; - GTree.prototype.removeNode = function (node) { - if (node._cell) { - if (node._cell.parent) - this.removeChild(node._cell); - this.returnToPool(node._cell); - node._cell._treeNode = null; - node._cell = null; - } - if (node.isFolder) { - var cnt = node.numChildren; - for (var i = 0; i < cnt; i++) { - var node2 = node.getChildAt(i); - this.removeNode(node2); - } - } - }; - GTree.prototype.__cellMouseDown = function (evt) { - var node = evt.currentTarget._treeNode; - this._expandedStatusInEvt = node.expanded; - }; - GTree.prototype.__expandedStateChanged = function (evt) { - var cc = evt.currentTarget; - var node = cc.parent._treeNode; - node.expanded = cc.selectedIndex == 1; - }; - GTree.prototype.dispatchItemEvent = function (evt) { - if (this._clickToExpand != 0) { - var node = evt.itemObject._treeNode; - if (node && node.isFolder && this._expandedStatusInEvt == node.expanded) { - if (this._clickToExpand == 2) { - } - else - node.expanded = !node.expanded; - } - } - _super_1.prototype.dispatchItemEvent.call(this, evt); - }; - GTree.prototype.setup_beforeAdd = function (buffer, beginPos) { - _super_1.prototype.setup_beforeAdd.call(this, buffer, beginPos); - buffer.seek(beginPos, 9); - this._indent = buffer.readInt(); - this._clickToExpand = buffer.readByte(); - }; - GTree.prototype.readItems = function (buffer) { - var cnt; - var i; - var nextPos; - var str; - var isFolder; - var lastNode; - var level; - var prevLevel = 0; - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - str = buffer.readS(); - if (str == null) { - str = this.defaultItem; - if (!str) { - buffer.position = nextPos; - continue; - } - } - isFolder = buffer.readBool(); - level = buffer.readByte(); - var node = new fgui.GTreeNode(isFolder, str); - node.expanded = true; - if (i == 0) - this._rootNode.addChild(node); - else { - if (level > prevLevel) - lastNode.addChild(node); - else if (level < prevLevel) { - for (var j = level; j <= prevLevel; j++) - lastNode = lastNode.parent; - lastNode.addChild(node); - } - else - lastNode.parent.addChild(node); - } - lastNode = node; - prevLevel = level; - this.setupItem(buffer, node.cell); - buffer.position = nextPos; - } - }; - return GTree; - }(fgui.GList)); - fgui.GTree = GTree; - var s_list = new Array(); -})(fgui || (fgui = {})); - -(function (fgui) { - var GTreeNode = (function () { - function GTreeNode(hasChild, resURL) { - this._level = 0; - this._resURL = resURL; - if (hasChild) - this._children = new Array(); - } - Object.defineProperty(GTreeNode.prototype, "expanded", { - get: function () { - return this._expanded; - }, - set: function (value) { - if (!this._children) - return; - if (this._expanded != value) { - this._expanded = value; - if (this._tree) { - if (this._expanded) - this._tree._afterExpanded(this); - else - this._tree._afterCollapsed(this); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "isFolder", { - get: function () { - return this._children != null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "parent", { - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "text", { - get: function () { - if (this._cell) - return this._cell.text; - else - return null; - }, - set: function (value) { - if (this._cell) - this._cell.text = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "icon", { - get: function () { - if (this._cell) - return this._cell.icon; - else - return null; - }, - set: function (value) { - if (this._cell) - this._cell.icon = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "cell", { - get: function () { - return this._cell; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTreeNode.prototype, "level", { - get: function () { - return this._level; - }, - enumerable: true, - configurable: true - }); - GTreeNode.prototype._setLevel = function (value) { - this._level = value; - }; - GTreeNode.prototype.addChild = function (child) { - this.addChildAt(child, this._children.length); - return child; - }; - GTreeNode.prototype.addChildAt = function (child, index) { - if (!child) - throw new Error("child is null"); - var numChildren = this._children.length; - if (index >= 0 && index <= numChildren) { - if (child._parent == this) { - this.setChildIndex(child, index); - } - else { - if (child._parent) - child._parent.removeChild(child); - var cnt = this._children.length; - if (index == cnt) - this._children.push(child); - else - this._children.splice(index, 0, child); - child._parent = this; - child._level = this._level + 1; - child._setTree(this._tree); - if (this._tree && this == this._tree.rootNode || this._cell && this._cell.parent && this._expanded) - this._tree._afterInserted(child); - } - return child; - } - else { - throw new RangeError("Invalid child index"); - } - }; - GTreeNode.prototype.removeChild = function (child) { - var childIndex = this._children.indexOf(child); - if (childIndex != -1) { - this.removeChildAt(childIndex); - } - return child; - }; - GTreeNode.prototype.removeChildAt = function (index) { - if (index >= 0 && index < this.numChildren) { - var child = this._children[index]; - this._children.splice(index, 1); - child._parent = null; - if (this._tree) { - child._setTree(null); - this._tree._afterRemoved(child); - } - return child; - } - else { - throw "Invalid child index"; - } - }; - GTreeNode.prototype.removeChildren = function (beginIndex, endIndex) { - beginIndex = beginIndex || 0; - if (endIndex == null) - endIndex = -1; - if (endIndex < 0 || endIndex >= this.numChildren) - endIndex = this.numChildren - 1; - for (var i = beginIndex; i <= endIndex; ++i) - this.removeChildAt(beginIndex); - }; - GTreeNode.prototype.getChildAt = function (index) { - if (index >= 0 && index < this.numChildren) - return this._children[index]; - else - throw "Invalid child index"; - }; - GTreeNode.prototype.getChildIndex = function (child) { - return this._children.indexOf(child); - }; - GTreeNode.prototype.getPrevSibling = function () { - if (this._parent == null) - return null; - var i = this._parent._children.indexOf(this); - if (i <= 0) - return null; - return this._parent._children[i - 1]; - }; - GTreeNode.prototype.getNextSibling = function () { - if (this._parent == null) - return null; - var i = this._parent._children.indexOf(this); - if (i < 0 || i >= this._parent._children.length - 1) - return null; - return this._parent._children[i + 1]; - }; - GTreeNode.prototype.setChildIndex = function (child, index) { - var oldIndex = this._children.indexOf(child); - if (oldIndex == -1) - throw "Not a child of this container"; - var cnt = this._children.length; - if (index < 0) - index = 0; - else if (index > cnt) - index = cnt; - if (oldIndex == index) - return; - this._children.splice(oldIndex, 1); - this._children.splice(index, 0, child); - if (this._tree && this == this._tree.rootNode || this._cell && this._cell.parent && this._expanded) - this._tree._afterMoved(child); - }; - GTreeNode.prototype.swapChildren = function (child1, child2) { - var index1 = this._children.indexOf(child1); - var index2 = this._children.indexOf(child2); - if (index1 == -1 || index2 == -1) - throw "Not a child of this container"; - this.swapChildrenAt(index1, index2); - }; - GTreeNode.prototype.swapChildrenAt = function (index1, index2) { - var child1 = this._children[index1]; - var child2 = this._children[index2]; - this.setChildIndex(child1, index2); - this.setChildIndex(child2, index1); - }; - Object.defineProperty(GTreeNode.prototype, "numChildren", { - get: function () { - return this._children.length; - }, - enumerable: true, - configurable: true - }); - GTreeNode.prototype.expandToRoot = function () { - var p = this; - while (p) { - p.expanded = true; - p = p.parent; - } - }; - Object.defineProperty(GTreeNode.prototype, "tree", { - get: function () { - return this._tree; - }, - enumerable: true, - configurable: true - }); - GTreeNode.prototype._setTree = function (value) { - this._tree = value; - if (this._tree && this._tree.treeNodeWillExpand && this._expanded) - this._tree.treeNodeWillExpand(this, true); - if (this._children) { - var cnt = this._children.length; - for (var i = 0; i < cnt; i++) { - var node = this._children[i]; - node._level = this._level + 1; - node._setTree(value); - } - } - }; - return GTreeNode; - }()); - fgui.GTreeNode = GTreeNode; -})(fgui || (fgui = {})); - -(function (fgui) { - var Margin = (function () { - function Margin() { - this.left = 0; - this.right = 0; - this.top = 0; - this.bottom = 0; - } - Margin.prototype.copy = function (source) { - this.top = source.top; - this.bottom = source.bottom; - this.left = source.left; - this.right = source.right; - }; - return Margin; - }()); - fgui.Margin = Margin; -})(fgui || (fgui = {})); - -(function (fgui) { - var PixelHitTest = (function () { - function PixelHitTest(data, offsetX, offsetY) { - this._data = data; - this.offsetX = offsetX; - this.offsetY = offsetY; - this.scaleX = 1; - this.scaleY = 1; - } - PixelHitTest.prototype.contains = function (x, y) { - x = Math.floor((x / this.scaleX - this.offsetX) * this._data.scale); - y = Math.floor((y / this.scaleY - this.offsetY) * this._data.scale); - if (x < 0 || y < 0 || x >= this._data.pixelWidth) - return false; - var pos = y * this._data.pixelWidth + x; - var pos2 = Math.floor(pos / 8); - var pos3 = pos % 8; - if (pos2 >= 0 && pos2 < this._data.pixels.length) - return ((this._data.pixels[pos2] >> pos3) & 0x1) == 1; - else - return false; - }; - return PixelHitTest; - }()); - fgui.PixelHitTest = PixelHitTest; - var PixelHitTestData = (function () { - function PixelHitTestData() { - } - PixelHitTestData.prototype.load = function (ba) { - ba.readInt(); - this.pixelWidth = ba.readInt(); - this.scale = 1 / ba.readByte(); - var len = ba.readInt(); - this.pixels = []; - for (var i = 0; i < len; i++) { - var j = ba.readByte(); - if (j < 0) - j += 256; - this.pixels[i] = j; - } - }; - return PixelHitTestData; - }()); - fgui.PixelHitTestData = PixelHitTestData; -})(fgui || (fgui = {})); - -(function (fgui) { - var PackageItem = (function () { - function PackageItem() { - this.width = 0; - this.height = 0; - } - PackageItem.prototype.load = function () { - return this.owner.getItemAsset(this); - }; - PackageItem.prototype.getBranch = function () { - if (this.branches && this.owner._branchIndex != -1) { - var itemId = this.branches[this.owner._branchIndex]; - if (itemId) - return this.owner.getItemById(itemId); - } - return this; - }; - PackageItem.prototype.getHighResolution = function () { - if (this.highResolution && fgui.GRoot.contentScaleLevel > 0) { - var itemId = this.highResolution[fgui.GRoot.contentScaleLevel - 1]; - if (itemId) - return this.owner.getItemById(itemId); - } - return this; - }; - PackageItem.prototype.toString = function () { - return this.name; - }; - return PackageItem; - }()); - fgui.PackageItem = PackageItem; -})(fgui || (fgui = {})); - -(function (fgui) { - var PopupMenu = (function () { - function PopupMenu(resourceURL) { - if (!resourceURL) { - resourceURL = fgui.UIConfig.popupMenu; - if (!resourceURL) - throw "UIConfig.popupMenu not defined"; - } - this._contentPane = fgui.UIPackage.createObjectFromURL(resourceURL).asCom; - this._contentPane.addEventListener(egret.Event.ADDED_TO_STAGE, this.__addedToStage, this); - this._list = (this._contentPane.getChild("list")); - this._list.removeChildrenToPool(); - this._list.addRelation(this._contentPane, fgui.RelationType.Width); - this._list.removeRelation(this._contentPane, fgui.RelationType.Height); - this._contentPane.addRelation(this._list, fgui.RelationType.Height); - this._list.addEventListener(fgui.ItemEvent.CLICK, this.__clickItem, this); - } - PopupMenu.prototype.dispose = function () { - this._contentPane.dispose(); - }; - PopupMenu.prototype.addItem = function (caption, callback) { - var item = this._list.addItemFromPool().asButton; - item.title = caption; - item.data = callback; - item.grayed = false; - var c = item.getController("checked"); - if (c) - c.selectedIndex = 0; - return item; - }; - PopupMenu.prototype.addItemAt = function (caption, index, callback) { - var item = this._list.getFromPool().asButton; - this._list.addChildAt(item, index); - item.title = caption; - item.data = callback; - item.grayed = false; - var c = item.getController("checked"); - if (c) - c.selectedIndex = 0; - return item; - }; - PopupMenu.prototype.addSeperator = function () { - if (fgui.UIConfig.popupMenu_seperator == null) - throw "UIConfig.popupMenu_seperator not defined"; - this.list.addItemFromPool(fgui.UIConfig.popupMenu_seperator); - }; - PopupMenu.prototype.getItemName = function (index) { - var item = this._list.getChildAt(index); - return item.name; - }; - PopupMenu.prototype.setItemText = function (name, caption) { - var item = this._list.getChild(name).asButton; - item.title = caption; - }; - PopupMenu.prototype.setItemVisible = function (name, visible) { - var item = this._list.getChild(name).asButton; - if (item.visible != visible) { - item.visible = visible; - this._list.setBoundsChangedFlag(); - } - }; - PopupMenu.prototype.setItemGrayed = function (name, grayed) { - var item = this._list.getChild(name).asButton; - item.grayed = grayed; - }; - PopupMenu.prototype.setItemCheckable = function (name, checkable) { - var item = this._list.getChild(name).asButton; - var c = item.getController("checked"); - if (c) { - if (checkable) { - if (c.selectedIndex == 0) - c.selectedIndex = 1; - } - else - c.selectedIndex = 0; - } - }; - PopupMenu.prototype.setItemChecked = function (name, checked) { - var item = this._list.getChild(name).asButton; - var c = item.getController("checked"); - if (c) - c.selectedIndex = checked ? 2 : 1; - }; - PopupMenu.prototype.isItemChecked = function (name) { - var item = this._list.getChild(name).asButton; - var c = item.getController("checked"); - if (c) - return c.selectedIndex == 2; - else - return false; - }; - PopupMenu.prototype.removeItem = function (name) { - var item = this._list.getChild(name); - if (item) { - var index = this._list.getChildIndex(item); - this._list.removeChildToPoolAt(index); - return true; - } - else - return false; - }; - PopupMenu.prototype.clearItems = function () { - this._list.removeChildrenToPool(); - }; - Object.defineProperty(PopupMenu.prototype, "itemCount", { - get: function () { - return this._list.numChildren; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(PopupMenu.prototype, "contentPane", { - get: function () { - return this._contentPane; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(PopupMenu.prototype, "list", { - get: function () { - return this._list; - }, - enumerable: true, - configurable: true - }); - PopupMenu.prototype.show = function (target, dir) { - var r = target ? target.root : fgui.GRoot.inst; - r.showPopup(this.contentPane, (target instanceof fgui.GRoot) ? null : target, dir); - }; - PopupMenu.prototype.__clickItem = function (evt) { - fgui.GTimers.inst.add(100, 1, this.__clickItem2, this, evt); - }; - PopupMenu.prototype.__clickItem2 = function (evt) { - var item = evt.itemObject.asButton; - if (item == null) - return; - if (item.grayed) { - this._list.selectedIndex = -1; - return; - } - var c = item.getController("checked"); - if (c && c.selectedIndex != 0) { - if (c.selectedIndex == 1) - c.selectedIndex = 2; - else - c.selectedIndex = 1; - } - var r = (this._contentPane.parent); - r.hidePopup(this.contentPane); - if (item.data != null) { - if (item.data.length == 1) - item.data(evt); - else - item.data(); - } - }; - PopupMenu.prototype.__addedToStage = function (evt) { - this._list.selectedIndex = -1; - this._list.resizeToFit(100000, 10); - }; - return PopupMenu; - }()); - fgui.PopupMenu = PopupMenu; -})(fgui || (fgui = {})); - -(function (fgui) { - var RelationItem = (function () { - function RelationItem(owner) { - this._owner = owner; - this._defs = new Array(); - } - Object.defineProperty(RelationItem.prototype, "owner", { - get: function () { - return this._owner; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RelationItem.prototype, "target", { - get: function () { - return this._target; - }, - set: function (value) { - if (this._target != value) { - if (this._target) - this.releaseRefTarget(this._target); - this._target = value; - if (this._target) - this.addRefTarget(this._target); - } - }, - enumerable: true, - configurable: true - }); - RelationItem.prototype.add = function (relationType, usePercent) { - if (relationType == fgui.RelationType.Size) { - this.add(fgui.RelationType.Width, usePercent); - this.add(fgui.RelationType.Height, usePercent); - return; - } - var length = this._defs.length; - for (var i = 0; i < length; i++) { - var def = this._defs[i]; - if (def.type == relationType) - return; - } - this.internalAdd(relationType, usePercent); - }; - RelationItem.prototype.internalAdd = function (relationType, usePercent) { - if (relationType == fgui.RelationType.Size) { - this.internalAdd(fgui.RelationType.Width, usePercent); - this.internalAdd(fgui.RelationType.Height, usePercent); - return; - } - var info = new RelationDef(); - info.percent = usePercent; - info.type = relationType; - info.axis = (relationType <= fgui.RelationType.Right_Right || relationType == fgui.RelationType.Width || relationType >= fgui.RelationType.LeftExt_Left && relationType <= fgui.RelationType.RightExt_Right) ? 0 : 1; - this._defs.push(info); - if (usePercent || relationType == fgui.RelationType.Left_Center || relationType == fgui.RelationType.Center_Center || relationType == fgui.RelationType.Right_Center - || relationType == fgui.RelationType.Top_Middle || relationType == fgui.RelationType.Middle_Middle || relationType == fgui.RelationType.Bottom_Middle) - this._owner.pixelSnapping = true; - }; - RelationItem.prototype.remove = function (relationType) { - if (relationType === void 0) { relationType = 0; } - if (relationType == fgui.RelationType.Size) { - this.remove(fgui.RelationType.Width); - this.remove(fgui.RelationType.Height); - return; - } - var dc = this._defs.length; - for (var k = 0; k < dc; k++) { - if (this._defs[k].type == relationType) { - this._defs.splice(k, 1); - break; - } - } - }; - RelationItem.prototype.copyFrom = function (source) { - this.target = source.target; - this._defs.length = 0; - var length = source._defs.length; - for (var i = 0; i < length; i++) { - var info = source._defs[i]; - var info2 = new RelationDef(); - info2.copyFrom(info); - this._defs.push(info2); - } - }; - RelationItem.prototype.dispose = function () { - if (this._target) { - this.releaseRefTarget(this._target); - this._target = null; - } - }; - Object.defineProperty(RelationItem.prototype, "isEmpty", { - get: function () { - return this._defs.length == 0; - }, - enumerable: true, - configurable: true - }); - RelationItem.prototype.applyOnSelfResized = function (dWidth, dHeight, applyPivot) { - var ox = this._owner.x; - var oy = this._owner.y; - var length = this._defs.length; - for (var i = 0; i < length; i++) { - var info = this._defs[i]; - switch (info.type) { - case fgui.RelationType.Center_Center: - this._owner.x -= (0.5 - (applyPivot ? this._owner.pivotX : 0)) * dWidth; - break; - case fgui.RelationType.Right_Center: - case fgui.RelationType.Right_Left: - case fgui.RelationType.Right_Right: - this._owner.x -= (1 - (applyPivot ? this._owner.pivotX : 0)) * dWidth; - break; - case fgui.RelationType.Middle_Middle: - this._owner.y -= (0.5 - (applyPivot ? this._owner.pivotY : 0)) * dHeight; - break; - case fgui.RelationType.Bottom_Middle: - case fgui.RelationType.Bottom_Top: - case fgui.RelationType.Bottom_Bottom: - this._owner.y -= (1 - (applyPivot ? this._owner.pivotY : 0)) * dHeight; - break; - } - } - if (ox != this._owner.x || oy != this._owner.y) { - ox = this._owner.x - ox; - oy = this._owner.y - oy; - this._owner.updateGearFromRelations(1, ox, oy); - if (this._owner.parent) { - var len = this._owner.parent._transitions.length; - if (len > 0) { - for (var i = 0; i < len; ++i) { - this._owner.parent._transitions[i].updateFromRelations(this._owner.id, ox, oy); - } - } - } - } - }; - RelationItem.prototype.applyOnXYChanged = function (info, dx, dy) { - var tmp; - switch (info.type) { - case fgui.RelationType.Left_Left: - case fgui.RelationType.Left_Center: - case fgui.RelationType.Left_Right: - case fgui.RelationType.Center_Center: - case fgui.RelationType.Right_Left: - case fgui.RelationType.Right_Center: - case fgui.RelationType.Right_Right: - this._owner.x += dx; - break; - case fgui.RelationType.Top_Top: - case fgui.RelationType.Top_Middle: - case fgui.RelationType.Top_Bottom: - case fgui.RelationType.Middle_Middle: - case fgui.RelationType.Bottom_Top: - case fgui.RelationType.Bottom_Middle: - case fgui.RelationType.Bottom_Bottom: - this._owner.y += dy; - break; - case fgui.RelationType.Width: - case fgui.RelationType.Height: - break; - case fgui.RelationType.LeftExt_Left: - case fgui.RelationType.LeftExt_Right: - if (this._owner != this._target.parent) { - tmp = this._owner.xMin; - this._owner.width = this._owner._rawWidth - dx; - this._owner.xMin = tmp + dx; - } - else - this._owner.width = this._owner._rawWidth - dx; - break; - case fgui.RelationType.RightExt_Left: - case fgui.RelationType.RightExt_Right: - if (this._owner != this._target.parent) { - tmp = this._owner.xMin; - this._owner.width = this._owner._rawWidth + dx; - this._owner.xMin = tmp; - } - else - this._owner.width = this._owner._rawWidth + dx; - break; - case fgui.RelationType.TopExt_Top: - case fgui.RelationType.TopExt_Bottom: - if (this._owner != this._target.parent) { - tmp = this._owner.yMin; - this._owner.height = this._owner._rawHeight - dy; - this._owner.yMin = tmp + dy; - } - else - this._owner.height = this._owner._rawHeight - dy; - break; - case fgui.RelationType.BottomExt_Top: - case fgui.RelationType.BottomExt_Bottom: - if (this._owner != this._target.parent) { - tmp = this._owner.yMin; - this._owner.height = this._owner._rawHeight + dy; - this._owner.yMin = tmp; - } - else - this._owner.height = this._owner._rawHeight + dy; - break; - } - }; - RelationItem.prototype.applyOnSizeChanged = function (info) { - var pos = 0, pivot = 0, delta = 0; - var v, tmp; - if (info.axis == 0) { - if (this._target != this._owner.parent) { - pos = this._target.x; - if (this._target.pivotAsAnchor) - pivot = this._target.pivotX; - } - if (info.percent) { - if (this._targetWidth != 0) - delta = this._target._width / this._targetWidth; - } - else - delta = this._target._width - this._targetWidth; - } - else { - if (this._target != this._owner.parent) { - pos = this._target.y; - if (this._target.pivotAsAnchor) - pivot = this._target.pivotY; - } - if (info.percent) { - if (this._targetHeight != 0) - delta = this._target._height / this._targetHeight; - } - else - delta = this._target._height - this._targetHeight; - } - switch (info.type) { - case fgui.RelationType.Left_Left: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin - pos) * delta; - else if (pivot != 0) - this._owner.x += delta * (-pivot); - break; - case fgui.RelationType.Left_Center: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin - pos) * delta; - else - this._owner.x += delta * (0.5 - pivot); - break; - case fgui.RelationType.Left_Right: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin - pos) * delta; - else - this._owner.x += delta * (1 - pivot); - break; - case fgui.RelationType.Center_Center: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin + this._owner._rawWidth * 0.5 - pos) * delta - this._owner._rawWidth * 0.5; - else - this._owner.x += delta * (0.5 - pivot); - break; - case fgui.RelationType.Right_Left: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin + this._owner._rawWidth - pos) * delta - this._owner._rawWidth; - else if (pivot != 0) - this._owner.x += delta * (-pivot); - break; - case fgui.RelationType.Right_Center: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin + this._owner._rawWidth - pos) * delta - this._owner._rawWidth; - else - this._owner.x += delta * (0.5 - pivot); - break; - case fgui.RelationType.Right_Right: - if (info.percent) - this._owner.xMin = pos + (this._owner.xMin + this._owner._rawWidth - pos) * delta - this._owner._rawWidth; - else - this._owner.x += delta * (1 - pivot); - break; - case fgui.RelationType.Top_Top: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin - pos) * delta; - else if (pivot != 0) - this._owner.y += delta * (-pivot); - break; - case fgui.RelationType.Top_Middle: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin - pos) * delta; - else - this._owner.y += delta * (0.5 - pivot); - break; - case fgui.RelationType.Top_Bottom: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin - pos) * delta; - else - this._owner.y += delta * (1 - pivot); - break; - case fgui.RelationType.Middle_Middle: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin + this._owner._rawHeight * 0.5 - pos) * delta - this._owner._rawHeight * 0.5; - else - this._owner.y += delta * (0.5 - pivot); - break; - case fgui.RelationType.Bottom_Top: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin + this._owner._rawHeight - pos) * delta - this._owner._rawHeight; - else if (pivot != 0) - this._owner.y += delta * (-pivot); - break; - case fgui.RelationType.Bottom_Middle: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin + this._owner._rawHeight - pos) * delta - this._owner._rawHeight; - else - this._owner.y += delta * (0.5 - pivot); - break; - case fgui.RelationType.Bottom_Bottom: - if (info.percent) - this._owner.yMin = pos + (this._owner.yMin + this._owner._rawHeight - pos) * delta - this._owner._rawHeight; - else - this._owner.y += delta * (1 - pivot); - break; - case fgui.RelationType.Width: - if (this._owner._underConstruct && this._owner == this._target.parent) - v = this._owner.sourceWidth - this._target.initWidth; - else - v = this._owner._rawWidth - this._targetWidth; - if (info.percent) - v = v * delta; - if (this._target == this._owner.parent) { - if (this._owner.pivotAsAnchor) { - tmp = this._owner.xMin; - this._owner.setSize(this._target._width + v, this._owner._rawHeight, true); - this._owner.xMin = tmp; - } - else - this._owner.setSize(this._target._width + v, this._owner._rawHeight, true); - } - else - this._owner.width = this._target._width + v; - break; - case fgui.RelationType.Height: - if (this._owner._underConstruct && this._owner == this._target.parent) - v = this._owner.sourceHeight - this._target.initHeight; - else - v = this._owner._rawHeight - this._targetHeight; - if (info.percent) - v = v * delta; - if (this._target == this._owner.parent) { - if (this._owner.pivotAsAnchor) { - tmp = this._owner.yMin; - this._owner.setSize(this._owner._rawWidth, this._target._height + v, true); - this._owner.yMin = tmp; - } - else - this._owner.setSize(this._owner._rawWidth, this._target._height + v, true); - } - else - this._owner.height = this._target._height + v; - break; - case fgui.RelationType.LeftExt_Left: - tmp = this._owner.xMin; - if (info.percent) - v = pos + (tmp - pos) * delta - tmp; - else - v = delta * (-pivot); - this._owner.width = this._owner._rawWidth - v; - this._owner.xMin = tmp + v; - break; - case fgui.RelationType.LeftExt_Right: - tmp = this._owner.xMin; - if (info.percent) - v = pos + (tmp - pos) * delta - tmp; - else - v = delta * (1 - pivot); - this._owner.width = this._owner._rawWidth - v; - this._owner.xMin = tmp + v; - break; - case fgui.RelationType.RightExt_Left: - tmp = this._owner.xMin; - if (info.percent) - v = pos + (tmp + this._owner._rawWidth - pos) * delta - (tmp + this._owner._rawWidth); - else - v = delta * (-pivot); - this._owner.width = this._owner._rawWidth + v; - this._owner.xMin = tmp; - break; - case fgui.RelationType.RightExt_Right: - tmp = this._owner.xMin; - if (info.percent) { - if (this._owner == this._target.parent) { - if (this._owner._underConstruct) - this._owner.width = pos + this._target._width - this._target._width * pivot + - (this._owner.sourceWidth - pos - this._target.initWidth + this._target.initWidth * pivot) * delta; - else - this._owner.width = pos + (this._owner._rawWidth - pos) * delta; - } - else { - v = pos + (tmp + this._owner._rawWidth - pos) * delta - (tmp + this._owner._rawWidth); - this._owner.width = this._owner._rawWidth + v; - this._owner.xMin = tmp; - } - } - else { - if (this._owner == this._target.parent) { - if (this._owner._underConstruct) - this._owner.width = this._owner.sourceWidth + (this._target._width - this._target.initWidth) * (1 - pivot); - else - this._owner.width = this._owner._rawWidth + delta * (1 - pivot); - } - else { - v = delta * (1 - pivot); - this._owner.width = this._owner._rawWidth + v; - this._owner.xMin = tmp; - } - } - break; - case fgui.RelationType.TopExt_Top: - tmp = this._owner.yMin; - if (info.percent) - v = pos + (tmp - pos) * delta - tmp; - else - v = delta * (-pivot); - this._owner.height = this._owner._rawHeight - v; - this._owner.yMin = tmp + v; - break; - case fgui.RelationType.TopExt_Bottom: - tmp = this._owner.yMin; - if (info.percent) - v = pos + (tmp - pos) * delta - tmp; - else - v = delta * (1 - pivot); - this._owner.height = this._owner._rawHeight - v; - this._owner.yMin = tmp + v; - break; - case fgui.RelationType.BottomExt_Top: - tmp = this._owner.yMin; - if (info.percent) - v = pos + (tmp + this._owner._rawHeight - pos) * delta - (tmp + this._owner._rawHeight); - else - v = delta * (-pivot); - this._owner.height = this._owner._rawHeight + v; - this._owner.yMin = tmp; - break; - case fgui.RelationType.BottomExt_Bottom: - tmp = this._owner.yMin; - if (info.percent) { - if (this._owner == this._target.parent) { - if (this._owner._underConstruct) - this._owner.height = pos + this._target._height - this._target._height * pivot + - (this._owner.sourceHeight - pos - this._target.initHeight + this._target.initHeight * pivot) * delta; - else - this._owner.height = pos + (this._owner._rawHeight - pos) * delta; - } - else { - v = pos + (tmp + this._owner._rawHeight - pos) * delta - (tmp + this._owner._rawHeight); - this._owner.height = this._owner._rawHeight + v; - this._owner.yMin = tmp; - } - } - else { - if (this._owner == this._target.parent) { - if (this._owner._underConstruct) - this._owner.height = this._owner.sourceHeight + (this._target._height - this._target.initHeight) * (1 - pivot); - else - this._owner.height = this._owner._rawHeight + delta * (1 - pivot); - } - else { - v = delta * (1 - pivot); - this._owner.height = this._owner._rawHeight + v; - this._owner.yMin = tmp; - } - } - break; - } - }; - RelationItem.prototype.addRefTarget = function (target) { - if (target != this._owner.parent) - target.addEventListener(fgui.GObject.XY_CHANGED, this.__targetXYChanged, this); - target.addEventListener(fgui.GObject.SIZE_CHANGED, this.__targetSizeChanged, this); - target.addEventListener(fgui.GObject.SIZE_DELAY_CHANGE, this.__targetSizeWillChange, this); - this._targetX = this._target.x; - this._targetY = this._target.y; - this._targetWidth = this._target._width; - this._targetHeight = this._target._height; - }; - RelationItem.prototype.releaseRefTarget = function (target) { - target.removeEventListener(fgui.GObject.XY_CHANGED, this.__targetXYChanged, this); - target.removeEventListener(fgui.GObject.SIZE_CHANGED, this.__targetSizeChanged, this); - target.removeEventListener(fgui.GObject.SIZE_DELAY_CHANGE, this.__targetSizeWillChange, this); - }; - RelationItem.prototype.__targetXYChanged = function (evt) { - if (this._owner.relations.handling != null || this._owner.group != null && this._owner.group._updating) { - this._targetX = this._target.x; - this._targetY = this._target.y; - return; - } - this._owner.relations.handling = this._target; - var ox = this._owner.x; - var oy = this._owner.y; - var dx = this._target.x - this._targetX; - var dy = this._target.y - this._targetY; - var length = this._defs.length; - for (var i = 0; i < length; i++) { - var info = this._defs[i]; - this.applyOnXYChanged(info, dx, dy); - } - this._targetX = this._target.x; - this._targetY = this._target.y; - if (ox != this._owner.x || oy != this._owner.y) { - ox = this._owner.x - ox; - oy = this._owner.y - oy; - this._owner.updateGearFromRelations(1, ox, oy); - if (this._owner.parent) { - var len = this._owner.parent._transitions.length; - if (len > 0) { - for (var i = 0; i < len; ++i) { - this._owner.parent._transitions[i].updateFromRelations(this._owner.id, ox, oy); - } - } - } - } - this._owner.relations.handling = null; - }; - RelationItem.prototype.__targetSizeChanged = function (evt) { - if (this._owner.relations.handling != null) - return; - this._owner.relations.handling = this._target; - var ox = this._owner.x; - var oy = this._owner.y; - var ow = this._owner._rawWidth; - var oh = this._owner._rawHeight; - var length = this._defs.length; - for (var i = 0; i < length; i++) { - var info = this._defs[i]; - this.applyOnSizeChanged(info); - } - this._targetWidth = this._target._width; - this._targetHeight = this._target._height; - if (ox != this._owner.x || oy != this._owner.y) { - ox = this._owner.x - ox; - oy = this._owner.y - oy; - this._owner.updateGearFromRelations(1, ox, oy); - if (this._owner.parent) { - var len = this._owner.parent._transitions.length; - if (len > 0) { - for (var i = 0; i < len; ++i) { - this._owner.parent._transitions[i].updateFromRelations(this._owner.id, ox, oy); - } - } - } - } - if (ow != this._owner._rawWidth || oh != this._owner._rawHeight) { - ow = this._owner._rawWidth - ow; - oh = this._owner._rawHeight - oh; - this._owner.updateGearFromRelations(2, ow, oh); - } - this._owner.relations.handling = null; - }; - RelationItem.prototype.__targetSizeWillChange = function (evt) { - this._owner.relations.sizeDirty = true; - }; - return RelationItem; - }()); - fgui.RelationItem = RelationItem; - var RelationDef = (function () { - function RelationDef() { - } - RelationDef.prototype.copyFrom = function (source) { - this.percent = source.percent; - this.type = source.type; - this.axis = source.axis; - }; - return RelationDef; - }()); - fgui.RelationDef = RelationDef; -})(fgui || (fgui = {})); - -(function (fgui) { - var Relations = (function () { - function Relations(owner) { - this._owner = owner; - this._items = new Array(); - } - Relations.prototype.add = function (target, relationType, usePercent) { - var length = this._items.length; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - if (item.target == target) { - item.add(relationType, usePercent); - return; - } - } - var newItem = new fgui.RelationItem(this._owner); - newItem.target = target; - newItem.add(relationType, usePercent); - this._items.push(newItem); - }; - Relations.prototype.remove = function (target, relationType) { - relationType = relationType || 0; - var cnt = this._items.length; - var i = 0; - while (i < cnt) { - var item = this._items[i]; - if (item.target == target) { - item.remove(relationType); - if (item.isEmpty) { - item.dispose(); - this._items.splice(i, 1); - cnt--; - } - else - i++; - } - else - i++; - } - }; - Relations.prototype.contains = function (target) { - var length = this._items.length; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - if (item.target == target) - return true; - } - return false; - }; - Relations.prototype.clearFor = function (target) { - var cnt = this._items.length; - var i = 0; - while (i < cnt) { - var item = this._items[i]; - if (item.target == target) { - item.dispose(); - this._items.splice(i, 1); - cnt--; - } - else - i++; - } - }; - Relations.prototype.clearAll = function () { - var length = this._items.length; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - item.dispose(); - } - this._items.length = 0; - }; - Relations.prototype.copyFrom = function (source) { - this.clearAll(); - var arr = source._items; - var length = arr.length; - for (var i = 0; i < length; i++) { - var ri = arr[i]; - var item = new fgui.RelationItem(this._owner); - item.copyFrom(ri); - this._items.push(item); - } - }; - Relations.prototype.dispose = function () { - this.clearAll(); - }; - Relations.prototype.onOwnerSizeChanged = function (dWidth, dHeight, applyPivot) { - if (this._items.length == 0) - return; - var length = this._items.length; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - item.applyOnSelfResized(dWidth, dHeight, applyPivot); - } - }; - Relations.prototype.ensureRelationsSizeCorrect = function () { - if (this._items.length == 0) - return; - this.sizeDirty = false; - var length = this._items.length; - for (var i = 0; i < length; i++) { - var item = this._items[i]; - item.target.ensureSizeCorrect(); - } - }; - Object.defineProperty(Relations.prototype, "empty", { - get: function () { - return this._items.length == 0; - }, - enumerable: true, - configurable: true - }); - Relations.prototype.setup = function (buffer, parentToChild) { - var cnt = buffer.readByte(); - var target; - for (var i = 0; i < cnt; i++) { - var targetIndex = buffer.readShort(); - if (targetIndex == -1) - target = this._owner.parent; - else if (parentToChild) - target = this._owner.getChildAt(targetIndex); - else - target = this._owner.parent.getChildAt(targetIndex); - var newItem = new fgui.RelationItem(this._owner); - newItem.target = target; - this._items.push(newItem); - var cnt2 = buffer.readByte(); - for (var j = 0; j < cnt2; j++) { - var rt = buffer.readByte(); - var usePercent = buffer.readBool(); - newItem.internalAdd(rt, usePercent); - } - } - }; - return Relations; - }()); - fgui.Relations = Relations; -})(fgui || (fgui = {})); - -(function (fgui) { - var ScrollPane = (function (_super_1) { - __extends(ScrollPane, _super_1); - function ScrollPane(owner) { - var _this = _super_1.call(this) || this; - _this._owner = owner; - _this._maskContainer = new egret.DisplayObjectContainer(); - _this._owner._rootContainer.addChild(_this._maskContainer); - _this._container = _this._owner._container; - _this._container.x = 0; - _this._container.y = 0; - _this._maskContainer.addChild(_this._container); - _this._scrollBarMargin = new fgui.Margin(); - _this._xPos = 0; - _this._yPos = 0; - _this._aniFlag = 0; - _this._tweening = 0; - _this._footerLockedSize = 0; - _this._headerLockedSize = 0; - _this._viewSize = new egret.Point(); - _this._contentSize = new egret.Point(); - _this._pageSize = new egret.Point(1, 1); - _this._overlapSize = new egret.Point(); - _this._tweenTime = new egret.Point(); - _this._tweenStart = new egret.Point(); - _this._tweenDuration = new egret.Point(); - _this._tweenChange = new egret.Point(); - _this._velocity = new egret.Point(); - _this._containerPos = new egret.Point(); - _this._beginTouchPos = new egret.Point(); - _this._lastTouchPos = new egret.Point(); - _this._lastTouchGlobalPos = new egret.Point(); - _this._scrollStep = fgui.UIConfig.defaultScrollStep; - _this._decelerationRate = fgui.UIConfig.defaultScrollDecelerationRate; - _this._owner.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.__touchBegin, _this); - return _this; - } - ScrollPane.prototype.setup = function (buffer) { - this._scrollType = buffer.readByte(); - var scrollBarDisplay = buffer.readByte(); - var flags = buffer.readInt(); - if (buffer.readBool()) { - this._scrollBarMargin.top = buffer.readInt(); - this._scrollBarMargin.bottom = buffer.readInt(); - this._scrollBarMargin.left = buffer.readInt(); - this._scrollBarMargin.right = buffer.readInt(); - } - var vtScrollBarRes = buffer.readS(); - var hzScrollBarRes = buffer.readS(); - var headerRes = buffer.readS(); - var footerRes = buffer.readS(); - if ((flags & 1) != 0) - this._displayOnLeft = true; - if ((flags & 2) != 0) - this._snapToItem = true; - if ((flags & 4) != 0) - this._displayInDemand = true; - if ((flags & 8) != 0) - this._pageMode = true; - if (flags & 16) - this._touchEffect = true; - else if (flags & 32) - this._touchEffect = false; - else - this._touchEffect = fgui.UIConfig.defaultScrollTouchEffect; - if (flags & 64) - this._bouncebackEffect = true; - else if (flags & 128) - this._bouncebackEffect = false; - else - this._bouncebackEffect = fgui.UIConfig.defaultScrollBounceEffect; - if ((flags & 256) != 0) - this._inertiaDisabled = true; - if ((flags & 512) == 0) - this._maskContainer.scrollRect = new egret.Rectangle(); - if ((flags & 1024) != 0) - this._floating = true; - if ((flags & 2048) != 0) - this._dontClipMargin = true; - if (scrollBarDisplay == fgui.ScrollBarDisplayType.Default) - scrollBarDisplay = fgui.UIConfig.defaultScrollBarDisplay; - if (scrollBarDisplay != fgui.ScrollBarDisplayType.Hidden) { - if (this._scrollType == fgui.ScrollType.Both || this._scrollType == fgui.ScrollType.Vertical) { - var res = vtScrollBarRes ? vtScrollBarRes : fgui.UIConfig.verticalScrollBar; - if (res) { - this._vtScrollBar = fgui.UIPackage.createObjectFromURL(res); - if (!this._vtScrollBar) - throw "cannot create scrollbar from " + res; - this._vtScrollBar.setScrollPane(this, true); - this._owner._rootContainer.addChild(this._vtScrollBar.displayObject); - } - } - if (this._scrollType == fgui.ScrollType.Both || this._scrollType == fgui.ScrollType.Horizontal) { - var res = hzScrollBarRes ? hzScrollBarRes : fgui.UIConfig.horizontalScrollBar; - if (res) { - this._hzScrollBar = fgui.UIPackage.createObjectFromURL(res); - if (!this._hzScrollBar) - throw "cannot create scrollbar from " + res; - this._hzScrollBar.setScrollPane(this, false); - this._owner._rootContainer.addChild(this._hzScrollBar.displayObject); - } - } - if (scrollBarDisplay == fgui.ScrollBarDisplayType.Auto) - this._scrollBarDisplayAuto = true; - if (this._scrollBarDisplayAuto) { - if (this._vtScrollBar) - this._vtScrollBar.displayObject.visible = false; - if (this._hzScrollBar) - this._hzScrollBar.displayObject.visible = false; - } - } - if (headerRes) { - this._header = fgui.UIPackage.createObjectFromURL(headerRes); - if (!this._header) - throw "cannot create scrollPane header from " + headerRes; - } - if (footerRes) { - this._footer = fgui.UIPackage.createObjectFromURL(footerRes); - if (!this._footer) - throw "cannot create scrollPane footer from " + footerRes; - } - if (this._header || this._footer) - this._refreshBarAxis = (this._scrollType == fgui.ScrollType.Both || this._scrollType == fgui.ScrollType.Vertical) ? "y" : "x"; - this.setSize(this._owner.width, this._owner.height); - }; - ScrollPane.prototype.dispose = function () { - if (this._tweening != 0) - fgui.GTimers.inst.remove(this.tweenUpdate, this); - delete this._pageController; - if (this._hzScrollBar) - this._hzScrollBar.dispose(); - if (this._vtScrollBar) - this._vtScrollBar.dispose(); - if (this._header) - this._header.dispose(); - if (this._footer) - this._footer.dispose(); - }; - Object.defineProperty(ScrollPane.prototype, "owner", { - get: function () { - return this._owner; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "hzScrollBar", { - get: function () { - return this._hzScrollBar; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "vtScrollBar", { - get: function () { - return this._vtScrollBar; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "header", { - get: function () { - return this._header; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "footer", { - get: function () { - return this._footer; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "bouncebackEffect", { - get: function () { - return this._bouncebackEffect; - }, - set: function (sc) { - this._bouncebackEffect = sc; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "touchEffect", { - get: function () { - return this._touchEffect; - }, - set: function (sc) { - this._touchEffect = sc; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "scrollStep", { - get: function () { - return this._scrollStep; - }, - set: function (val) { - this._scrollStep = val; - if (this._scrollStep == 0) - this._scrollStep = fgui.UIConfig.defaultScrollStep; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "decelerationRate", { - get: function () { - return this._decelerationRate; - }, - set: function (val) { - this._decelerationRate = val; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "snapToItem", { - get: function () { - return this._snapToItem; - }, - set: function (value) { - this._snapToItem = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "isDragged", { - get: function () { - return this._dragged; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "percX", { - get: function () { - return this._overlapSize.x == 0 ? 0 : this._xPos / this._overlapSize.x; - }, - set: function (value) { - this.setPercX(value, false); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.setPercX = function (value, ani) { - if (ani === void 0) { ani = false; } - this._owner.ensureBoundsCorrect(); - this.setPosX(this._overlapSize.x * fgui.ToolSet.clamp01(value), ani); - }; - Object.defineProperty(ScrollPane.prototype, "percY", { - get: function () { - return this._overlapSize.y == 0 ? 0 : this._yPos / this._overlapSize.y; - }, - set: function (value) { - this.setPercY(value, false); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.setPercY = function (value, ani) { - if (ani === void 0) { ani = false; } - this._owner.ensureBoundsCorrect(); - this.setPosY(this._overlapSize.y * fgui.ToolSet.clamp01(value), ani); - }; - Object.defineProperty(ScrollPane.prototype, "posX", { - get: function () { - return this._xPos; - }, - set: function (value) { - this.setPosX(value, false); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.setPosX = function (value, ani) { - this._owner.ensureBoundsCorrect(); - if (this._loop == 1) - value = this.loopCheckingNewPos(value, "x"); - value = fgui.ToolSet.clamp(value, 0, this._overlapSize.x); - if (value != this._xPos) { - this._xPos = value; - this.posChanged(ani); - } - }; - Object.defineProperty(ScrollPane.prototype, "posY", { - get: function () { - return this._yPos; - }, - set: function (value) { - this.setPosY(value, false); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.setPosY = function (value, ani) { - this._owner.ensureBoundsCorrect(); - if (this._loop == 1) - value = this.loopCheckingNewPos(value, "y"); - value = fgui.ToolSet.clamp(value, 0, this._overlapSize.y); - if (value != this._yPos) { - this._yPos = value; - this.posChanged(ani); - } - }; - Object.defineProperty(ScrollPane.prototype, "contentWidth", { - get: function () { - return this._contentSize.x; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "contentHeight", { - get: function () { - return this._contentSize.y; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "viewWidth", { - get: function () { - return this._viewSize.x; - }, - set: function (value) { - value = value + this._owner.margin.left + this._owner.margin.right; - if (this._vtScrollBar && !this._floating) - value += this._vtScrollBar.width; - this._owner.width = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "viewHeight", { - get: function () { - return this._viewSize.y; - }, - set: function (value) { - value = value + this._owner.margin.top + this._owner.margin.bottom; - if (this._hzScrollBar && !this._floating) - value += this._hzScrollBar.height; - this._owner.height = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "currentPageX", { - get: function () { - if (!this._pageMode) - return 0; - var page = Math.floor(this._xPos / this._pageSize.x); - if (this._xPos - page * this._pageSize.x > this._pageSize.x * 0.5) - page++; - return page; - }, - set: function (value) { - this.setCurrentPageX(value, false); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "currentPageY", { - get: function () { - if (!this._pageMode) - return 0; - var page = Math.floor(this._yPos / this._pageSize.y); - if (this._yPos - page * this._pageSize.y > this._pageSize.y * 0.5) - page++; - return page; - }, - set: function (value) { - this.setCurrentPageY(value, false); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.setCurrentPageX = function (value, ani) { - if (!this._pageMode) - return; - this._owner.ensureBoundsCorrect(); - if (this._overlapSize.x > 0) - this.setPosX(value * this._pageSize.x, ani); - }; - ScrollPane.prototype.setCurrentPageY = function (value, ani) { - if (!this._pageMode) - return; - this._owner.ensureBoundsCorrect(); - if (this._overlapSize.y > 0) - this.setPosY(value * this._pageSize.y, ani); - }; - Object.defineProperty(ScrollPane.prototype, "isBottomMost", { - get: function () { - return this._yPos == this._overlapSize.y || this._overlapSize.y == 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "isRightMost", { - get: function () { - return this._xPos == this._overlapSize.x || this._overlapSize.x == 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "pageController", { - get: function () { - return this._pageController; - }, - set: function (value) { - this._pageController = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "scrollingPosX", { - get: function () { - return fgui.ToolSet.clamp(-this._container.x, 0, this._overlapSize.x); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollPane.prototype, "scrollingPosY", { - get: function () { - return fgui.ToolSet.clamp(-this._container.y, 0, this._overlapSize.y); - }, - enumerable: true, - configurable: true - }); - ScrollPane.prototype.scrollTop = function (ani) { - this.setPercY(0, ani); - }; - ScrollPane.prototype.scrollBottom = function (ani) { - this.setPercY(1, ani); - }; - ScrollPane.prototype.scrollUp = function (ratio, ani) { - ratio = ratio || 1; - if (this._pageMode) - this.setPosY(this._yPos - this._pageSize.y * ratio, ani); - else - this.setPosY(this._yPos - this._scrollStep * ratio, ani); - }; - ScrollPane.prototype.scrollDown = function (ratio, ani) { - ratio = ratio || 1; - if (this._pageMode) - this.setPosY(this._yPos + this._pageSize.y * ratio, ani); - else - this.setPosY(this._yPos + this._scrollStep * ratio, ani); - }; - ScrollPane.prototype.scrollLeft = function (ratio, ani) { - ratio = ratio || 1; - if (this._pageMode) - this.setPosX(this._xPos - this._pageSize.x * ratio, ani); - else - this.setPosX(this._xPos - this._scrollStep * ratio, ani); - }; - ScrollPane.prototype.scrollRight = function (ratio, ani) { - ratio = ratio || 1; - if (this._pageMode) - this.setPosX(this._xPos + this._pageSize.x * ratio, ani); - else - this.setPosX(this._xPos + this._scrollStep * ratio, ani); - }; - ScrollPane.prototype.scrollToView = function (target, ani, setFirst) { - this._owner.ensureBoundsCorrect(); - if (this._needRefresh) - this.refresh(); - var rect; - if (target instanceof fgui.GObject) { - if (target.parent != this._owner) { - target.parent.localToGlobalRect(target.x, target.y, target.width, target.height, s_rect); - rect = this._owner.globalToLocalRect(s_rect.x, s_rect.y, s_rect.width, s_rect.height, s_rect); - } - else { - rect = s_rect; - rect.setTo(target.x, target.y, target.width, target.height); - } - } - else - rect = target; - if (this._overlapSize.y > 0) { - var bottom = this._yPos + this._viewSize.y; - if (setFirst || rect.y <= this._yPos || rect.height >= this._viewSize.y) { - if (this._pageMode) - this.setPosY(Math.floor(rect.y / this._pageSize.y) * this._pageSize.y, ani); - else - this.setPosY(rect.y, ani); - } - else if (rect.y + rect.height > bottom) { - if (this._pageMode) - this.setPosY(Math.floor(rect.y / this._pageSize.y) * this._pageSize.y, ani); - else if (rect.height <= this._viewSize.y / 2) - this.setPosY(rect.y + rect.height * 2 - this._viewSize.y, ani); - else - this.setPosY(rect.y + rect.height - this._viewSize.y, ani); - } - } - if (this._overlapSize.x > 0) { - var right = this._xPos + this._viewSize.x; - if (setFirst || rect.x <= this._xPos || rect.width >= this._viewSize.x) { - if (this._pageMode) - this.setPosX(Math.floor(rect.x / this._pageSize.x) * this._pageSize.x, ani); - else - this.setPosX(rect.x, ani); - } - else if (rect.x + rect.width > right) { - if (this._pageMode) - this.setPosX(Math.floor(rect.x / this._pageSize.x) * this._pageSize.x, ani); - else if (rect.width <= this._viewSize.x / 2) - this.setPosX(rect.x + rect.width * 2 - this._viewSize.x, ani); - else - this.setPosX(rect.x + rect.width - this._viewSize.x, ani); - } - } - if (!ani && this._needRefresh) - this.refresh(); - }; - ScrollPane.prototype.isChildInView = function (obj) { - if (this._overlapSize.y > 0) { - var dist = obj.y + this._container.y; - if (dist < -obj.height || dist > this._viewSize.y) - return false; - } - if (this._overlapSize.x > 0) { - dist = obj.x + this._container.x; - if (dist < -obj.width || dist > this._viewSize.x) - return false; - } - return true; - }; - ScrollPane.prototype.cancelDragging = function () { - this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.__touchMove, this); - this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_END, this.__touchEnd, this); - this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.__touchTap, this); - if (ScrollPane.draggingPane == this) - ScrollPane.draggingPane = null; - _gestureFlag = 0; - this._dragged = false; - this._maskContainer.touchChildren = true; - }; - ScrollPane.prototype.lockHeader = function (size) { - if (this._headerLockedSize == size) - return; - this._headerLockedSize = size; - if (!this._refreshEventDispatching && this._container[this._refreshBarAxis] >= 0) { - this._tweenStart.setTo(this._container.x, this._container.y); - this._tweenChange.setTo(0, 0); - this._tweenChange[this._refreshBarAxis] = this._headerLockedSize - this._tweenStart[this._refreshBarAxis]; - this._tweenDuration.setTo(TWEEN_TIME_DEFAULT, TWEEN_TIME_DEFAULT); - this.startTween(2); - } - }; - ScrollPane.prototype.lockFooter = function (size) { - if (this._footerLockedSize == size) - return; - this._footerLockedSize = size; - if (!this._refreshEventDispatching && this._container[this._refreshBarAxis] <= -this._overlapSize[this._refreshBarAxis]) { - this._tweenStart.setTo(this._container.x, this._container.y); - this._tweenChange.setTo(0, 0); - var max = this._overlapSize[this._refreshBarAxis]; - if (max == 0) - max = Math.max(this._contentSize[this._refreshBarAxis] + this._footerLockedSize - this._viewSize[this._refreshBarAxis], 0); - else - max += this._footerLockedSize; - this._tweenChange[this._refreshBarAxis] = -max - this._tweenStart[this._refreshBarAxis]; - this._tweenDuration.setTo(TWEEN_TIME_DEFAULT, TWEEN_TIME_DEFAULT); - this.startTween(2); - } - }; - ScrollPane.prototype.onOwnerSizeChanged = function () { - this.setSize(this._owner.width, this._owner.height); - this.posChanged(false); - }; - ScrollPane.prototype.handleControllerChanged = function (c) { - if (this._pageController == c) { - if (this._scrollType == fgui.ScrollType.Horizontal) - this.setCurrentPageX(c.selectedIndex, true); - else - this.setCurrentPageY(c.selectedIndex, true); - } - }; - ScrollPane.prototype.updatePageController = function () { - if (this._pageController && !this._pageController.changing) { - var index; - if (this._scrollType == fgui.ScrollType.Horizontal) - index = this.currentPageX; - else - index = this.currentPageY; - if (index < this._pageController.pageCount) { - var c = this._pageController; - this._pageController = null; - c.selectedIndex = index; - this._pageController = c; - } - } - }; - ScrollPane.prototype.adjustMaskContainer = function () { - var mx = 0, my = 0; - if (this._dontClipMargin) { - if (this._displayOnLeft && this._vtScrollBar && !this._floating) - mx = this._vtScrollBar.width; - } - else { - if (this._displayOnLeft && this._vtScrollBar && !this._floating) - mx = this._owner.margin.left + this._vtScrollBar.width; - else - mx = this._owner.margin.left; - my = this._owner.margin.top; - } - this._maskContainer.x = mx; - this._maskContainer.y = my; - mx = this._owner._alignOffset.x; - my = this._owner._alignOffset.y; - if (mx != 0 || my != 0 || this._dontClipMargin) { - if (!this._alignContainer) { - this._alignContainer = new egret.DisplayObjectContainer(); - this._maskContainer.addChild(this._alignContainer); - this._alignContainer.addChild(this._container); - } - } - if (this._alignContainer) { - if (this._dontClipMargin) { - mx += this._owner.margin.left; - my += this._owner.margin.top; - } - this._alignContainer.x = mx; - this._alignContainer.y = my; - } - }; - ScrollPane.prototype.setSize = function (aWidth, aHeight) { - this.adjustMaskContainer(); - if (this._hzScrollBar) { - this._hzScrollBar.y = aHeight - this._hzScrollBar.height; - if (this._vtScrollBar && !this._vScrollNone) { - this._hzScrollBar.width = aWidth - this._vtScrollBar.width - this._scrollBarMargin.left - this._scrollBarMargin.right; - if (this._displayOnLeft) - this._hzScrollBar.x = this._scrollBarMargin.left + this._vtScrollBar.width; - else - this._hzScrollBar.x = this._scrollBarMargin.left; - } - else { - this._hzScrollBar.width = aWidth - this._scrollBarMargin.left - this._scrollBarMargin.right; - this._hzScrollBar.x = this._scrollBarMargin.left; - } - } - if (this._vtScrollBar) { - if (!this._displayOnLeft) - this._vtScrollBar.x = aWidth - this._vtScrollBar.width; - if (this._hzScrollBar) - this._vtScrollBar.height = aHeight - this._hzScrollBar.height - this._scrollBarMargin.top - this._scrollBarMargin.bottom; - else - this._vtScrollBar.height = aHeight - this._scrollBarMargin.top - this._scrollBarMargin.bottom; - this._vtScrollBar.y = this._scrollBarMargin.top; - } - this._viewSize.x = aWidth; - this._viewSize.y = aHeight; - if (this._hzScrollBar && !this._floating) - this._viewSize.y -= this._hzScrollBar.height; - if (this._vtScrollBar && !this._floating) - this._viewSize.x -= this._vtScrollBar.width; - this._viewSize.x -= (this._owner.margin.left + this._owner.margin.right); - this._viewSize.y -= (this._owner.margin.top + this._owner.margin.bottom); - this._viewSize.x = Math.max(1, this._viewSize.x); - this._viewSize.y = Math.max(1, this._viewSize.y); - this._pageSize.x = this._viewSize.x; - this._pageSize.y = this._viewSize.y; - this.handleSizeChanged(); - }; - ScrollPane.prototype.setContentSize = function (aWidth, aHeight) { - if (this._contentSize.x == aWidth && this._contentSize.y == aHeight) - return; - this._contentSize.x = aWidth; - this._contentSize.y = aHeight; - this.handleSizeChanged(); - }; - ScrollPane.prototype.changeContentSizeOnScrolling = function (deltaWidth, deltaHeight, deltaPosX, deltaPosY) { - var isRightmost = this._xPos == this._overlapSize.x; - var isBottom = this._yPos == this._overlapSize.y; - this._contentSize.x += deltaWidth; - this._contentSize.y += deltaHeight; - this.handleSizeChanged(); - if (this._tweening == 1) { - if (deltaWidth != 0 && isRightmost && this._tweenChange.x < 0) { - this._xPos = this._overlapSize.x; - this._tweenChange.x = -this._xPos - this._tweenStart.x; - } - if (deltaHeight != 0 && isBottom && this._tweenChange.y < 0) { - this._yPos = this._overlapSize.y; - this._tweenChange.y = -this._yPos - this._tweenStart.y; - } - } - else if (this._tweening == 2) { - if (deltaPosX != 0) { - this._container.x -= deltaPosX; - this._tweenStart.x -= deltaPosX; - this._xPos = -this._container.x; - } - if (deltaPosY != 0) { - this._container.y -= deltaPosY; - this._tweenStart.y -= deltaPosY; - this._yPos = -this._container.y; - } - } - else if (this._dragged) { - if (deltaPosX != 0) { - this._container.x -= deltaPosX; - this._containerPos.x -= deltaPosX; - this._xPos = -this._container.x; - } - if (deltaPosY != 0) { - this._container.y -= deltaPosY; - this._containerPos.y -= deltaPosY; - this._yPos = -this._container.y; - } - } - else { - if (deltaWidth != 0 && isRightmost) { - this._xPos = this._overlapSize.x; - this._container.x = -this._xPos; - } - if (deltaHeight != 0 && isBottom) { - this._yPos = this._overlapSize.y; - this._container.y = -this._yPos; - } - } - if (this._pageMode) - this.updatePageController(); - }; - ScrollPane.prototype.handleSizeChanged = function () { - if (this._displayInDemand) { - this._vScrollNone = this._contentSize.y <= this._viewSize.y; - this._hScrollNone = this._contentSize.x <= this._viewSize.x; - } - if (this._vtScrollBar) { - if (this._contentSize.y == 0) - this._vtScrollBar.setDisplayPerc(0); - else - this._vtScrollBar.setDisplayPerc(Math.min(1, this._viewSize.y / this._contentSize.y)); - } - if (this._hzScrollBar) { - if (this._contentSize.x == 0) - this._hzScrollBar.setDisplayPerc(0); - else - this._hzScrollBar.setDisplayPerc(Math.min(1, this._viewSize.x / this._contentSize.x)); - } - this.updateScrollBarVisible(); - var rect = this._maskContainer.scrollRect; - if (rect) { - rect.width = this._viewSize.x; - rect.height = this._viewSize.y; - if (this._vScrollNone && this._vtScrollBar) - rect.width += this._vtScrollBar.width; - if (this._hScrollNone && this._hzScrollBar) - rect.height += this._hzScrollBar.height; - if (this._dontClipMargin) { - rect.width += (this._owner.margin.left + this._owner.margin.right); - rect.height += (this._owner.margin.top + this._owner.margin.bottom); - } - this._maskContainer.scrollRect = rect; - } - if (this._scrollType == fgui.ScrollType.Horizontal || this._scrollType == fgui.ScrollType.Both) - this._overlapSize.x = Math.ceil(Math.max(0, this._contentSize.x - this._viewSize.x)); - else - this._overlapSize.x = 0; - if (this._scrollType == fgui.ScrollType.Vertical || this._scrollType == fgui.ScrollType.Both) - this._overlapSize.y = Math.ceil(Math.max(0, this._contentSize.y - this._viewSize.y)); - else - this._overlapSize.y = 0; - this._xPos = fgui.ToolSet.clamp(this._xPos, 0, this._overlapSize.x); - this._yPos = fgui.ToolSet.clamp(this._yPos, 0, this._overlapSize.y); - if (this._refreshBarAxis != null) { - var max = this._overlapSize[this._refreshBarAxis]; - if (max == 0) - max = Math.max(this._contentSize[this._refreshBarAxis] + this._footerLockedSize - this._viewSize[this._refreshBarAxis], 0); - else - max += this._footerLockedSize; - if (this._refreshBarAxis == "x") { - this._container.x = fgui.ToolSet.clamp(this._container.x, -max, this._headerLockedSize); - this._container.y = fgui.ToolSet.clamp(this._container.y, -this._overlapSize.y, 0); - } - else { - this._container.x = fgui.ToolSet.clamp(this._container.x, -this._overlapSize.x, 0); - this._container.y = fgui.ToolSet.clamp(this._container.y, -max, this._headerLockedSize); - } - if (this._header) { - if (this._refreshBarAxis == "x") - this._header.height = this._viewSize.y; - else - this._header.width = this._viewSize.x; - } - if (this._footer) { - if (this._refreshBarAxis == "y") - this._footer.height = this._viewSize.y; - else - this._footer.width = this._viewSize.x; - } - } - else { - this._container.x = fgui.ToolSet.clamp(this._container.x, -this._overlapSize.x, 0); - this._container.y = fgui.ToolSet.clamp(this._container.y, -this._overlapSize.y, 0); - } - this.updateScrollBarPos(); - if (this._pageMode) - this.updatePageController(); - }; - ScrollPane.prototype.posChanged = function (ani) { - if (this._aniFlag == 0) - this._aniFlag = ani ? 1 : -1; - else if (this._aniFlag == 1 && !ani) - this._aniFlag = -1; - this._needRefresh = true; - fgui.GTimers.inst.callLater(this.refresh, this); - if (this._tweening != 0) - this.killTween(); - }; - ScrollPane.prototype.refresh = function () { - this._needRefresh = false; - fgui.GTimers.inst.remove(this.refresh, this); - if (this._pageMode || this._snapToItem) { - sEndPos.setTo(-this._xPos, -this._yPos); - this.alignPosition(sEndPos, false); - this._xPos = -sEndPos.x; - this._yPos = -sEndPos.y; - } - this.refresh2(); - this.dispatchEventWith(ScrollPane.SCROLL); - if (this._needRefresh) { - this._needRefresh = false; - fgui.GTimers.inst.remove(this.refresh, this); - this.refresh2(); - } - this.updateScrollBarPos(); - this._aniFlag = 0; - }; - ScrollPane.prototype.refresh2 = function () { - if (this._aniFlag == 1 && !this._dragged) { - var posX; - var posY; - if (this._overlapSize.x > 0) - posX = -Math.floor(this._xPos); - else { - if (this._container.x != 0) - this._container.x = 0; - posX = 0; - } - if (this._overlapSize.y > 0) - posY = -Math.floor(this._yPos); - else { - if (this._container.y != 0) - this._container.y = 0; - posY = 0; - } - if (posX != this._container.x || posY != this._container.y) { - this._tweenDuration.setTo(TWEEN_TIME_GO, TWEEN_TIME_GO); - this._tweenStart.setTo(this._container.x, this._container.y); - this._tweenChange.setTo(posX - this._tweenStart.x, posY - this._tweenStart.y); - this.startTween(1); - } - else if (this._tweening != 0) - this.killTween(); - } - else { - if (this._tweening != 0) - this.killTween(); - this._container.x = Math.floor(-this._xPos); - this._container.y = Math.floor(-this._yPos); - this.loopCheckingCurrent(); - } - if (this._pageMode) - this.updatePageController(); - }; - ScrollPane.prototype.__touchBegin = function (evt) { - if (!this._touchEffect) - return; - if (this._tweening != 0) { - this.killTween(); - this._dragged = true; - } - else - this._dragged = false; - var pt = this._owner.globalToLocal(evt.stageX, evt.stageY, s_vec2); - this._containerPos.setTo(this._container.x, this._container.y); - this._beginTouchPos.setTo(pt.x, pt.y); - this._lastTouchPos.setTo(pt.x, pt.y); - this._lastTouchGlobalPos.setTo(evt.stageX, evt.stageY); - this._isHoldAreaDone = false; - this._velocity.setTo(0, 0); - this._velocityScale = 1; - this._lastMoveTime = egret.getTimer() / 1000; - this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.__touchMove, this); - this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.__touchEnd, this); - this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_TAP, this.__touchTap, this); - }; - ScrollPane.prototype.__touchMove = function (evt) { - if (this._owner.displayObject.stage == null) - return; - if (!this._touchEffect) - return; - if (ScrollPane.draggingPane && ScrollPane.draggingPane != this || fgui.GObject.draggingObject) - return; - var pt = this._owner.globalToLocal(evt.stageX, evt.stageY, s_vec2); - var sensitivity = fgui.UIConfig.touchScrollSensitivity; - var diff, diff2; - var sv, sh, st; - if (this._scrollType == fgui.ScrollType.Vertical) { - if (!this._isHoldAreaDone) { - _gestureFlag |= 1; - diff = Math.abs(this._beginTouchPos.y - pt.y); - if (diff < sensitivity) - return; - if ((_gestureFlag & 2) != 0) { - diff2 = Math.abs(this._beginTouchPos.x - pt.x); - if (diff < diff2) - return; - } - } - sv = true; - } - else if (this._scrollType == fgui.ScrollType.Horizontal) { - if (!this._isHoldAreaDone) { - _gestureFlag |= 2; - diff = Math.abs(this._beginTouchPos.x - pt.x); - if (diff < sensitivity) - return; - if ((_gestureFlag & 1) != 0) { - diff2 = Math.abs(this._beginTouchPos.y - pt.y); - if (diff < diff2) - return; - } - } - sh = true; - } - else { - _gestureFlag = 3; - if (!this._isHoldAreaDone) { - diff = Math.abs(this._beginTouchPos.y - pt.y); - if (diff < sensitivity) { - diff = Math.abs(this._beginTouchPos.x - pt.x); - if (diff < sensitivity) - return; - } - } - sv = sh = true; - } - var newPosX = Math.floor(this._containerPos.x + pt.x - this._beginTouchPos.x); - var newPosY = Math.floor(this._containerPos.y + pt.y - this._beginTouchPos.y); - if (sv) { - if (newPosY > 0) { - if (!this._bouncebackEffect) - this._container.y = 0; - else if (this._header && this._header.maxHeight != 0) - this._container.y = Math.floor(Math.min(newPosY * 0.5, this._header.maxHeight)); - else - this._container.y = Math.floor(Math.min(newPosY * 0.5, this._viewSize.y * PULL_RATIO)); - } - else if (newPosY < -this._overlapSize.y) { - if (!this._bouncebackEffect) - this._container.y = -this._overlapSize.y; - else if (this._footer && this._footer.maxHeight > 0) - this._container.y = Math.floor(Math.max((newPosY + this._overlapSize.y) * 0.5, -this._footer.maxHeight) - this._overlapSize.y); - else - this._container.y = Math.floor(Math.max((newPosY + this._overlapSize.y) * 0.5, -this._viewSize.y * PULL_RATIO) - this._overlapSize.y); - } - else - this._container.y = newPosY; - } - if (sh) { - if (newPosX > 0) { - if (!this._bouncebackEffect) - this._container.x = 0; - else if (this._header && this._header.maxWidth != 0) - this._container.x = Math.floor(Math.min(newPosX * 0.5, this._header.maxWidth)); - else - this._container.x = Math.floor(Math.min(newPosX * 0.5, this._viewSize.x * PULL_RATIO)); - } - else if (newPosX < 0 - this._overlapSize.x) { - if (!this._bouncebackEffect) - this._container.x = -this._overlapSize.x; - else if (this._footer && this._footer.maxWidth > 0) - this._container.x = Math.floor(Math.max((newPosX + this._overlapSize.x) * 0.5, -this._footer.maxWidth) - this._overlapSize.x); - else - this._container.x = Math.floor(Math.max((newPosX + this._overlapSize.x) * 0.5, -this._viewSize.x * PULL_RATIO) - this._overlapSize.x); - } - else - this._container.x = newPosX; - } - var now = egret.getTimer() / 1000; - var deltaTime = Math.max(now - this._lastMoveTime, 1 / 60); - var deltaPositionX = pt.x - this._lastTouchPos.x; - var deltaPositionY = pt.y - this._lastTouchPos.y; - if (!sh) - deltaPositionX = 0; - if (!sv) - deltaPositionY = 0; - if (deltaTime != 0) { - var frameRate = this._owner.displayObject.stage.frameRate; - var elapsed = deltaTime * frameRate - 1; - if (elapsed > 1) { - var factor = Math.pow(0.833, elapsed); - this._velocity.x = this._velocity.x * factor; - this._velocity.y = this._velocity.y * factor; - } - this._velocity.x = fgui.ToolSet.lerp(this._velocity.x, deltaPositionX * 60 / frameRate / deltaTime, deltaTime * 10); - this._velocity.y = fgui.ToolSet.lerp(this._velocity.y, deltaPositionY * 60 / frameRate / deltaTime, deltaTime * 10); - } - var deltaGlobalPositionX = this._lastTouchGlobalPos.x - evt.stageX; - var deltaGlobalPositionY = this._lastTouchGlobalPos.y - evt.stageY; - if (deltaPositionX != 0) - this._velocityScale = Math.abs(deltaGlobalPositionX / deltaPositionX); - else if (deltaPositionY != 0) - this._velocityScale = Math.abs(deltaGlobalPositionY / deltaPositionY); - this._lastTouchPos.setTo(pt.x, pt.y); - this._lastTouchGlobalPos.setTo(evt.stageX, evt.stageY); - this._lastMoveTime = now; - if (this._overlapSize.x > 0) - this._xPos = fgui.ToolSet.clamp(-this._container.x, 0, this._overlapSize.x); - if (this._overlapSize.y > 0) - this._yPos = fgui.ToolSet.clamp(-this._container.y, 0, this._overlapSize.y); - if (this._loop != 0) { - newPosX = this._container.x; - newPosY = this._container.y; - if (this.loopCheckingCurrent()) { - this._containerPos.x += this._container.x - newPosX; - this._containerPos.y += this._container.y - newPosY; - } - } - ScrollPane.draggingPane = this; - this._isHoldAreaDone = true; - this._dragged = true; - this._maskContainer.touchChildren = false; - this.updateScrollBarPos(); - this.updateScrollBarVisible(); - if (this._pageMode) - this.updatePageController(); - this.dispatchEventWith(ScrollPane.SCROLL); - }; - ScrollPane.prototype.__touchEnd = function (evt) { - evt.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.__touchMove, this); - evt.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END, this.__touchEnd, this); - evt.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.__touchTap, this); - if (ScrollPane.draggingPane == this) - ScrollPane.draggingPane = null; - _gestureFlag = 0; - if (!this._dragged || !this._touchEffect || this._owner.displayObject.stage == null) { - this._dragged = false; - this._maskContainer.touchChildren = true; - return; - } - this._dragged = false; - this._maskContainer.touchChildren = true; - this._tweenStart.setTo(this._container.x, this._container.y); - sEndPos.setTo(this._tweenStart.x, this._tweenStart.y); - var flag = false; - if (this._container.x > 0) { - sEndPos.x = 0; - flag = true; - } - else if (this._container.x < -this._overlapSize.x) { - sEndPos.x = -this._overlapSize.x; - flag = true; - } - if (this._container.y > 0) { - sEndPos.y = 0; - flag = true; - } - else if (this._container.y < -this._overlapSize.y) { - sEndPos.y = -this._overlapSize.y; - flag = true; - } - if (flag) { - this._tweenChange.setTo(sEndPos.x - this._tweenStart.x, sEndPos.y - this._tweenStart.y); - if (this._tweenChange.x < -fgui.UIConfig.touchDragSensitivity || this._tweenChange.y < -fgui.UIConfig.touchDragSensitivity) { - this._refreshEventDispatching = true; - this.dispatchEventWith(ScrollPane.PULL_DOWN_RELEASE); - this._refreshEventDispatching = false; - } - else if (this._tweenChange.x > fgui.UIConfig.touchDragSensitivity || this._tweenChange.y > fgui.UIConfig.touchDragSensitivity) { - this._refreshEventDispatching = true; - this.dispatchEventWith(ScrollPane.PULL_UP_RELEASE); - this._refreshEventDispatching = false; - } - if (this._headerLockedSize > 0 && sEndPos[this._refreshBarAxis] == 0) { - sEndPos[this._refreshBarAxis] = this._headerLockedSize; - this._tweenChange.x = sEndPos.x - this._tweenStart.x; - this._tweenChange.y = sEndPos.y - this._tweenStart.y; - } - else if (this._footerLockedSize > 0 && sEndPos[this._refreshBarAxis] == -this._overlapSize[this._refreshBarAxis]) { - var max = this._overlapSize[this._refreshBarAxis]; - if (max == 0) - max = Math.max(this._contentSize[this._refreshBarAxis] + this._footerLockedSize - this._viewSize[this._refreshBarAxis], 0); - else - max += this._footerLockedSize; - sEndPos[this._refreshBarAxis] = -max; - this._tweenChange.x = sEndPos.x - this._tweenStart.x; - this._tweenChange.y = sEndPos.y - this._tweenStart.y; - } - this._tweenDuration.setTo(TWEEN_TIME_DEFAULT, TWEEN_TIME_DEFAULT); - } - else { - if (!this._inertiaDisabled) { - var frameRate = this._owner.displayObject.stage.frameRate; - var elapsed = (egret.getTimer() / 1000 - this._lastMoveTime) * frameRate - 1; - if (elapsed > 1) { - var factor = Math.pow(0.833, elapsed); - this._velocity.x = this._velocity.x * factor; - this._velocity.y = this._velocity.y * factor; - } - this.updateTargetAndDuration(this._tweenStart, sEndPos); - } - else - this._tweenDuration.setTo(TWEEN_TIME_DEFAULT, TWEEN_TIME_DEFAULT); - sOldChange.setTo(sEndPos.x - this._tweenStart.x, sEndPos.y - this._tweenStart.y); - this.loopCheckingTarget(sEndPos); - if (this._pageMode || this._snapToItem) - this.alignPosition(sEndPos, true); - this._tweenChange.x = sEndPos.x - this._tweenStart.x; - this._tweenChange.y = sEndPos.y - this._tweenStart.y; - if (this._tweenChange.x == 0 && this._tweenChange.y == 0) { - this.updateScrollBarVisible(); - return; - } - if (this._pageMode || this._snapToItem) { - this.fixDuration("x", sOldChange.x); - this.fixDuration("y", sOldChange.y); - } - } - this.startTween(2); - }; - ScrollPane.prototype.__touchTap = function (evt) { - this._dragged = false; - }; - ScrollPane.prototype.updateScrollBarPos = function () { - if (this._vtScrollBar) - this._vtScrollBar.setScrollPerc(this._overlapSize.y == 0 ? 0 : fgui.ToolSet.clamp(-this._container.y, 0, this._overlapSize.y) / this._overlapSize.y); - if (this._hzScrollBar) - this._hzScrollBar.setScrollPerc(this._overlapSize.x == 0 ? 0 : fgui.ToolSet.clamp(-this._container.x, 0, this._overlapSize.x) / this._overlapSize.x); - this.checkRefreshBar(); - }; - ScrollPane.prototype.updateScrollBarVisible = function () { - if (this._vtScrollBar) { - if (this._viewSize.y <= this._vtScrollBar.minSize || this._vScrollNone) - this._vtScrollBar.displayObject.visible = false; - else - this.updateScrollBarVisible2(this._vtScrollBar); - } - if (this._hzScrollBar) { - if (this._viewSize.x <= this._hzScrollBar.minSize || this._hScrollNone) - this._hzScrollBar.displayObject.visible = false; - else - this.updateScrollBarVisible2(this._hzScrollBar); - } - }; - ScrollPane.prototype.updateScrollBarVisible2 = function (bar) { - if (this._scrollBarDisplayAuto) - fgui.GTween.kill(bar, false, "alpha"); - if (this._scrollBarDisplayAuto && this._tweening == 0 && !this._dragged && !bar.gripDragging) { - if (bar.displayObject.visible) - fgui.GTween.to(1, 0, 0.5).setDelay(0.5).onComplete(this.__barTweenComplete, this).setTarget(bar, "alpha"); - } - else { - bar.alpha = 1; - bar.displayObject.visible = true; - } - }; - ScrollPane.prototype.__barTweenComplete = function (tweener) { - var bar = (tweener.target); - bar.alpha = 1; - bar.displayObject.visible = false; - }; - ScrollPane.prototype.getLoopPartSize = function (division, axis) { - return (this._contentSize[axis] + (axis == "x" ? this._owner.columnGap : this._owner.lineGap)) / division; - }; - ScrollPane.prototype.loopCheckingCurrent = function () { - var changed = false; - if (this._loop == 1 && this._overlapSize.x > 0) { - if (this._xPos < 0.001) { - this._xPos += this.getLoopPartSize(2, "x"); - changed = true; - } - else if (this._xPos >= this._overlapSize.x) { - this._xPos -= this.getLoopPartSize(2, "x"); - changed = true; - } - } - else if (this._loop == 2 && this._overlapSize.y > 0) { - if (this._yPos < 0.001) { - this._yPos += this.getLoopPartSize(2, "y"); - changed = true; - } - else if (this._yPos >= this._overlapSize.y) { - this._yPos -= this.getLoopPartSize(2, "y"); - changed = true; - } - } - if (changed) { - this._container.x = Math.floor(-this._xPos); - this._container.y = Math.floor(-this._yPos); - } - return changed; - }; - ScrollPane.prototype.loopCheckingTarget = function (endPos) { - if (this._loop == 1) - this.loopCheckingTarget2(endPos, "x"); - if (this._loop == 2) - this.loopCheckingTarget2(endPos, "y"); - }; - ScrollPane.prototype.loopCheckingTarget2 = function (endPos, axis) { - var halfSize; - var tmp; - if (endPos[axis] > 0) { - halfSize = this.getLoopPartSize(2, axis); - tmp = this._tweenStart[axis] - halfSize; - if (tmp <= 0 && tmp >= -this._overlapSize[axis]) { - endPos[axis] -= halfSize; - this._tweenStart[axis] = tmp; - } - } - else if (endPos[axis] < -this._overlapSize[axis]) { - halfSize = this.getLoopPartSize(2, axis); - tmp = this._tweenStart[axis] + halfSize; - if (tmp <= 0 && tmp >= -this._overlapSize[axis]) { - endPos[axis] += halfSize; - this._tweenStart[axis] = tmp; - } - } - }; - ScrollPane.prototype.loopCheckingNewPos = function (value, axis) { - if (this._overlapSize[axis] == 0) - return value; - var pos = axis == "x" ? this._xPos : this._yPos; - var changed = false; - var v; - if (value < 0.001) { - value += this.getLoopPartSize(2, axis); - if (value > pos) { - v = this.getLoopPartSize(6, axis); - v = Math.ceil((value - pos) / v) * v; - pos = fgui.ToolSet.clamp(pos + v, 0, this._overlapSize[axis]); - changed = true; - } - } - else if (value >= this._overlapSize[axis]) { - value -= this.getLoopPartSize(2, axis); - if (value < pos) { - v = this.getLoopPartSize(6, axis); - v = Math.ceil((pos - value) / v) * v; - pos = fgui.ToolSet.clamp(pos - v, 0, this._overlapSize[axis]); - changed = true; - } - } - if (changed) { - if (axis == "x") - this._container.x = -Math.floor(pos); - else - this._container.y = -Math.floor(pos); - } - return value; - }; - ScrollPane.prototype.alignPosition = function (pos, inertialScrolling) { - if (this._pageMode) { - pos.x = this.alignByPage(pos.x, "x", inertialScrolling); - pos.y = this.alignByPage(pos.y, "y", inertialScrolling); - } - else if (this._snapToItem) { - var pt = this._owner.getSnappingPosition(-pos.x, -pos.y, s_vec2); - if (pos.x < 0 && pos.x > -this._overlapSize.x) - pos.x = -pt.x; - if (pos.y < 0 && pos.y > -this._overlapSize.y) - pos.y = -pt.y; - } - }; - ScrollPane.prototype.alignByPage = function (pos, axis, inertialScrolling) { - var page; - if (pos > 0) - page = 0; - else if (pos < -this._overlapSize[axis]) - page = Math.ceil(this._contentSize[axis] / this._pageSize[axis]) - 1; - else { - page = Math.floor(-pos / this._pageSize[axis]); - var change = inertialScrolling ? (pos - this._containerPos[axis]) : (pos - this._container[axis]); - var testPageSize = Math.min(this._pageSize[axis], this._contentSize[axis] - (page + 1) * this._pageSize[axis]); - var delta = -pos - page * this._pageSize[axis]; - if (Math.abs(change) > this._pageSize[axis]) { - if (delta > testPageSize * 0.5) - page++; - } - else { - if (delta > testPageSize * (change < 0 ? 0.3 : 0.7)) - page++; - } - pos = -page * this._pageSize[axis]; - if (pos < -this._overlapSize[axis]) - pos = -this._overlapSize[axis]; - } - if (inertialScrolling) { - var oldPos = this._tweenStart[axis]; - var oldPage; - if (oldPos > 0) - oldPage = 0; - else if (oldPos < -this._overlapSize[axis]) - oldPage = Math.ceil(this._contentSize[axis] / this._pageSize[axis]) - 1; - else - oldPage = Math.floor(-oldPos / this._pageSize[axis]); - var startPage = Math.floor(-this._containerPos[axis] / this._pageSize[axis]); - if (Math.abs(page - startPage) > 1 && Math.abs(oldPage - startPage) <= 1) { - if (page > startPage) - page = startPage + 1; - else - page = startPage - 1; - pos = -page * this._pageSize[axis]; - } - } - return pos; - }; - ScrollPane.prototype.updateTargetAndDuration = function (orignPos, resultPos) { - resultPos.x = this.updateTargetAndDuration2(orignPos.x, "x"); - resultPos.y = this.updateTargetAndDuration2(orignPos.y, "y"); - }; - ScrollPane.prototype.updateTargetAndDuration2 = function (pos, axis) { - var v = this._velocity[axis]; - var duration = 0; - if (pos > 0) - pos = 0; - else if (pos < -this._overlapSize[axis]) - pos = -this._overlapSize[axis]; - else { - var isMobile = egret.Capabilities.isMobile; - var v2 = Math.abs(v) * this._velocityScale; - if (isMobile) - v2 *= 1136 / Math.max(this._owner.displayObject.stage.stageWidth, this._owner.displayObject.stage.stageHeight); - var ratio = 0; - if (this._pageMode || !isMobile) { - if (v2 > 500) - ratio = Math.pow((v2 - 500) / 500, 2); - } - else { - if (v2 > 1000) - ratio = Math.pow((v2 - 1000) / 1000, 2); - } - if (ratio != 0) { - if (ratio > 1) - ratio = 1; - v2 *= ratio; - v *= ratio; - this._velocity[axis] = v; - duration = Math.log(60 / v2) / Math.log(this._decelerationRate) / 60; - var change = Math.floor(v * duration * 0.4); - pos += change; - } - } - if (duration < TWEEN_TIME_DEFAULT) - duration = TWEEN_TIME_DEFAULT; - this._tweenDuration[axis] = duration; - return pos; - }; - ScrollPane.prototype.fixDuration = function (axis, oldChange) { - if (this._tweenChange[axis] == 0 || Math.abs(this._tweenChange[axis]) >= Math.abs(oldChange)) - return; - var newDuration = Math.abs(this._tweenChange[axis] / oldChange) * this._tweenDuration[axis]; - if (newDuration < TWEEN_TIME_DEFAULT) - newDuration = TWEEN_TIME_DEFAULT; - this._tweenDuration[axis] = newDuration; - }; - ScrollPane.prototype.startTween = function (type) { - this._tweenTime.setTo(0, 0); - this._tweening = type; - fgui.GTimers.inst.add(1, 0, this.tweenUpdate, this); - this.updateScrollBarVisible(); - }; - ScrollPane.prototype.killTween = function () { - if (this._tweening == 1) { - this._container.x = this._tweenStart.x + this._tweenChange.x; - this._container.y = this._tweenStart.y + this._tweenChange.y; - this.dispatchEventWith(ScrollPane.SCROLL); - } - this._tweening = 0; - fgui.GTimers.inst.remove(this.tweenUpdate, this); - this.updateScrollBarVisible(); - this.dispatchEventWith(ScrollPane.SCROLL_END); - }; - ScrollPane.prototype.checkRefreshBar = function () { - if (this._header == null && this._footer == null) - return; - var pos = this._container[this._refreshBarAxis]; - if (this._header) { - if (pos > 0) { - if (this._header.displayObject.parent == null) - this._maskContainer.addChildAt(this._header.displayObject, 0); - var pt = s_vec2; - pt.setTo(this._header.width, this._header.height); - pt[this._refreshBarAxis] = pos; - this._header.setSize(pt.x, pt.y); - } - else { - if (this._header.displayObject.parent) - this._maskContainer.removeChild(this._header.displayObject); - } - } - if (this._footer) { - var max = this._overlapSize[this._refreshBarAxis]; - if (pos < -max || max == 0 && this._footerLockedSize > 0) { - if (this._footer.displayObject.parent == null) - this._maskContainer.addChildAt(this._footer.displayObject, 0); - pt = s_vec2; - pt.setTo(this._footer.x, this._footer.y); - if (max > 0) - pt[this._refreshBarAxis] = pos + this._contentSize[this._refreshBarAxis]; - else - pt[this._refreshBarAxis] = Math.max(Math.min(pos + this._viewSize[this._refreshBarAxis], this._viewSize[this._refreshBarAxis] - this._footerLockedSize), this._viewSize[this._refreshBarAxis] - this._contentSize[this._refreshBarAxis]); - this._footer.setXY(pt.x, pt.y); - pt.setTo(this._footer.width, this._footer.height); - if (max > 0) - pt[this._refreshBarAxis] = -max - pos; - else - pt[this._refreshBarAxis] = this._viewSize[this._refreshBarAxis] - this._footer[this._refreshBarAxis]; - this._footer.setSize(pt.x, pt.y); - } - else { - if (this._footer.displayObject.parent) - this._maskContainer.removeChild(this._footer.displayObject); - } - } - }; - ScrollPane.prototype.tweenUpdate = function (timestamp) { - var nx = this.runTween("x"); - var ny = this.runTween("y"); - this._container.x = nx; - this._container.y = ny; - if (this._tweening == 2) { - if (this._overlapSize.x > 0) - this._xPos = fgui.ToolSet.clamp(-nx, 0, this._overlapSize.x); - if (this._overlapSize.y > 0) - this._yPos = fgui.ToolSet.clamp(-ny, 0, this._overlapSize.y); - if (this._pageMode) - this.updatePageController(); - } - if (this._tweenChange.x == 0 && this._tweenChange.y == 0) { - this._tweening = 0; - fgui.GTimers.inst.remove(this.tweenUpdate, this); - this.loopCheckingCurrent(); - this.updateScrollBarPos(); - this.updateScrollBarVisible(); - this.dispatchEventWith(ScrollPane.SCROLL); - this.dispatchEventWith(ScrollPane.SCROLL_END); - } - else { - this.updateScrollBarPos(); - this.dispatchEventWith(ScrollPane.SCROLL); - } - return true; - }; - ScrollPane.prototype.runTween = function (axis) { - var newValue; - if (this._tweenChange[axis] != 0) { - this._tweenTime[axis] += fgui.GTimers.deltaTime / 1000; - if (this._tweenTime[axis] >= this._tweenDuration[axis]) { - newValue = this._tweenStart[axis] + this._tweenChange[axis]; - this._tweenChange[axis] = 0; - } - else { - var ratio = easeFunc(this._tweenTime[axis], this._tweenDuration[axis]); - newValue = this._tweenStart[axis] + Math.floor(this._tweenChange[axis] * ratio); - } - var threshold1 = 0; - var threshold2 = -this._overlapSize[axis]; - if (this._headerLockedSize > 0 && this._refreshBarAxis == axis) - threshold1 = this._headerLockedSize; - if (this._footerLockedSize > 0 && this._refreshBarAxis == axis) { - var max = this._overlapSize[this._refreshBarAxis]; - if (max == 0) - max = Math.max(this._contentSize[this._refreshBarAxis] + this._footerLockedSize - this._viewSize[this._refreshBarAxis], 0); - else - max += this._footerLockedSize; - threshold2 = -max; - } - if (this._tweening == 2 && this._bouncebackEffect) { - if (newValue > 20 + threshold1 && this._tweenChange[axis] > 0 - || newValue > threshold1 && this._tweenChange[axis] == 0) { - this._tweenTime[axis] = 0; - this._tweenDuration[axis] = TWEEN_TIME_DEFAULT; - this._tweenChange[axis] = -newValue + threshold1; - this._tweenStart[axis] = newValue; - } - else if (newValue < threshold2 - 20 && this._tweenChange[axis] < 0 - || newValue < threshold2 && this._tweenChange[axis] == 0) { - this._tweenTime[axis] = 0; - this._tweenDuration[axis] = TWEEN_TIME_DEFAULT; - this._tweenChange[axis] = threshold2 - newValue; - this._tweenStart[axis] = newValue; - } - } - else { - if (newValue > threshold1) { - newValue = threshold1; - this._tweenChange[axis] = 0; - } - else if (newValue < threshold2) { - newValue = threshold2; - this._tweenChange[axis] = 0; - } - } - } - else - newValue = this._container[axis]; - return newValue; - }; - ScrollPane.SCROLL = "__scroll"; - ScrollPane.SCROLL_END = "__scrollEnd"; - ScrollPane.PULL_DOWN_RELEASE = "pullDownRelease"; - ScrollPane.PULL_UP_RELEASE = "pullUpRelease"; - return ScrollPane; - }(egret.EventDispatcher)); - fgui.ScrollPane = ScrollPane; - var _gestureFlag = 0; - var TWEEN_TIME_GO = 0.5; - var TWEEN_TIME_DEFAULT = 0.3; - var PULL_RATIO = 0.5; - var s_vec2 = new egret.Point(); - var s_rect = new egret.Rectangle(); - var sEndPos = new egret.Point(); - var sOldChange = new egret.Point(); - function easeFunc(t, d) { - return (t = t / d - 1) * t * t + 1; - } -})(fgui || (fgui = {})); - -(function (fgui) { - var Transition = (function () { - function Transition(owner) { - this._ownerBaseX = 0; - this._ownerBaseY = 0; - this._totalTimes = 0; - this._totalTasks = 0; - this._options = 0; - this._totalDuration = 0; - this._autoPlayTimes = 1; - this._autoPlayDelay = 0; - this._timeScale = 1; - this._startTime = 0; - this._endTime = 0; - this._owner = owner; - this._items = new Array(); - } - Transition.prototype.play = function (onComplete, onCompleteObj, onCompleteParam, times, delay, startTime, endTime) { - this._play(onComplete, onCompleteObj, onCompleteParam, times, delay, startTime, endTime, false); - }; - Transition.prototype.playReverse = function (onComplete, onCompleteObj, onCompleteParam, times, delay) { - this._play(onComplete, onCompleteObj, onCompleteParam, times, delay, 0, -1, true); - }; - Transition.prototype.changePlayTimes = function (value) { - this._totalTimes = value; - }; - Transition.prototype.setAutoPlay = function (value, times, delay) { - if (times == undefined) - times = -1; - if (delay == undefined) - delay = 0; - if (this._autoPlay != value) { - this._autoPlay = value; - this._autoPlayTimes = times; - this._autoPlayDelay = delay; - if (this._autoPlay) { - if (this._owner.onStage) - this.play(null, null, this._autoPlayTimes, this._autoPlayDelay); - } - else { - if (!this._owner.onStage) - this.stop(false, true); - } - } - }; - Transition.prototype._play = function (onComplete, onCompleteCaller, onCompleteParam, times, delay, startTime, endTime, reversed) { - if (times == undefined) - times = 1; - if (delay == undefined) - delay = 0; - if (startTime == undefined) - startTime = 0; - if (endTime == undefined) - endTime = -1; - this.stop(true, true); - this._totalTimes = times; - this._reversed = reversed; - this._startTime = startTime; - this._endTime = endTime; - this._playing = true; - this._paused = false; - this._onComplete = onComplete; - this._onCompleteParam = onCompleteParam; - this._onCompleteCaller = onCompleteCaller; - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (!item.target) { - if (item.targetId) - item.target = this._owner.getChildById(item.targetId); - else - item.target = this._owner; - } - else if (item.target != this._owner && item.target.parent != this._owner) - item.target = null; - if (item.target && item.type == ActionType.Transition) { - var trans = item.target.getTransition(item.value.transName); - if (trans == this) - trans = null; - if (trans) { - if (item.value.playTimes == 0) { - var j; - for (j = i - 1; j >= 0; j--) { - var item2 = this._items[j]; - if (item2.type == ActionType.Transition) { - if (item2.value.trans == trans) { - item2.value.stopTime = item.time - item2.time; - break; - } - } - } - if (j < 0) - item.value.stopTime = 0; - else - trans = null; - } - else - item.value.stopTime = -1; - } - item.value.trans = trans; - } - } - if (delay == 0) - this.onDelayedPlay(); - else - fgui.GTween.delayedCall(delay).onComplete(this.onDelayedPlay, this); - }; - Transition.prototype.stop = function (setToComplete, processCallback) { - if (setToComplete == undefined) - setToComplete = true; - if (!this._playing) - return; - this._playing = false; - this._totalTasks = 0; - this._totalTimes = 0; - var func = this._onComplete; - var param = this._onCompleteParam; - var thisObj = this._onCompleteCaller; - this._onComplete = null; - this._onCompleteParam = null; - this._onCompleteCaller = null; - fgui.GTween.kill(this); - var cnt = this._items.length; - if (this._reversed) { - for (var i = cnt - 1; i >= 0; i--) { - var item = this._items[i]; - if (!item.target) - continue; - this.stopItem(item, setToComplete); - } - } - else { - for (i = 0; i < cnt; i++) { - item = this._items[i]; - if (!item.target) - continue; - this.stopItem(item, setToComplete); - } - } - if (processCallback && func != null) { - func.call(thisObj, param); - } - }; - Transition.prototype.stopItem = function (item, setToComplete) { - if (item.displayLockToken != 0) { - item.target.releaseDisplayLock(item.displayLockToken); - item.displayLockToken = 0; - } - if (item.tweener) { - item.tweener.kill(setToComplete); - item.tweener = null; - if (item.type == ActionType.Shake && !setToComplete) { - item.target._gearLocked = true; - item.target.setXY(item.target.x - item.value.lastOffsetX, item.target.y - item.value.lastOffsetY); - item.target._gearLocked = false; - } - } - if (item.type == ActionType.Transition) { - var trans = item.value.trans; - if (trans) - trans.stop(setToComplete, false); - } - }; - Transition.prototype.setPaused = function (paused) { - if (!this._playing || this._paused == paused) - return; - this._paused = paused; - var tweener = fgui.GTween.getTween(this); - if (tweener) - tweener.setPaused(paused); - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (!item.target) - continue; - if (item.type == ActionType.Transition) { - if (item.value.trans) - item.value.trans.setPaused(paused); - } - else if (item.type == ActionType.Animation) { - if (paused) { - item.value.flag = item.target.getProp(fgui.ObjectPropID.Playing); - item.target.setProp(fgui.ObjectPropID.Playing, false); - } - else - item.target.setProp(fgui.ObjectPropID.Playing, item.value.flag); - } - if (item.tweener) - item.tweener.setPaused(paused); - } - }; - Transition.prototype.dispose = function () { - if (this._playing) - fgui.GTween.kill(this); - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.tweener) { - item.tweener.kill(); - item.tweener = null; - } - item.target = null; - item.hook = null; - if (item.tweenConfig) - item.tweenConfig.endHook = null; - } - this._items.length = 0; - this._playing = false; - this._onComplete = null; - this._onCompleteCaller = null; - this._onCompleteParam = null; - }; - Object.defineProperty(Transition.prototype, "playing", { - get: function () { - return this._playing; - }, - enumerable: true, - configurable: true - }); - Transition.prototype.setValue = function (label) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - var cnt = this._items.length; - var value; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.label == label) { - if (item.tweenConfig) - value = item.tweenConfig.startValue; - else - value = item.value; - } - else if (item.tweenConfig && item.tweenConfig.endLabel == label) { - value = item.tweenConfig.endValue; - } - else - continue; - switch (item.type) { - case ActionType.XY: - case ActionType.Size: - case ActionType.Pivot: - case ActionType.Scale: - case ActionType.Skew: - value.b1 = true; - value.b2 = true; - value.f1 = parseFloat(args[0]); - value.f2 = parseFloat(args[1]); - break; - case ActionType.Alpha: - value.f1 = parseFloat(args[0]); - break; - case ActionType.Rotation: - value.f1 = parseFloat(args[0]); - break; - case ActionType.Color: - value.f1 = parseFloat(args[0]); - break; - case ActionType.Animation: - value.frame = parseInt(args[0]); - if (args.length > 1) - value.playing = args[1]; - break; - case ActionType.Visible: - value.visible = args[0]; - break; - case ActionType.Sound: - value.sound = args[0]; - if (args.length > 1) - value.volume = parseFloat(args[1]); - break; - case ActionType.Transition: - value.transName = args[0]; - if (args.length > 1) - value.playTimes = parseInt(args[1]); - break; - case ActionType.Shake: - value.amplitude = parseFloat(args[0]); - if (args.length > 1) - value.duration = parseFloat(args[1]); - break; - case ActionType.ColorFilter: - value.f1 = parseFloat(args[0]); - value.f2 = parseFloat(args[1]); - value.f3 = parseFloat(args[2]); - value.f4 = parseFloat(args[3]); - break; - case ActionType.Text: - case ActionType.Icon: - value.text = args[0]; - break; - } - } - }; - Transition.prototype.setHook = function (label, callback, caller) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.label == label) { - item.hook = callback; - item.hookCaller = caller; - break; - } - else if (item.tweenConfig && item.tweenConfig.endLabel == label) { - item.tweenConfig.endHook = callback; - item.tweenConfig.endHookCaller = caller; - break; - } - } - }; - Transition.prototype.clearHooks = function () { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - item.hook = null; - item.hookCaller = null; - if (item.tweenConfig) { - item.tweenConfig.endHook = null; - item.tweenConfig.endHookCaller = null; - } - } - }; - Transition.prototype.setTarget = function (label, newTarget) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.label == label) { - item.targetId = (newTarget == this._owner || !newTarget) ? "" : newTarget.id; - if (this._playing) { - if (item.targetId.length > 0) - item.target = this._owner.getChildById(item.targetId); - else - item.target = this._owner; - } - else - item.target = null; - } - } - }; - Transition.prototype.setDuration = function (label, value) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.tweenConfig && item.label == label) - item.tweenConfig.duration = value; - } - }; - Transition.prototype.getLabelTime = function (label) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.label == label) - return item.time; - else if (item.tweenConfig && item.tweenConfig.endLabel == label) - return item.time + item.tweenConfig.duration; - } - return Number.NaN; - }; - Object.defineProperty(Transition.prototype, "timeScale", { - get: function () { - return this._timeScale; - }, - set: function (value) { - if (this._timeScale != value) { - this._timeScale = value; - if (this._playing) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.tweener) - item.tweener.setTimeScale(value); - else if (item.type == ActionType.Transition) { - if (item.value.trans) - item.value.trans.timeScale = value; - } - else if (item.type == ActionType.Animation) { - if (item.target) - item.target.setProp(fgui.ObjectPropID.TimeScale, value); - } - } - } - } - }, - enumerable: true, - configurable: true - }); - Transition.prototype.updateFromRelations = function (targetId, dx, dy) { - var cnt = this._items.length; - if (cnt == 0) - return; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.type == ActionType.XY && item.targetId == targetId) { - if (item.tweenConfig) { - item.tweenConfig.startValue.f1 += dx; - item.tweenConfig.startValue.f2 += dy; - item.tweenConfig.endValue.f1 += dx; - item.tweenConfig.endValue.f2 += dy; - } - else { - item.value.f1 += dx; - item.value.f2 += dy; - } - } - } - }; - Transition.prototype.onOwnerAddedToStage = function () { - if (this._autoPlay && !this._playing) - this.play(null, null, null, this._autoPlayTimes, this._autoPlayDelay); - }; - Transition.prototype.onOwnerRemovedFromStage = function () { - if ((this._options & OPTION_AUTO_STOP_DISABLED) == 0) - this.stop((this._options & OPTION_AUTO_STOP_AT_END) != 0 ? true : false, false); - }; - Transition.prototype.onDelayedPlay = function () { - this.internalPlay(); - this._playing = this._totalTasks > 0; - if (this._playing) { - if ((this._options & OPTION_IGNORE_DISPLAY_CONTROLLER) != 0) { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.target && item.target != this._owner) - item.displayLockToken = item.target.addDisplayLock(); - } - } - } - else if (this._onComplete != null) { - var func = this._onComplete; - var param = this._onCompleteParam; - var thisObj = this._onCompleteCaller; - this._onComplete = null; - this._onCompleteParam = null; - this._onCompleteCaller = null; - func.call(thisObj, param); - } - }; - Transition.prototype.internalPlay = function () { - this._ownerBaseX = this._owner.x; - this._ownerBaseY = this._owner.y; - this._totalTasks = 0; - var cnt = this._items.length; - var item; - var needSkipAnimations = false; - var i; - if (!this._reversed) { - for (i = 0; i < cnt; i++) { - item = this._items[i]; - if (!item.target) - continue; - if (item.type == ActionType.Animation && this._startTime != 0 && item.time <= this._startTime) { - needSkipAnimations = true; - item.value.flag = false; - } - else - this.playItem(item); - } - } - else { - for (i = cnt - 1; i >= 0; i--) { - item = this._items[i]; - if (!item.target) - continue; - this.playItem(item); - } - } - if (needSkipAnimations) - this.skipAnimations(); - }; - Transition.prototype.playItem = function (item) { - var time; - if (item.tweenConfig) { - if (this._reversed) - time = (this._totalDuration - item.time - item.tweenConfig.duration); - else - time = item.time; - if (this._endTime == -1 || time <= this._endTime) { - var startValue; - var endValue; - if (this._reversed) { - startValue = item.tweenConfig.endValue; - endValue = item.tweenConfig.startValue; - } - else { - startValue = item.tweenConfig.startValue; - endValue = item.tweenConfig.endValue; - } - item.value.b1 = startValue.b1 || endValue.b1; - item.value.b2 = startValue.b2 || endValue.b2; - switch (item.type) { - case ActionType.XY: - case ActionType.Size: - case ActionType.Scale: - case ActionType.Skew: - item.tweener = fgui.GTween.to2(startValue.f1, startValue.f2, endValue.f1, endValue.f2, item.tweenConfig.duration); - break; - case ActionType.Alpha: - case ActionType.Rotation: - item.tweener = fgui.GTween.to(startValue.f1, endValue.f1, item.tweenConfig.duration); - break; - case ActionType.Color: - item.tweener = fgui.GTween.toColor(startValue.f1, endValue.f1, item.tweenConfig.duration); - break; - case ActionType.ColorFilter: - item.tweener = fgui.GTween.to4(startValue.f1, startValue.f2, startValue.f3, startValue.f4, endValue.f1, endValue.f2, endValue.f3, endValue.f4, item.tweenConfig.duration); - break; - } - item.tweener.setDelay(time) - .setEase(item.tweenConfig.easeType) - .setRepeat(item.tweenConfig.repeat, item.tweenConfig.yoyo) - .setTimeScale(this._timeScale) - .setTarget(item) - .onStart(this.onTweenStart, this) - .onUpdate(this.onTweenUpdate, this) - .onComplete(this.onTweenComplete, this); - if (this._endTime >= 0) - item.tweener.setBreakpoint(this._endTime - time); - this._totalTasks++; - } - } - else if (item.type == ActionType.Shake) { - if (this._reversed) - time = (this._totalDuration - item.time - item.value.duration); - else - time = item.time; - item.value.offsetX = item.value.offsetY = 0; - item.value.lastOffsetX = item.value.lastOffsetY = 0; - item.tweener = fgui.GTween.shake(0, 0, item.value.amplitude, item.value.duration) - .setDelay(time) - .setTimeScale(this._timeScale) - .setTarget(item) - .onUpdate(this.onTweenUpdate, this) - .onComplete(this.onTweenComplete, this); - if (this._endTime >= 0) - item.tweener.setBreakpoint(this._endTime - item.time); - this._totalTasks++; - } - else { - if (this._reversed) - time = (this._totalDuration - item.time); - else - time = item.time; - if (time <= this._startTime) { - this.applyValue(item); - this.callHook(item, false); - } - else if (this._endTime == -1 || time <= this._endTime) { - this._totalTasks++; - item.tweener = fgui.GTween.delayedCall(time) - .setTimeScale(this._timeScale) - .setTarget(item) - .onComplete(this.onDelayedPlayItem, this); - } - } - if (item.tweener != null) - item.tweener.seek(this._startTime); - }; - Transition.prototype.skipAnimations = function () { - var frame; - var playStartTime; - var playTotalTime; - var value; - var target; - var item; - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - item = this._items[i]; - if (item.type != ActionType.Animation || item.time > this._startTime) - continue; - value = item.value; - if (value.flag) - continue; - target = item.target; - frame = target.getProp(fgui.ObjectPropID.Frame); - playStartTime = target.getProp(fgui.ObjectPropID.Playing) ? 0 : -1; - playTotalTime = 0; - for (var j = i; j < cnt; j++) { - item = this._items[j]; - if (item.type != ActionType.Animation || item.target != target || item.time > this._startTime) - continue; - value = item.value; - value.flag = true; - if (value.frame != -1) { - frame = value.frame; - if (value.playing) - playStartTime = item.time; - else - playStartTime = -1; - playTotalTime = 0; - } - else { - if (value.playing) { - if (playStartTime < 0) - playStartTime = item.time; - } - else { - if (playStartTime >= 0) - playTotalTime += (item.time - playStartTime); - playStartTime = -1; - } - } - this.callHook(item, false); - } - if (playStartTime >= 0) - playTotalTime += (this._startTime - playStartTime); - target.setProp(fgui.ObjectPropID.Playing, playStartTime >= 0); - target.setProp(fgui.ObjectPropID.Frame, frame); - if (playTotalTime > 0) - target.setProp(fgui.ObjectPropID.DeltaTime, playTotalTime * 1000); - } - }; - Transition.prototype.onDelayedPlayItem = function (tweener) { - var item = tweener.target; - item.tweener = null; - this._totalTasks--; - this.applyValue(item); - this.callHook(item, false); - this.checkAllComplete(); - }; - Transition.prototype.onTweenStart = function (tweener) { - var item = tweener.target; - if (item.type == ActionType.XY || item.type == ActionType.Size) { - var startValue; - var endValue; - if (this._reversed) { - startValue = item.tweenConfig.endValue; - endValue = item.tweenConfig.startValue; - } - else { - startValue = item.tweenConfig.startValue; - endValue = item.tweenConfig.endValue; - } - if (item.type == ActionType.XY) { - if (item.target != this._owner) { - if (!startValue.b1) - tweener.startValue.x = item.target.x; - else if (startValue.b3) - tweener.startValue.x = startValue.f1 * this._owner.width; - if (!startValue.b2) - tweener.startValue.y = item.target.y; - else if (startValue.b3) - tweener.startValue.y = startValue.f2 * this._owner.height; - if (!endValue.b1) - tweener.endValue.x = tweener.startValue.x; - else if (endValue.b3) - tweener.endValue.x = endValue.f1 * this._owner.width; - if (!endValue.b2) - tweener.endValue.y = tweener.startValue.y; - else if (endValue.b3) - tweener.endValue.y = endValue.f2 * this._owner.height; - } - else { - if (!startValue.b1) - tweener.startValue.x = item.target.x - this._ownerBaseX; - if (!startValue.b2) - tweener.startValue.y = item.target.y - this._ownerBaseY; - if (!endValue.b1) - tweener.endValue.x = tweener.startValue.x; - if (!endValue.b2) - tweener.endValue.y = tweener.startValue.y; - } - } - else { - if (!startValue.b1) - tweener.startValue.x = item.target.width; - if (!startValue.b2) - tweener.startValue.y = item.target.height; - if (!endValue.b1) - tweener.endValue.x = tweener.startValue.x; - if (!endValue.b2) - tweener.endValue.y = tweener.startValue.y; - } - if (item.tweenConfig.path) { - item.value.b1 = item.value.b2 = true; - tweener.setPath(item.tweenConfig.path); - } - } - this.callHook(item, false); - }; - Transition.prototype.onTweenUpdate = function (tweener) { - var item = tweener.target; - switch (item.type) { - case ActionType.XY: - case ActionType.Size: - case ActionType.Scale: - case ActionType.Skew: - item.value.f1 = tweener.value.x; - item.value.f2 = tweener.value.y; - if (item.tweenConfig.path) { - item.value.f1 += tweener.startValue.x; - item.value.f2 += tweener.startValue.y; - } - break; - case ActionType.Alpha: - case ActionType.Rotation: - item.value.f1 = tweener.value.x; - break; - case ActionType.Color: - item.value.f1 = tweener.value.color; - break; - case ActionType.ColorFilter: - item.value.f1 = tweener.value.x; - item.value.f2 = tweener.value.y; - item.value.f3 = tweener.value.z; - item.value.f4 = tweener.value.w; - break; - case ActionType.Shake: - item.value.offsetX = tweener.deltaValue.x; - item.value.offsetY = tweener.deltaValue.y; - break; - } - this.applyValue(item); - }; - Transition.prototype.onTweenComplete = function (tweener) { - var item = tweener.target; - item.tweener = null; - this._totalTasks--; - if (tweener.allCompleted) - this.callHook(item, true); - this.checkAllComplete(); - }; - Transition.prototype.onPlayTransCompleted = function (item) { - this._totalTasks--; - this.checkAllComplete(); - }; - Transition.prototype.callHook = function (item, tweenEnd) { - if (tweenEnd) { - if (item.tweenConfig && item.tweenConfig.endHook) - item.tweenConfig.endHook.call(item.tweenConfig.endHookCaller); - } - else { - if (item.time >= this._startTime && item.hook != null) - item.hook.call(item.hookCaller); - } - }; - Transition.prototype.checkAllComplete = function () { - if (this._playing && this._totalTasks == 0) { - if (this._totalTimes < 0) { - this.internalPlay(); - } - else { - this._totalTimes--; - if (this._totalTimes > 0) - this.internalPlay(); - else { - this._playing = false; - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var item = this._items[i]; - if (item.target && item.displayLockToken != 0) { - item.target.releaseDisplayLock(item.displayLockToken); - item.displayLockToken = 0; - } - } - if (this._onComplete != null) { - var func = this._onComplete; - var param = this._onCompleteParam; - var thisObj = this._onCompleteCaller; - this._onComplete = null; - this._onCompleteParam = null; - this._onCompleteCaller = null; - func.call(thisObj, param); - } - } - } - } - }; - Transition.prototype.applyValue = function (item) { - item.target._gearLocked = true; - var value = item.value; - switch (item.type) { - case ActionType.XY: - if (item.target == this._owner) { - if (value.b1 && value.b2) - item.target.setXY(value.f1 + this._ownerBaseX, value.f2 + this._ownerBaseY); - else if (value.b1) - item.target.x = value.f1 + this._ownerBaseX; - else - item.target.y = value.f2 + this._ownerBaseY; - } - else { - if (value.b3) { - if (value.b1 && value.b2) - item.target.setXY(value.f1 * this._owner.width, value.f2 * this._owner.height); - else if (value.b1) - item.target.x = value.f1 * this._owner.width; - else if (value.b2) - item.target.y = value.f2 * this._owner.height; - } - else { - if (value.b1 && value.b2) - item.target.setXY(value.f1, value.f2); - else if (value.b1) - item.target.x = value.f1; - else if (value.b2) - item.target.y = value.f2; - } - } - break; - case ActionType.Size: - if (!value.b1) - value.f1 = item.target.width; - if (!value.b2) - value.f2 = item.target.height; - item.target.setSize(value.f1, value.f2); - break; - case ActionType.Pivot: - item.target.setPivot(value.f1, value.f2, item.target.pivotAsAnchor); - break; - case ActionType.Alpha: - item.target.alpha = value.f1; - break; - case ActionType.Rotation: - item.target.rotation = value.f1; - break; - case ActionType.Scale: - item.target.setScale(value.f1, value.f2); - break; - case ActionType.Skew: - item.target.setSkew(value.f1, value.f2); - break; - case ActionType.Color: - item.target.setProp(fgui.ObjectPropID.Color, value.f1); - break; - case ActionType.Animation: - if (value.frame >= 0) - item.target.setProp(fgui.ObjectPropID.Frame, value.frame); - item.target.setProp(fgui.ObjectPropID.Playing, value.playing); - item.target.setProp(fgui.ObjectPropID.TimeScale, this._timeScale); - break; - case ActionType.Visible: - item.target.visible = value.visible; - break; - case ActionType.Transition: - if (this._playing) { - var trans = value.trans; - if (trans) { - this._totalTasks++; - var startTime = this._startTime > item.time ? (this._startTime - item.time) : 0; - var endTime = this._endTime >= 0 ? (this._endTime - item.time) : -1; - if (value.stopTime >= 0 && (endTime < 0 || endTime > value.stopTime)) - endTime = value.stopTime; - trans.timeScale = this._timeScale; - trans._play(this.onPlayTransCompleted, this, item, value.playTimes, 0, startTime, endTime, this._reversed); - } - } - break; - case ActionType.Sound: - if (this._playing && item.time >= this._startTime) { - if (!value.audioClip) { - var pi = fgui.UIPackage.getItemByURL(value.sound); - if (pi) - value.audioClip = pi.owner.getItemAsset(pi); - } - if (value.audioClip) - fgui.GRoot.inst.playOneShotSound(value.audioClip, value.volume); - } - break; - case ActionType.Shake: - item.target.setXY(item.target.x - value.lastOffsetX + value.offsetX, item.target.y - value.lastOffsetY + value.offsetY); - value.lastOffsetX = value.offsetX; - value.lastOffsetY = value.offsetY; - break; - case ActionType.ColorFilter: - { - fgui.ToolSet.setColorFilter(item.target.displayObject, [value.f1, value.f2, value.f3, value.f4]); - break; - } - case ActionType.Text: - item.target.text = value.text; - break; - case ActionType.Icon: - item.target.icon = value.text; - break; - } - item.target._gearLocked = false; - }; - Transition.prototype.setup = function (buffer) { - this.name = buffer.readS(); - this._options = buffer.readInt(); - this._autoPlay = buffer.readBool(); - this._autoPlayTimes = buffer.readInt(); - this._autoPlayDelay = buffer.readFloat(); - var cnt = buffer.readShort(); - for (var i = 0; i < cnt; i++) { - var dataLen = buffer.readShort(); - var curPos = buffer.position; - buffer.seek(curPos, 0); - var item = new Item(buffer.readByte()); - this._items[i] = item; - item.time = buffer.readFloat(); - var targetId = buffer.readShort(); - if (targetId < 0) - item.targetId = ""; - else - item.targetId = this._owner.getChildAt(targetId).id; - item.label = buffer.readS(); - if (buffer.readBool()) { - buffer.seek(curPos, 1); - item.tweenConfig = new TweenConfig(); - item.tweenConfig.duration = buffer.readFloat(); - if (item.time + item.tweenConfig.duration > this._totalDuration) - this._totalDuration = item.time + item.tweenConfig.duration; - item.tweenConfig.easeType = buffer.readByte(); - item.tweenConfig.repeat = buffer.readInt(); - item.tweenConfig.yoyo = buffer.readBool(); - item.tweenConfig.endLabel = buffer.readS(); - buffer.seek(curPos, 2); - this.decodeValue(item, buffer, item.tweenConfig.startValue); - buffer.seek(curPos, 3); - this.decodeValue(item, buffer, item.tweenConfig.endValue); - if (buffer.version >= 2) { - var pathLen = buffer.readInt(); - if (pathLen > 0) { - item.tweenConfig.path = new fgui.GPath(); - var pts = new Array(); - for (var j = 0; j < pathLen; j++) { - var curveType = buffer.readByte(); - switch (curveType) { - case fgui.CurveType.Bezier: - pts.push(fgui.GPathPoint.newBezierPoint(buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat())); - break; - case fgui.CurveType.CubicBezier: - pts.push(fgui.GPathPoint.newCubicBezierPoint(buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat(), buffer.readFloat())); - break; - default: - pts.push(fgui.GPathPoint.newPoint(buffer.readFloat(), buffer.readFloat(), curveType)); - break; - } - } - item.tweenConfig.path.create(pts); - } - } - } - else { - if (item.time > this._totalDuration) - this._totalDuration = item.time; - buffer.seek(curPos, 2); - this.decodeValue(item, buffer, item.value); - } - buffer.position = curPos + dataLen; - } - }; - Transition.prototype.decodeValue = function (item, buffer, value) { - switch (item.type) { - case ActionType.XY: - case ActionType.Size: - case ActionType.Pivot: - case ActionType.Skew: - value.b1 = buffer.readBool(); - value.b2 = buffer.readBool(); - value.f1 = buffer.readFloat(); - value.f2 = buffer.readFloat(); - if (buffer.version >= 2 && item.type == ActionType.XY) - value.b3 = buffer.readBool(); - break; - case ActionType.Alpha: - case ActionType.Rotation: - value.f1 = buffer.readFloat(); - break; - case ActionType.Scale: - value.f1 = buffer.readFloat(); - value.f2 = buffer.readFloat(); - break; - case ActionType.Color: - value.f1 = buffer.readColor(); - break; - case ActionType.Animation: - value.playing = buffer.readBool(); - value.frame = buffer.readInt(); - break; - case ActionType.Visible: - value.visible = buffer.readBool(); - break; - case ActionType.Sound: - value.sound = buffer.readS(); - value.volume = buffer.readFloat(); - break; - case ActionType.Transition: - value.transName = buffer.readS(); - value.playTimes = buffer.readInt(); - break; - case ActionType.Shake: - value.amplitude = buffer.readFloat(); - value.duration = buffer.readFloat(); - break; - case ActionType.ColorFilter: - value.f1 = buffer.readFloat(); - value.f2 = buffer.readFloat(); - value.f3 = buffer.readFloat(); - value.f4 = buffer.readFloat(); - break; - case ActionType.Text: - case ActionType.Icon: - value.text = buffer.readS(); - break; - } - }; - return Transition; - }()); - fgui.Transition = Transition; - var OPTION_IGNORE_DISPLAY_CONTROLLER = 1; - var OPTION_AUTO_STOP_DISABLED = 2; - var OPTION_AUTO_STOP_AT_END = 4; - var ActionType = (function () { - function ActionType() { - } - ActionType.XY = 0; - ActionType.Size = 1; - ActionType.Scale = 2; - ActionType.Pivot = 3; - ActionType.Alpha = 4; - ActionType.Rotation = 5; - ActionType.Color = 6; - ActionType.Animation = 7; - ActionType.Visible = 8; - ActionType.Sound = 9; - ActionType.Transition = 10; - ActionType.Shake = 11; - ActionType.ColorFilter = 12; - ActionType.Skew = 13; - ActionType.Text = 14; - ActionType.Icon = 15; - ActionType.Unknown = 16; - return ActionType; - }()); - var Item = (function () { - function Item(type) { - this.type = type; - this.value = {}; - this.displayLockToken = 0; - } - return Item; - }()); - var TweenConfig = (function () { - function TweenConfig() { - this.duration = 0; - this.repeat = 0; - this.easeType = fgui.EaseType.QuadOut; - this.startValue = { b1: true, b2: true }; - this.endValue = { b1: true, b2: true }; - } - return TweenConfig; - }()); -})(fgui || (fgui = {})); - -(function (fgui) { - var TranslationHelper = (function () { - function TranslationHelper() { - } - TranslationHelper.loadFromXML = function (source) { - var strings = {}; - TranslationHelper.strings = strings; - var xml = egret.XML.parse(source); - var nodes = xml.children; - var length1 = nodes.length; - for (var i1 = 0; i1 < length1; i1++) { - var cxml = nodes[i1]; - if (cxml.name == "string") { - var key = cxml.attributes.name; - var text = cxml.children.length > 0 ? cxml.children[0].text : ""; - var i = key.indexOf("-"); - if (i == -1) - continue; - var key2 = key.substr(0, i); - var key3 = key.substr(i + 1); - var col = strings[key2]; - if (!col) { - col = {}; - strings[key2] = col; - } - col[key3] = text; - } - } - }; - TranslationHelper.translateComponent = function (item) { - if (TranslationHelper.strings == null) - return; - var compStrings = TranslationHelper.strings[item.owner.id + item.id]; - if (compStrings == null) - return; - var elementId, value; - var buffer = item.rawData; - var nextPos; - var itemCount; - var i, j, k; - var dataLen; - var curPos; - var valueCnt; - var page; - buffer.seek(0, 2); - var childCount = buffer.readShort(); - for (i = 0; i < childCount; i++) { - dataLen = buffer.readShort(); - curPos = buffer.position; - buffer.seek(curPos, 0); - var baseType = buffer.readByte(); - var type = baseType; - buffer.skip(4); - elementId = buffer.readS(); - if (type == fgui.ObjectType.Component) { - if (buffer.seek(curPos, 6)) - type = buffer.readByte(); - } - buffer.seek(curPos, 1); - if ((value = compStrings[elementId + "-tips"]) != null) - buffer.writeS(value); - buffer.seek(curPos, 2); - var gearCnt = buffer.readShort(); - for (j = 0; j < gearCnt; j++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - if (buffer.readByte() == 6) { - buffer.skip(2); - valueCnt = buffer.readShort(); - for (k = 0; k < valueCnt; k++) { - page = buffer.readS(); - if (page != null) { - if ((value = compStrings[elementId + "-texts_" + k]) != null) - buffer.writeS(value); - else - buffer.skip(2); - } - } - if (buffer.readBool() && (value = compStrings[elementId + "-texts_def"]) != null) - buffer.writeS(value); - } - if (baseType == fgui.ObjectType.Component && buffer.version >= 2) { - buffer.seek(curPos, 4); - buffer.skip(2); - buffer.skip(4 * buffer.readShort()); - var cpCount = buffer.readShort(); - for (var k = 0; k < cpCount; k++) { - var target = buffer.readS(); - var propertyId = buffer.readShort(); - if (propertyId == 0 && (value = compStrings[elementId + "-cp-" + target]) != null) - buffer.writeS(value); - else - buffer.skip(2); - } - } - buffer.position = nextPos; - } - switch (type) { - case fgui.ObjectType.Text: - case fgui.ObjectType.RichText: - case fgui.ObjectType.InputText: - { - if ((value = compStrings[elementId]) != null) { - buffer.seek(curPos, 6); - buffer.writeS(value); - } - if ((value = compStrings[elementId + "-prompt"]) != null) { - buffer.seek(curPos, 4); - buffer.writeS(value); - } - break; - } - case fgui.ObjectType.List: - case fgui.ObjectType.Tree: - { - buffer.seek(curPos, 8); - buffer.skip(2); - itemCount = buffer.readShort(); - for (j = 0; j < itemCount; j++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - buffer.skip(2); - if (type == fgui.ObjectType.Tree) - buffer.skip(2); - if ((value = compStrings[elementId + "-" + j]) != null) - buffer.writeS(value); - else - buffer.skip(2); - if ((value = compStrings[elementId + "-" + j + "-0"]) != null) - buffer.writeS(value); - else - buffer.skip(2); - if (buffer.version >= 2) { - buffer.skip(6); - buffer.skip(buffer.readUnsignedShort() * 4); - var cpCount = buffer.readUnsignedShort(); - for (var k = 0; k < cpCount; k++) { - var target = buffer.readS(); - var propertyId = buffer.readUnsignedShort(); - if (propertyId == 0 && (value = compStrings[elementId + "-" + j + "-" + target]) != null) - buffer.writeS(value); - else - buffer.skip(2); - } - } - buffer.position = nextPos; - } - break; - } - case fgui.ObjectType.Label: - { - if (buffer.seek(curPos, 6) && buffer.readByte() == type) { - if ((value = compStrings[elementId]) != null) - buffer.writeS(value); - else - buffer.skip(2); - buffer.skip(2); - if (buffer.readBool()) - buffer.skip(4); - buffer.skip(4); - if (buffer.readBool() && (value = compStrings[elementId + "-prompt"]) != null) - buffer.writeS(value); - } - break; - } - case fgui.ObjectType.Button: - { - if (buffer.seek(curPos, 6) && buffer.readByte() == type) { - if ((value = compStrings[elementId]) != null) - buffer.writeS(value); - else - buffer.skip(2); - if ((value = compStrings[elementId + "-0"]) != null) - buffer.writeS(value); - } - break; - } - case fgui.ObjectType.ComboBox: - { - if (buffer.seek(curPos, 6) && buffer.readByte() == type) { - itemCount = buffer.readShort(); - for (j = 0; j < itemCount; j++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - if ((value = compStrings[elementId + "-" + j]) != null) - buffer.writeS(value); - buffer.position = nextPos; - } - if ((value = compStrings[elementId]) != null) - buffer.writeS(value); - } - break; - } - } - buffer.position = curPos + dataLen; - } - }; - return TranslationHelper; - }()); - fgui.TranslationHelper = TranslationHelper; -})(fgui || (fgui = {})); - -(function (fgui) { - var UIConfig = (function () { - function UIConfig() { - } - UIConfig.defaultFont = "SimSun"; - UIConfig.modalLayerColor = 0x333333; - UIConfig.modalLayerAlpha = 0.2; - UIConfig.buttonSoundVolumeScale = 1; - UIConfig.defaultScrollStep = 25; - UIConfig.defaultScrollDecelerationRate = 0.967; - UIConfig.defaultScrollBarDisplay = fgui.ScrollBarDisplayType.Visible; - UIConfig.defaultScrollTouchEffect = true; - UIConfig.defaultScrollBounceEffect = true; - UIConfig.defaultComboBoxVisibleItemCount = 10; - UIConfig.touchScrollSensitivity = 20; - UIConfig.touchDragSensitivity = 10; - UIConfig.clickDragSensitivity = 2; - UIConfig.bringWindowToFrontOnClick = true; - UIConfig.frameTimeForAsyncUIConstruction = 2; - return UIConfig; - }()); - fgui.UIConfig = UIConfig; -})(fgui || (fgui = {})); - -(function (fgui) { - var UIObjectFactory = (function () { - function UIObjectFactory() { - } - UIObjectFactory.setExtension = function (url, type) { - if (url == null) - throw "Invaild url: " + url; - var pi = fgui.UIPackage.getItemByURL(url); - if (pi) - pi.extensionType = type; - UIObjectFactory.extensions[url] = type; - }; - UIObjectFactory.setPackageItemExtension = function (url, type) { - UIObjectFactory.setExtension(url, type); - }; - UIObjectFactory.setLoaderExtension = function (type) { - UIObjectFactory.loaderType = type; - }; - UIObjectFactory.resolvePackageItemExtension = function (pi) { - var extensionType = UIObjectFactory.extensions["ui://" + pi.owner.id + pi.id]; - if (!extensionType) - extensionType = UIObjectFactory.extensions["ui://" + pi.owner.name + "/" + pi.name]; - if (extensionType) - pi.extensionType = extensionType; - }; - UIObjectFactory.newObject = function (type, userClass) { - var obj; - if (typeof type === 'number') { - switch (type) { - case fgui.ObjectType.Image: - return new fgui.GImage(); - case fgui.ObjectType.MovieClip: - return new fgui.GMovieClip(); - case fgui.ObjectType.Component: - return new fgui.GComponent(); - case fgui.ObjectType.Text: - return new fgui.GTextField(); - case fgui.ObjectType.RichText: - return new fgui.GRichTextField(); - case fgui.ObjectType.InputText: - return new fgui.GTextInput(); - case fgui.ObjectType.Group: - return new fgui.GGroup(); - case fgui.ObjectType.List: - return new fgui.GList(); - case fgui.ObjectType.Graph: - return new fgui.GGraph(); - case fgui.ObjectType.Loader: - if (UIObjectFactory.loaderType) - return new UIObjectFactory.loaderType(); - else - return new fgui.GLoader(); - case fgui.ObjectType.Button: - return new fgui.GButton(); - case fgui.ObjectType.Label: - return new fgui.GLabel(); - case fgui.ObjectType.ProgressBar: - return new fgui.GProgressBar(); - case fgui.ObjectType.Slider: - return new fgui.GSlider(); - case fgui.ObjectType.ScrollBar: - return new fgui.GScrollBar(); - case fgui.ObjectType.ComboBox: - return new fgui.GComboBox(); - case fgui.ObjectType.Tree: - return new fgui.GTree(); - case fgui.ObjectType.Loader3D: - return new fgui.GLoader3D(); - default: - return null; - } - } - else { - if (type.type == fgui.PackageItemType.Component) { - if (userClass) - obj = new userClass(); - else if (type.extensionType) - obj = new type.extensionType(); - else - obj = UIObjectFactory.newObject(type.objectType); - } - else - obj = UIObjectFactory.newObject(type.objectType); - if (obj) - obj.packageItem = type; - } - return obj; - }; - UIObjectFactory.extensions = {}; - return UIObjectFactory; - }()); - fgui.UIObjectFactory = UIObjectFactory; -})(fgui || (fgui = {})); - -(function (fgui) { - var UIPackage = (function () { - function UIPackage() { - this._items = []; - this._itemsById = {}; - this._itemsByName = {}; - this._sprites = {}; - this._dependencies = []; - this._branches = []; - this._branchIndex = -1; - } - Object.defineProperty(UIPackage, "branch", { - get: function () { - return UIPackage._branch; - }, - set: function (value) { - UIPackage._branch = value; - for (var pkgId in UIPackage._instById) { - var pkg = UIPackage._instById[pkgId]; - if (pkg._branches) { - pkg._branchIndex = pkg._branches.indexOf(value); - } - } - }, - enumerable: true, - configurable: true - }); - UIPackage.getVar = function (key) { - return UIPackage._vars[key]; - }; - UIPackage.setVar = function (key, value) { - UIPackage._vars[key] = value; - }; - UIPackage.getById = function (id) { - return UIPackage._instById[id]; - }; - UIPackage.getByName = function (name) { - return UIPackage._instByName[name]; - }; - UIPackage.loadPackage = function (resKey) { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () { - var pkg, asset, cnt, tasks, i, pi; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - pkg = UIPackage._instById[resKey]; - if (pkg) { - resolve(pkg); - return [2]; - } - return [4, RES.getResAsync(getAssetResKey(resKey, "fui"))]; - case 1: - asset = _a.sent(); - pkg = new UIPackage(); - pkg._resKey = resKey; - pkg.loadPackage(new fgui.ByteBuffer(asset)); - cnt = pkg._items.length; - tasks = []; - for (i = 0; i < cnt; i++) { - pi = pkg._items[i]; - if (pi.type == fgui.PackageItemType.Atlas || pi.type == fgui.PackageItemType.Sound) { - tasks.push(RES.getResAsync(pi.file)); - } - } - if (!(tasks.length > 0)) return [3, 3]; - return [4, Promise.all(tasks)]; - case 2: - _a.sent(); - _a.label = 3; - case 3: - UIPackage._instById[pkg.id] = pkg; - UIPackage._instByName[pkg.name] = pkg; - UIPackage._instById[pkg._resKey] = pkg; - resolve(pkg); - return [2]; - } - }); - }); })]; - }); - }); - }; - UIPackage.addPackage = function (resKey, descData) { - if (!descData) { - descData = RES.getRes(resKey); - if (!descData) - throw "Resource '" + resKey + "' not found, please check default.res.json!"; - } - var pkg = new UIPackage(); - pkg._resKey = resKey; - pkg.loadPackage(new fgui.ByteBuffer(descData)); - UIPackage._instById[pkg.id] = pkg; - UIPackage._instByName[pkg.name] = pkg; - UIPackage._instById[resKey] = pkg; - return pkg; - }; - UIPackage.removePackage = function (packageIdOrName) { - var pkg = UIPackage._instById[packageIdOrName]; - if (!pkg) - pkg = UIPackage._instByName[packageIdOrName]; - if (!pkg) - throw new Error("unknown package: " + packageIdOrName); - pkg.dispose(); - delete UIPackage._instById[pkg.id]; - delete UIPackage._instByName[pkg.name]; - delete UIPackage._instById[pkg._resKey]; - if (pkg._customId != null) - delete UIPackage._instById[pkg._customId]; - }; - UIPackage.createObject = function (pkgName, resName, userClass) { - var pkg = UIPackage.getByName(pkgName); - if (pkg) - return pkg.createObject(resName, userClass); - else - return null; - }; - UIPackage.createObjectFromURL = function (url, userClass) { - var pi = UIPackage.getItemByURL(url); - if (pi) - return pi.owner.internalCreateObject(pi, userClass); - else - return null; - }; - UIPackage.getItemURL = function (pkgName, resName) { - var pkg = UIPackage.getByName(pkgName); - if (!pkg) - return null; - var pi = pkg._itemsByName[resName]; - if (!pi) - return null; - return "ui://" + pkg.id + pi.id; - }; - UIPackage.getItemByURL = function (url) { - var pos1 = url.indexOf("//"); - if (pos1 == -1) - return null; - var pos2 = url.indexOf("/", pos1 + 2); - if (pos2 == -1) { - if (url.length > 13) { - var pkgId = url.substr(5, 8); - var pkg = UIPackage.getById(pkgId); - if (pkg != null) { - var srcId = url.substr(13); - return pkg.getItemById(srcId); - } - } - } - else { - var pkgName = url.substr(pos1 + 2, pos2 - pos1 - 2); - pkg = UIPackage.getByName(pkgName); - if (pkg != null) { - var srcName = url.substr(pos2 + 1); - return pkg.getItemByName(srcName); - } - } - return null; - }; - UIPackage.normalizeURL = function (url) { - if (url == null) - return null; - var pos1 = url.indexOf("//"); - if (pos1 == -1) - return null; - var pos2 = url.indexOf("/", pos1 + 2); - if (pos2 == -1) - return url; - var pkgName = url.substr(pos1 + 2, pos2 - pos1 - 2); - var srcName = url.substr(pos2 + 1); - return UIPackage.getItemURL(pkgName, srcName); - }; - UIPackage.setStringsSource = function (source) { - fgui.TranslationHelper.loadFromXML(source); - }; - UIPackage.prototype.loadPackage = function (buffer) { - if (buffer.readUnsignedInt() != 0x46475549) - throw "FairyGUI: old package format found in '" + this._resKey + "'"; - buffer.version = buffer.readInt(); - var compressed = buffer.readBool(); - this._id = buffer.readUTF(); - this._name = buffer.readUTF(); - buffer.skip(20); - if (compressed) { - var buf = new Uint8Array(buffer.buffer, buffer.position, buffer.length - buffer.position); - var inflater = new Zlib.RawInflate(buf); - var buffer2 = new fgui.ByteBuffer(inflater.decompress()); - buffer2.version = buffer.version; - buffer = buffer2; - } - var ver2 = buffer.version >= 2; - var indexTablePos = buffer.position; - var cnt; - var i; - var nextPos; - var str; - var branchIncluded; - buffer.seek(indexTablePos, 4); - cnt = buffer.readInt(); - var stringTable = new Array(cnt); - stringTable.reduceRight; - for (i = 0; i < cnt; i++) - stringTable[i] = buffer.readUTF(); - buffer.stringTable = stringTable; - buffer.seek(indexTablePos, 0); - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) - this._dependencies.push({ id: buffer.readS(), name: buffer.readS() }); - if (ver2) { - cnt = buffer.readShort(); - if (cnt > 0) { - this._branches = buffer.readSArray(cnt); - if (UIPackage._branch) - this._branchIndex = this._branches.indexOf(UIPackage._branch); - } - branchIncluded = cnt > 0; - } - buffer.seek(indexTablePos, 1); - var pi; - var path = this._resKey; - var pos = path.lastIndexOf('/'); - var shortPath = pos == -1 ? "" : path.substr(0, pos + 1); - path = path + "_"; - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readInt(); - nextPos += buffer.position; - pi = new fgui.PackageItem(); - pi.owner = this; - pi.type = buffer.readByte(); - pi.id = buffer.readS(); - pi.name = buffer.readS(); - buffer.readS(); - pi.file = buffer.readS(); - buffer.readBool(); - pi.width = buffer.readInt(); - pi.height = buffer.readInt(); - switch (pi.type) { - case fgui.PackageItemType.Image: - { - pi.objectType = fgui.ObjectType.Image; - var scaleOption = buffer.readByte(); - if (scaleOption == 1) { - pi.scale9Grid = new egret.Rectangle(); - pi.scale9Grid.x = buffer.readInt(); - pi.scale9Grid.y = buffer.readInt(); - pi.scale9Grid.width = buffer.readInt(); - pi.scale9Grid.height = buffer.readInt(); - pi.tileGridIndice = buffer.readInt(); - } - else if (scaleOption == 2) - pi.scaleByTile = true; - pi.smoothing = buffer.readBool(); - break; - } - case fgui.PackageItemType.MovieClip: - { - pi.smoothing = buffer.readBool(); - pi.objectType = fgui.ObjectType.MovieClip; - pi.rawData = buffer.readBuffer(); - break; - } - case fgui.PackageItemType.Font: - { - pi.rawData = buffer.readBuffer(); - break; - } - case fgui.PackageItemType.Component: - { - var extension = buffer.readByte(); - if (extension > 0) - pi.objectType = extension; - else - pi.objectType = fgui.ObjectType.Component; - pi.rawData = buffer.readBuffer(); - fgui.UIObjectFactory.resolvePackageItemExtension(pi); - break; - } - case fgui.PackageItemType.Atlas: - case fgui.PackageItemType.Sound: - case fgui.PackageItemType.Misc: - { - var pos_1 = pi.file.lastIndexOf("."); - pi.file = path + (pos_1 == -1 ? pi.file : getAssetResKey(pi.file.substring(0, pos_1), pi.file.substring(pos_1 + 1))); - break; - } - case fgui.PackageItemType.Spine: - case fgui.PackageItemType.DragonBones: - { - var pos_2 = pi.file.lastIndexOf("."); - pi.file = shortPath + (pos_2 == -1 ? pi.file : pi.file.substring(0, pos_2)); - pi.skeletonAnchor = new egret.Point(); - pi.skeletonAnchor.x = buffer.readFloat(); - pi.skeletonAnchor.y = buffer.readFloat(); - break; - } - } - if (ver2) { - str = buffer.readS(); - if (str) - pi.name = str + "/" + pi.name; - var branchCnt = buffer.readUnsignedByte(); - if (branchCnt > 0) { - if (branchIncluded) - pi.branches = buffer.readSArray(branchCnt); - else - this._itemsById[buffer.readS()] = pi; - } - var highResCnt = buffer.readUnsignedByte(); - if (highResCnt > 0) - pi.highResolution = buffer.readSArray(highResCnt); - } - this._items.push(pi); - this._itemsById[pi.id] = pi; - if (pi.name != null) - this._itemsByName[pi.name] = pi; - buffer.position = nextPos; - } - buffer.seek(indexTablePos, 2); - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readShort(); - nextPos += buffer.position; - var itemId = buffer.readS(); - pi = this._itemsById[buffer.readS()]; - var sprite = { atlas: pi, rect: new egret.Rectangle(), offset: new egret.Point(), originalSize: new egret.Point() }; - sprite.rect.x = buffer.readInt(); - sprite.rect.y = buffer.readInt(); - sprite.rect.width = buffer.readInt(); - sprite.rect.height = buffer.readInt(); - sprite.rotated = buffer.readBool(); - if (ver2 && buffer.readBool()) { - sprite.offset.x = buffer.readInt(); - sprite.offset.y = buffer.readInt(); - sprite.originalSize.x = buffer.readInt(); - sprite.originalSize.y = buffer.readInt(); - } - else { - sprite.originalSize.x = sprite.rect.width; - sprite.originalSize.y = sprite.rect.height; - } - this._sprites[itemId] = sprite; - buffer.position = nextPos; - } - if (buffer.seek(indexTablePos, 3)) { - cnt = buffer.readShort(); - for (i = 0; i < cnt; i++) { - nextPos = buffer.readInt(); - nextPos += buffer.position; - pi = this._itemsById[buffer.readS()]; - if (pi && pi.type == fgui.PackageItemType.Image) { - pi.pixelHitTestData = new fgui.PixelHitTestData(); - pi.pixelHitTestData.load(buffer); - } - buffer.position = nextPos; - } - } - }; - UIPackage.prototype.dispose = function () { - var cnt = this._items.length; - for (var i = 0; i < cnt; i++) { - var pi = this._items[i]; - if (pi.type == fgui.PackageItemType.Atlas) { - RES.destroyRes(pi.file, false); - } - else if (pi.type == fgui.PackageItemType.Sound) { - } - } - }; - Object.defineProperty(UIPackage.prototype, "id", { - get: function () { - return this._id; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIPackage.prototype, "name", { - get: function () { - return this._name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIPackage.prototype, "customId", { - get: function () { - return this._customId; - }, - set: function (value) { - if (this._customId != null) - delete UIPackage._instById[this._customId]; - this._customId = value; - if (this._customId != null) - UIPackage._instById[this._customId] = this; - }, - enumerable: true, - configurable: true - }); - UIPackage.prototype.createObject = function (resName, userClass) { - var pi = this._itemsByName[resName]; - if (pi) - return this.internalCreateObject(pi, userClass); - else - return null; - }; - UIPackage.prototype.internalCreateObject = function (item, userClass) { - var g = fgui.UIObjectFactory.newObject(item, userClass); - if (g == null) - return null; - UIPackage._constructing++; - g.constructFromResource(); - UIPackage._constructing--; - return g; - }; - UIPackage.prototype.getItemById = function (itemId) { - return this._itemsById[itemId]; - }; - UIPackage.prototype.getItemByName = function (resName) { - return this._itemsByName[resName]; - }; - UIPackage.prototype.getItemAssetByName = function (resName) { - var pi = this._itemsByName[resName]; - if (pi == null) { - throw "Resource not found -" + resName; - } - return this.getItemAsset(pi); - }; - UIPackage.prototype.getItemAsset = function (item) { - switch (item.type) { - case fgui.PackageItemType.Image: - if (!item.decoded) { - item.decoded = true; - var sprite = this._sprites[item.id]; - if (sprite) { - var atlas = this.getItemAsset(sprite.atlas); - item.asset = new egret.Texture(); - item.asset.bitmapData = atlas.bitmapData; - item.asset.$initData(atlas.$bitmapX + sprite.rect.x, atlas.$bitmapY + sprite.rect.y, sprite.rect.width, sprite.rect.height, sprite.offset.x, sprite.offset.y, sprite.originalSize.x, sprite.originalSize.y, atlas.$sourceWidth, atlas.$sourceHeight, sprite.rotated); - } - } - return item.asset; - case fgui.PackageItemType.Atlas: - case fgui.PackageItemType.Sound: - if (!item.decoded) { - item.decoded = true; - item.asset = RES.getRes(item.file); - if (!item.asset) - console.log("Resource '" + item.file + "' not found, please check default.res.json!"); - } - return item.asset; - case fgui.PackageItemType.Font: - if (!item.decoded) { - item.decoded = true; - this.loadFont(item); - } - return item.bitmapFont; - case fgui.PackageItemType.MovieClip: - if (!item.decoded) { - item.decoded = true; - this.loadMovieClip(item); - } - return item.frames; - case fgui.PackageItemType.Misc: - if (item.file) - return RES.getRes(item.file); - else - return null; - default: - return null; - } - }; - UIPackage.prototype.getItemAssetAsync = function (item, onComplete) { - if (item.decoded) { - onComplete(null, item); - return; - } - if (item.loading) { - item.loading.push(onComplete); - return; - } - switch (item.type) { - case fgui.PackageItemType.DragonBones: - item.loading = [onComplete]; - this.loadDragonBones(item); - break; - default: - this.getItemAsset(item); - onComplete(null, item); - break; - } - }; - UIPackage.prototype.loadMovieClip = function (item) { - var buffer = item.rawData; - buffer.seek(0, 0); - item.interval = buffer.readInt(); - item.swing = buffer.readBool(); - item.repeatDelay = buffer.readInt(); - buffer.seek(0, 1); - var frameCount = buffer.readShort(); - item.frames = Array(frameCount); - var spriteId; - var sprite; - var fx; - var fy; - for (var i = 0; i < frameCount; i++) { - var nextPos = buffer.readShort(); - nextPos += buffer.position; - var frame = {}; - fx = buffer.readInt(); - fy = buffer.readInt(); - buffer.readInt(); - buffer.readInt(); - frame.addDelay = buffer.readInt(); - spriteId = buffer.readS(); - if (spriteId != null && (sprite = this._sprites[spriteId]) != null) { - var atlas = this.getItemAsset(sprite.atlas); - frame.texture = new egret.Texture(); - frame.texture.bitmapData = atlas.bitmapData; - frame.texture.$initData(atlas.$bitmapX + sprite.rect.x, atlas.$bitmapY + sprite.rect.y, sprite.rect.width, sprite.rect.height, fx, fy, item.width, item.height, atlas.$sourceWidth, atlas.$sourceHeight, sprite.rotated); - } - item.frames[i] = frame; - buffer.position = nextPos; - } - }; - UIPackage.prototype.loadFont = function (item) { - var font = new fgui.BitmapFont(); - item.bitmapFont = font; - var buffer = item.rawData; - buffer.seek(0, 0); - font.ttf = buffer.readBool(); - font.tint = buffer.readBool(); - font.resizable = buffer.readBool(); - buffer.readBool(); - font.size = buffer.readInt(); - var xadvance = buffer.readInt(); - var lineHeight = buffer.readInt(); - var mainTexture; - var mainSprite = this._sprites[item.id]; - if (mainSprite) - mainTexture = (this.getItemAsset(mainSprite.atlas)); - buffer.seek(0, 1); - var bg; - var cnt = buffer.readInt(); - for (var i = 0; i < cnt; i++) { - var nextPos = buffer.readShort(); - nextPos += buffer.position; - bg = {}; - var ch = buffer.readChar(); - font.glyphs[ch] = bg; - var img = buffer.readS(); - var bx = buffer.readInt(); - var by = buffer.readInt(); - bg.x = buffer.readInt(); - bg.y = buffer.readInt(); - bg.width = buffer.readInt(); - bg.height = buffer.readInt(); - bg.advance = buffer.readInt(); - bg.channel = buffer.readByte(); - if (bg.channel == 1) - bg.channel = 3; - else if (bg.channel == 2) - bg.channel = 2; - else if (bg.channel == 3) - bg.channel = 1; - if (font.ttf) { - bg.texture = new egret.Texture(); - bg.texture.bitmapData = mainTexture.bitmapData; - bg.texture.$initData(mainTexture.$bitmapX + bx + mainSprite.rect.x, mainTexture.$bitmapY + by + mainSprite.rect.y, bg.width, bg.height, mainSprite.offset.x, mainSprite.offset.y, mainSprite.originalSize.x, mainSprite.originalSize.y, mainTexture.$sourceWidth, mainTexture.$sourceHeight, mainSprite.rotated); - bg.lineHeight = lineHeight; - } - else { - var charImg = this._itemsById[img]; - if (charImg) { - this.getItemAsset(charImg); - bg.width = charImg.width; - bg.height = charImg.height; - bg.texture = charImg.asset; - } - if (bg.advance == 0) { - if (xadvance == 0) - bg.advance = bg.x + bg.width; - else - bg.advance = xadvance; - } - bg.lineHeight = bg.y < 0 ? bg.height : (bg.y + bg.height); - if (bg.lineHeight < font.size) - bg.lineHeight = font.size; - } - buffer.position = nextPos; - } - }; - UIPackage.prototype.loadDragonBones = function (item) { - var jsonFile = getAssetResKey(item.file, ["json", "dbbin"]); - var str = item.file.replace("_ske", "_tex"); - var atlasFile = getAssetResKey(str, "json"); - var texFile = getAssetResKey(str, "png"); - var task1 = RES.getResAsync(jsonFile); - var task2 = RES.getResAsync(atlasFile); - var task3 = RES.getResAsync(texFile); - Promise.all([task1, task2, task3]).then(function (values) { - var egretFactory = dragonBones.EgretFactory.factory; - item.asset = egretFactory.parseDragonBonesData(values[0]); - item.atlasAsset = egretFactory.parseTextureAtlasData(values[1], values[2]); - item.armatureName = item.asset.armatureNames[0]; - var arr = item.loading; - delete item.loading; - arr.forEach(function (e) { return e(null, item); }); - }).catch(function (reason) { - var arr = item.loading; - delete item.loading; - arr.forEach(function (e) { return e(reason, item); }); - }); - }; - UIPackage._constructing = 0; - UIPackage._instById = {}; - UIPackage._instByName = {}; - UIPackage._branch = ""; - UIPackage._vars = {}; - return UIPackage; - }()); - fgui.UIPackage = UIPackage; - function getAssetResKey(file, types) { - if (Array.isArray(types)) { - for (var i = 0; i < types.length; i++) { - var key = file + "_" + types[i]; - if (RES.hasRes(key)) - return key; - } - return file; - } - else { - var key = file + "_" + types; - if (RES.hasRes(key)) - return key; - return file; - } - } -})(fgui || (fgui = {})); - -(function (fgui) { - var Window = (function (_super_1) { - __extends(Window, _super_1); - function Window() { - var _this = _super_1.call(this) || this; - _this._requestingCmd = 0; - _this._uiSources = new Array(); - _this.bringToFontOnClick = fgui.UIConfig.bringWindowToFrontOnClick; - _this.displayObject.addEventListener(egret.Event.ADDED_TO_STAGE, _this.__onShown, _this); - _this.displayObject.addEventListener(egret.Event.REMOVED_FROM_STAGE, _this.__onHidden, _this); - _this.displayObject.addEventListener(egret.TouchEvent.TOUCH_BEGIN, _this.__mouseDown, _this, true); - return _this; - } - Window.prototype.addUISource = function (source) { - this._uiSources.push(source); - }; - Object.defineProperty(Window.prototype, "contentPane", { - get: function () { - return this._contentPane; - }, - set: function (val) { - if (this._contentPane != val) { - if (this._contentPane) - this.removeChild(this._contentPane); - this._contentPane = val; - if (this._contentPane) { - this.addChild(this._contentPane); - this.setSize(this._contentPane.width, this._contentPane.height); - this._contentPane.addRelation(this, fgui.RelationType.Size); - this._frame = (this._contentPane.getChild("frame")); - if (this._frame) { - this.closeButton = this._frame.getChild("closeButton"); - this.dragArea = this._frame.getChild("dragArea"); - this.contentArea = this._frame.getChild("contentArea"); - } - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "frame", { - get: function () { - return this._frame; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "closeButton", { - get: function () { - return this._closeButton; - }, - set: function (value) { - if (this._closeButton) - this._closeButton.removeClickListener(this.closeEventHandler, this); - this._closeButton = value; - if (this._closeButton) - this._closeButton.addClickListener(this.closeEventHandler, this); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "dragArea", { - get: function () { - return this._dragArea; - }, - set: function (value) { - if (this._dragArea != value) { - if (this._dragArea) { - this._dragArea.draggable = false; - this._dragArea.removeEventListener(fgui.DragEvent.DRAG_START, this.__dragStart, this); - } - this._dragArea = value; - if (this._dragArea) { - if ((this._dragArea instanceof fgui.GGraph) && this._dragArea.displayObject == null) - this._dragArea.asGraph.drawRect(0, 0, 0, 0, 0); - this._dragArea.draggable = true; - this._dragArea.addEventListener(fgui.DragEvent.DRAG_START, this.__dragStart, this); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "contentArea", { - get: function () { - return this._contentArea; - }, - set: function (value) { - this._contentArea = value; - }, - enumerable: true, - configurable: true - }); - Window.prototype.show = function () { - fgui.GRoot.inst.showWindow(this); - }; - Window.prototype.showOn = function (root) { - root.showWindow(this); - }; - Window.prototype.hide = function () { - if (this.isShowing) - this.doHideAnimation(); - }; - Window.prototype.hideImmediately = function () { - var r = (this.parent instanceof fgui.GRoot) ? this.parent : null; - if (!r) - r = fgui.GRoot.inst; - r.hideWindowImmediately(this); - }; - Window.prototype.centerOn = function (r, restraint) { - this.setXY(Math.round((r.width - this.width) / 2), Math.round((r.height - this.height) / 2)); - if (restraint) { - this.addRelation(r, fgui.RelationType.Center_Center); - this.addRelation(r, fgui.RelationType.Middle_Middle); - } - }; - Window.prototype.toggleStatus = function () { - if (this.isTop) - this.hide(); - else - this.show(); - }; - Object.defineProperty(Window.prototype, "isShowing", { - get: function () { - return this.parent != null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "isTop", { - get: function () { - return this.parent != null && this.parent.getChildIndex(this) == this.parent.numChildren - 1; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Window.prototype, "modal", { - get: function () { - return this._modal; - }, - set: function (val) { - this._modal = val; - }, - enumerable: true, - configurable: true - }); - Window.prototype.bringToFront = function () { - this.root.bringToFront(this); - }; - Window.prototype.showModalWait = function (requestingCmd) { - if (requestingCmd != undefined) - this._requestingCmd = requestingCmd; - if (fgui.UIConfig.windowModalWaiting) { - if (!this._modalWaitPane) - this._modalWaitPane = fgui.UIPackage.createObjectFromURL(fgui.UIConfig.windowModalWaiting); - this.layoutModalWaitPane(); - this.addChild(this._modalWaitPane); - } - }; - Window.prototype.layoutModalWaitPane = function () { - if (this._contentArea) { - var pt = this._frame.localToGlobal(); - pt = this.globalToLocal(pt.x, pt.y, pt); - this._modalWaitPane.setXY(pt.x + this._contentArea.x, pt.y + this._contentArea.y); - this._modalWaitPane.setSize(this._contentArea.width, this._contentArea.height); - } - else - this._modalWaitPane.setSize(this.width, this.height); - }; - Window.prototype.closeModalWait = function (requestingCmd) { - if (requestingCmd != null && requestingCmd != 0) { - if (this._requestingCmd != requestingCmd) - return false; - } - this._requestingCmd = 0; - if (this._modalWaitPane && this._modalWaitPane.parent != null) - this.removeChild(this._modalWaitPane); - return true; - }; - Object.defineProperty(Window.prototype, "modalWaiting", { - get: function () { - return this._modalWaitPane && this._modalWaitPane.parent != null; - }, - enumerable: true, - configurable: true - }); - Window.prototype.init = function () { - if (this._inited || this._loading) - return; - if (this._uiSources.length > 0) { - this._loading = false; - var cnt = this._uiSources.length; - for (var i = 0; i < cnt; i++) { - var lib = this._uiSources[i]; - if (!lib.loaded) { - lib.load(this.__uiLoadComplete, this); - this._loading = true; - } - } - if (!this._loading) - this._init(); - } - else - this._init(); - }; - Window.prototype.onInit = function () { - }; - Window.prototype.onShown = function () { - }; - Window.prototype.onHide = function () { - }; - Window.prototype.doShowAnimation = function () { - this.onShown(); - }; - Window.prototype.doHideAnimation = function () { - this.hideImmediately(); - }; - Window.prototype.__uiLoadComplete = function () { - var cnt = this._uiSources.length; - for (var i = 0; i < cnt; i++) { - var lib = this._uiSources[i]; - if (!lib.loaded) - return; - } - this._loading = false; - this._init(); - }; - Window.prototype._init = function () { - this._inited = true; - this.onInit(); - if (this.isShowing) - this.doShowAnimation(); - }; - Window.prototype.dispose = function () { - this.displayObject.removeEventListener(egret.Event.ADDED_TO_STAGE, this.__onShown, this); - this.displayObject.removeEventListener(egret.Event.REMOVED_FROM_STAGE, this.__onHidden, this); - if (this.parent) - this.hideImmediately(); - _super_1.prototype.dispose.call(this); - }; - Window.prototype.closeEventHandler = function (evt) { - this.hide(); - }; - Window.prototype.__onShown = function (evt) { - if (!this._inited) - this.init(); - else - this.doShowAnimation(); - }; - Window.prototype.__onHidden = function (evt) { - this.closeModalWait(); - this.onHide(); - }; - Window.prototype.__mouseDown = function (evt) { - if (this.isShowing && this.bringToFontOnClick) - this.bringToFront(); - }; - Window.prototype.__dragStart = function (evt) { - evt.preventDefault(); - this.startDrag(evt.touchPointID, evt.stageX, evt.stageY); - }; - return Window; - }(fgui.GComponent)); - fgui.Window = Window; -})(fgui || (fgui = {})); - -(function (fgui) { - var ControllerAction = (function () { - function ControllerAction() { - } - ControllerAction.createAction = function (type) { - switch (type) { - case 0: - return new fgui.PlayTransitionAction(); - case 1: - return new fgui.ChangePageAction(); - } - return null; - }; - ControllerAction.prototype.run = function (controller, prevPage, curPage) { - if ((this.fromPage == null || this.fromPage.length == 0 || this.fromPage.indexOf(prevPage) != -1) - && (this.toPage == null || this.toPage.length == 0 || this.toPage.indexOf(curPage) != -1)) - this.enter(controller); - else - this.leave(controller); - }; - ControllerAction.prototype.enter = function (controller) { - }; - ControllerAction.prototype.leave = function (controller) { - }; - ControllerAction.prototype.setup = function (buffer) { - var cnt; - var i; - cnt = buffer.readShort(); - this.fromPage = []; - for (i = 0; i < cnt; i++) - this.fromPage[i] = buffer.readS(); - cnt = buffer.readShort(); - this.toPage = []; - for (i = 0; i < cnt; i++) - this.toPage[i] = buffer.readS(); - }; - return ControllerAction; - }()); - fgui.ControllerAction = ControllerAction; -})(fgui || (fgui = {})); - -(function (fgui) { - var ChangePageAction = (function (_super_1) { - __extends(ChangePageAction, _super_1); - function ChangePageAction() { - return _super_1.call(this) || this; - } - ChangePageAction.prototype.enter = function (controller) { - if (!this.controllerName) - return; - var gcom; - if (this.objectId) { - var obj = controller.parent.getChildById(this.objectId); - if (obj instanceof fgui.GComponent) - gcom = obj; - else - return; - } - else - gcom = controller.parent; - if (gcom) { - var cc = gcom.getController(this.controllerName); - if (cc && cc != controller && !cc.changing) { - if (this.targetPage == "~1") { - if (controller.selectedIndex < cc.pageCount) - cc.selectedIndex = controller.selectedIndex; - } - else if (this.targetPage == "~2") - cc.selectedPage = controller.selectedPage; - else - cc.selectedPageId = this.targetPage; - } - } - }; - ChangePageAction.prototype.setup = function (buffer) { - _super_1.prototype.setup.call(this, buffer); - this.objectId = buffer.readS(); - this.controllerName = buffer.readS(); - this.targetPage = buffer.readS(); - }; - return ChangePageAction; - }(fgui.ControllerAction)); - fgui.ChangePageAction = ChangePageAction; -})(fgui || (fgui = {})); - -(function (fgui) { - var PlayTransitionAction = (function (_super_1) { - __extends(PlayTransitionAction, _super_1); - function PlayTransitionAction() { - var _this = _super_1.call(this) || this; - _this.playTimes = 1; - _this.delay = 0; - _this.stopOnExit = false; - return _this; - } - PlayTransitionAction.prototype.enter = function (controller) { - var trans = controller.parent.getTransition(this.transitionName); - if (trans) { - if (this._currentTransition && this._currentTransition.playing) - trans.changePlayTimes(this.playTimes); - else - trans.play(null, null, null, this.playTimes, this.delay); - this._currentTransition = trans; - } - }; - PlayTransitionAction.prototype.leave = function (controller) { - if (this.stopOnExit && this._currentTransition) { - this._currentTransition.stop(); - this._currentTransition = null; - } - }; - PlayTransitionAction.prototype.setup = function (buffer) { - _super_1.prototype.setup.call(this, buffer); - this.transitionName = buffer.readS(); - this.playTimes = buffer.readInt(); - this.delay = buffer.readFloat(); - this.stopOnExit = buffer.readBool(); - }; - return PlayTransitionAction; - }(fgui.ControllerAction)); - fgui.PlayTransitionAction = PlayTransitionAction; -})(fgui || (fgui = {})); - -(function (fgui) { - var BitmapFont = (function () { - function BitmapFont() { - this.size = 0; - this.glyphs = {}; - } - return BitmapFont; - }()); - fgui.BitmapFont = BitmapFont; -})(fgui || (fgui = {})); - -(function (fgui) { - function fillImage(w, h, method, origin, clockwise, amount) { - if (amount <= 0) - return null; - else if (amount >= 0.9999) - return [0, 0, w, 0, w, h, 0, h]; - var points; - switch (method) { - case fgui.FillMethod.Horizontal: - points = fillHorizontal(w, h, origin, amount); - break; - case fgui.FillMethod.Vertical: - points = fillVertical(w, h, origin, amount); - break; - case fgui.FillMethod.Radial90: - points = fillRadial90(w, h, origin, clockwise, amount); - break; - case fgui.FillMethod.Radial180: - points = fillRadial180(w, h, origin, clockwise, amount); - break; - case fgui.FillMethod.Radial360: - points = fillRadial360(w, h, origin, clockwise, amount); - break; - } - return points; - } - fgui.fillImage = fillImage; - function fillHorizontal(w, h, origin, amount) { - var w2 = w * amount; - if (origin == fgui.FillOrigin.Left || origin == fgui.FillOrigin.Top) - return [0, 0, w2, 0, w2, h, 0, h]; - else - return [w, 0, w, h, w - w2, h, w - w2, 0]; - } - function fillVertical(w, h, origin, amount) { - var h2 = h * amount; - if (origin == fgui.FillOrigin.Left || origin == fgui.FillOrigin.Top) - return [0, 0, 0, h2, w, h2, w, 0]; - else - return [0, h, w, h, w, h - h2, 0, h - h2]; - } - function fillRadial90(w, h, origin, clockwise, amount) { - if (clockwise && (origin == fgui.FillOrigin.TopRight || origin == fgui.FillOrigin.BottomLeft) - || !clockwise && (origin == fgui.FillOrigin.TopLeft || origin == fgui.FillOrigin.BottomRight)) { - amount = 1 - amount; - } - var v, v2, h2; - v = Math.tan(Math.PI / 2 * amount); - h2 = w * v; - v2 = (h2 - h) / h2; - var points; - switch (origin) { - case fgui.FillOrigin.TopLeft: - if (clockwise) { - if (h2 <= h) - points = [0, 0, w, h2, w, 0]; - else - points = [0, 0, w * (1 - v2), h, w, h, w, 0]; - } - else { - if (h2 <= h) - points = [0, 0, w, h2, w, h, 0, h]; - else - points = [0, 0, w * (1 - v2), h, 0, h]; - } - break; - case fgui.FillOrigin.TopRight: - if (clockwise) { - if (h2 <= h) - points = [w, 0, 0, h2, 0, h, w, h]; - else - points = [w, 0, w * v2, h, w, h]; - } - else { - if (h2 <= h) - points = [w, 0, 0, h2, 0, 0]; - else - points = [w, 0, w * v2, h, 0, h, 0, 0]; - } - break; - case fgui.FillOrigin.BottomLeft: - if (clockwise) { - if (h2 <= h) - points = [0, h, w, h - h2, w, 0, 0, 0]; - else - points = [0, h, w * (1 - v2), 0, 0, 0]; - } - else { - if (h2 <= h) - points = [0, h, w, h - h2, w, h]; - else - points = [0, h, w * (1 - v2), 0, w, 0, w, h]; - } - break; - case fgui.FillOrigin.BottomRight: - if (clockwise) { - if (h2 <= h) - points = [w, h, 0, h - h2, 0, h]; - else - points = [w, h, w * v2, 0, 0, 0, 0, h]; - } - else { - if (h2 <= h) - points = [w, h, 0, h - h2, 0, 0, w, 0]; - else - points = [w, h, w * v2, 0, w, 0]; - } - break; - } - return points; - } - function movePoints(points, offsetX, offsetY) { - var cnt = points.length; - for (var i = 0; i < cnt; i += 2) { - points[i] += offsetX; - points[i + 1] += offsetY; - } - } - function fillRadial180(w, h, origin, clockwise, amount) { - var points; - switch (origin) { - case fgui.FillOrigin.Top: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial90(w / 2, h, clockwise ? fgui.FillOrigin.TopLeft : fgui.FillOrigin.TopRight, clockwise, amount); - if (clockwise) - movePoints(points, w / 2, 0); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial90(w / 2, h, clockwise ? fgui.FillOrigin.TopRight : fgui.FillOrigin.TopLeft, clockwise, amount); - if (clockwise) - points.push(w, h, w, 0); - else { - movePoints(points, w / 2, 0); - points.push(0, h, 0, 0); - } - } - break; - case fgui.FillOrigin.Bottom: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial90(w / 2, h, clockwise ? fgui.FillOrigin.BottomRight : fgui.FillOrigin.BottomLeft, clockwise, amount); - if (!clockwise) - movePoints(points, w / 2, 0); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial90(w / 2, h, clockwise ? fgui.FillOrigin.BottomLeft : fgui.FillOrigin.BottomRight, clockwise, amount); - if (clockwise) { - movePoints(points, w / 2, 0); - points.push(0, 0, 0, h); - } - else - points.push(w, 0, w, h); - } - break; - case fgui.FillOrigin.Left: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial90(w, h / 2, clockwise ? fgui.FillOrigin.BottomLeft : fgui.FillOrigin.TopLeft, clockwise, amount); - if (!clockwise) - movePoints(points, 0, h / 2); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial90(w, h / 2, clockwise ? fgui.FillOrigin.TopLeft : fgui.FillOrigin.BottomLeft, clockwise, amount); - if (clockwise) { - movePoints(points, 0, h / 2); - points.push(w, 0, 0, 0); - } - else - points.push(w, h, 0, h); - } - break; - case fgui.FillOrigin.Right: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial90(w, h / 2, clockwise ? fgui.FillOrigin.TopRight : fgui.FillOrigin.BottomRight, clockwise, amount); - if (clockwise) - movePoints(points, 0, h / 2); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial90(w, h / 2, clockwise ? fgui.FillOrigin.BottomRight : fgui.FillOrigin.TopRight, clockwise, amount); - if (clockwise) - points.push(0, h, w, h); - else { - movePoints(points, 0, h / 2); - points.push(0, 0, w, 0); - } - } - break; - } - return points; - } - function fillRadial360(w, h, origin, clockwise, amount) { - var points; - switch (origin) { - case fgui.FillOrigin.Top: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial180(w / 2, h, clockwise ? fgui.FillOrigin.Left : fgui.FillOrigin.Right, clockwise, amount); - if (clockwise) - movePoints(points, w / 2, 0); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial180(w / 2, h, clockwise ? fgui.FillOrigin.Right : fgui.FillOrigin.Left, clockwise, amount); - if (clockwise) - points.push(w, h, w, 0, w / 2, 0); - else { - movePoints(points, w / 2, 0); - points.push(0, h, 0, 0, w / 2, 0); - } - } - break; - case fgui.FillOrigin.Bottom: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial180(w / 2, h, clockwise ? fgui.FillOrigin.Right : fgui.FillOrigin.Left, clockwise, amount); - if (!clockwise) - movePoints(points, w / 2, 0); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial180(w / 2, h, clockwise ? fgui.FillOrigin.Left : fgui.FillOrigin.Right, clockwise, amount); - if (clockwise) { - movePoints(points, w / 2, 0); - points.push(0, 0, 0, h, w / 2, h); - } - else - points.push(w, 0, w, h, w / 2, h); - } - break; - case fgui.FillOrigin.Left: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial180(w, h / 2, clockwise ? fgui.FillOrigin.Bottom : fgui.FillOrigin.Top, clockwise, amount); - if (!clockwise) - movePoints(points, 0, h / 2); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial180(w, h / 2, clockwise ? fgui.FillOrigin.Top : fgui.FillOrigin.Bottom, clockwise, amount); - if (clockwise) { - movePoints(points, 0, h / 2); - points.push(w, 0, 0, 0, 0, h / 2); - } - else - points.push(w, h, 0, h, 0, h / 2); - } - break; - case fgui.FillOrigin.Right: - if (amount <= 0.5) { - amount = amount / 0.5; - points = fillRadial180(w, h / 2, clockwise ? fgui.FillOrigin.Top : fgui.FillOrigin.Bottom, clockwise, amount); - if (clockwise) - movePoints(points, 0, h / 2); - } - else { - amount = (amount - 0.5) / 0.5; - points = fillRadial180(w, h / 2, clockwise ? fgui.FillOrigin.Bottom : fgui.FillOrigin.Top, clockwise, amount); - if (clockwise) - points.push(0, h, w, h, w, h / 2); - else { - movePoints(points, 0, h / 2); - points.push(0, 0, w, 0, w, h / 2); - } - } - break; - } - return points; - } -})(fgui || (fgui = {})); - -(function (fgui) { - var Image = (function (_super_1) { - __extends(Image, _super_1); - function Image() { - var _this = _super_1.call(this) || this; - _this._fillMethod = 0; - _this._fillOrigin = 0; - _this._fillAmount = 0; - _this._color = 0xFFFFFF; - return _this; - } - Object.defineProperty(Image.prototype, "color", { - get: function () { - return this._color; - }, - set: function (value) { - if (this._color != value) { - this._color = value; - if (this.tint == undefined) - fgui.ToolSet.setColorFilter(this, value); - else - this.tint = value; - } - }, - enumerable: true, - configurable: true - }); - Image.prototype.$setX = function (value) { - if (this.mask) - this.mask.x = value; - return _super_1.prototype.$setX.call(this, value); - }; - Image.prototype.$setY = function (value) { - if (this.mask) - this.mask.y = value; - return _super_1.prototype.$setY.call(this, value); - }; - Object.defineProperty(Image.prototype, "fillMethod", { - get: function () { - return this._fillMethod; - }, - set: function (value) { - if (this._fillMethod != value) { - this._fillMethod = value; - if (this._fillMethod != 0) { - if (!this._mask) { - this._mask = new egret.Shape(); - this._mask.touchEnabled = false; - } - this.mask = this._mask; - this._mask.x = this.x; - this._mask.y = this.y; - this.addEventListener(egret.Event.RESIZE, this.markChanged, this); - this.markChanged(); - } - else if (this.mask) { - this._mask.graphics.clear(); - this.mask = null; - this.removeEventListener(egret.Event.RESIZE, this.markChanged, this); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Image.prototype, "fillOrigin", { - get: function () { - return this._fillOrigin; - }, - set: function (value) { - if (this._fillOrigin != value) { - this._fillOrigin = value; - if (this._fillMethod != 0) - this.markChanged(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Image.prototype, "fillClockwise", { - get: function () { - return this._fillClockwise; - }, - set: function (value) { - if (this._fillClockwise != value) { - this._fillClockwise = value; - if (this._fillMethod != 0) - this.markChanged(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Image.prototype, "fillAmount", { - get: function () { - return this._fillAmount; - }, - set: function (value) { - if (this._fillAmount != value) { - this._fillAmount = value; - if (this._fillMethod != 0) - this.markChanged(); - } - }, - enumerable: true, - configurable: true - }); - Image.prototype.markChanged = function () { - if (!this._maskDirtyFlag) { - this._maskDirtyFlag = true; - fgui.GTimers.inst.callLater(this.doFill, this); - } - }; - Image.prototype.doFill = function () { - this._maskDirtyFlag = false; - if (!this._mask.parent && this.parent) - this.parent.addChild(this._mask); - var w = this.width; - var h = this.height; - var g = this._mask.graphics; - g.clear(); - if (w == 0 || h == 0) - return; - var points = fgui.fillImage(w, h, this._fillMethod, this._fillOrigin, this._fillClockwise, this._fillAmount); - if (!points) - return; - g.beginFill(0, 1); - fgui.ToolSet.fillPath(g, points, 0, 0); - g.endFill(); - }; - return Image; - }(egret.Bitmap)); - fgui.Image = Image; -})(fgui || (fgui = {})); - -(function (fgui) { - var MovieClip = (function (_super_1) { - __extends(MovieClip, _super_1); - function MovieClip() { - var _this = _super_1.call(this) || this; - _this.interval = 0; - _this.repeatDelay = 0; - _this.timeScale = 1; - _this._playing = true; - _this._frameCount = 0; - _this._frame = 0; - _this._start = 0; - _this._end = 0; - _this._times = 0; - _this._endAt = 0; - _this._status = 0; - _this._frameElapsed = 0; - _this._reversed = false; - _this._repeatedCount = 0; - _this.touchEnabled = false; - _this.setPlaySettings(); - return _this; - } - Object.defineProperty(MovieClip.prototype, "frames", { - get: function () { - return this._frames; - }, - set: function (value) { - this._frames = value; - this.scale9Grid = null; - this.fillMode = egret.BitmapFillMode.SCALE; - if (this._frames) - this._frameCount = this._frames.length; - else - this._frameCount = 0; - if (this._end == -1 || this._end > this._frameCount - 1) - this._end = this._frameCount - 1; - if (this._endAt == -1 || this._endAt > this._frameCount - 1) - this._endAt = this._frameCount - 1; - if (this._frame < 0 || this._frame > this._frameCount - 1) - this._frame = this._frameCount - 1; - this.drawFrame(); - this._frameElapsed = 0; - this._repeatedCount = 0; - this._reversed = false; - this.checkTimer(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "frameCount", { - get: function () { - return this._frameCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "frame", { - get: function () { - return this._frame; - }, - set: function (value) { - if (this._frame != value) { - if (this._frames && value >= this._frameCount) - value = this._frameCount - 1; - this._frame = value; - this._frameElapsed = 0; - this.drawFrame(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "playing", { - get: function () { - return this._playing; - }, - set: function (value) { - if (this._playing != value) { - this._playing = value; - this.checkTimer(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieClip.prototype, "smoothing", { - get: function () { - return this._smoothing; - }, - set: function (value) { - this._smoothing = value; - }, - enumerable: true, - configurable: true - }); - MovieClip.prototype.rewind = function () { - this._frame = 0; - this._frameElapsed = 0; - this._reversed = false; - this._repeatedCount = 0; - this.drawFrame(); - }; - MovieClip.prototype.syncStatus = function (anotherMc) { - this._frame = anotherMc._frame; - this._frameElapsed = anotherMc._frameElapsed; - this._reversed = anotherMc._reversed; - this._repeatedCount = anotherMc._repeatedCount; - this.drawFrame(); - }; - MovieClip.prototype.advance = function (timeInMiniseconds) { - var beginFrame = this._frame; - var beginReversed = this._reversed; - var backupTime = timeInMiniseconds; - while (true) { - var tt = this.interval + this._frames[this._frame].addDelay; - if (this._frame == 0 && this._repeatedCount > 0) - tt += this.repeatDelay; - if (timeInMiniseconds < tt) { - this._frameElapsed = 0; - break; - } - timeInMiniseconds -= tt; - if (this.swing) { - if (this._reversed) { - this._frame--; - if (this._frame <= 0) { - this._frame = 0; - this._repeatedCount++; - this._reversed = !this._reversed; - } - } - else { - this._frame++; - if (this._frame > this._frameCount - 1) { - this._frame = Math.max(0, this._frameCount - 2); - this._repeatedCount++; - this._reversed = !this._reversed; - } - } - } - else { - this._frame++; - if (this._frame > this._frameCount - 1) { - this._frame = 0; - this._repeatedCount++; - } - } - if (this._frame == beginFrame && this._reversed == beginReversed) { - var roundTime = backupTime - timeInMiniseconds; - timeInMiniseconds -= Math.floor(timeInMiniseconds / roundTime) * roundTime; - } - } - this.drawFrame(); - }; - MovieClip.prototype.setPlaySettings = function (start, end, times, endAt, endCallback, callbackObj) { - if (start == undefined) - start = 0; - if (end == undefined) - end = -1; - if (times == undefined) - times = 0; - if (endAt == undefined) - endAt = -1; - this._start = start; - this._end = end; - if (this._end == -1 || this._end > this._frameCount - 1) - this._end = this._frameCount - 1; - this._times = times; - this._endAt = endAt; - if (this._endAt == -1) - this._endAt = this._end; - this._status = 0; - this._callback = endCallback; - this._callbackObj = callbackObj; - this.frame = start; - }; - MovieClip.prototype.update = function () { - if (!this._playing || this._frameCount == 0 || this._status == 3) - return; - var dt = fgui.GTimers.deltaTime; - if (this.timeScale != 1) - dt *= this.timeScale; - this._frameElapsed += dt; - var tt = this.interval + this._frames[this._frame].addDelay; - if (this._frame == 0 && this._repeatedCount > 0) - tt += this.repeatDelay; - if (this._frameElapsed < tt) - return; - this._frameElapsed -= tt; - if (this._frameElapsed > this.interval) - this._frameElapsed = this.interval; - if (this.swing) { - if (this._reversed) { - this._frame--; - if (this._frame <= 0) { - this._frame = 0; - this._repeatedCount++; - this._reversed = !this._reversed; - } - } - else { - this._frame++; - if (this._frame > this._frameCount - 1) { - this._frame = Math.max(0, this._frameCount - 2); - this._repeatedCount++; - this._reversed = !this._reversed; - } - } - } - else { - this._frame++; - if (this._frame > this._frameCount - 1) { - this._frame = 0; - this._repeatedCount++; - } - } - if (this._status == 1) { - this._frame = this._start; - this._frameElapsed = 0; - this._status = 0; - } - else if (this._status == 2) { - this._frame = this._endAt; - this._frameElapsed = 0; - this._status = 3; - if (this._callback != null) { - var callback = this._callback; - var caller = this._callbackObj; - this._callback = null; - this._callbackObj = null; - callback.call(caller); - } - } - else { - if (this._frame == this._end) { - if (this._times > 0) { - this._times--; - if (this._times == 0) - this._status = 2; - else - this._status = 1; - } - else if (this._start != 0) - this._status = 1; - } - } - this.drawFrame(); - }; - MovieClip.prototype.drawFrame = function () { - if (this._frameCount > 0 && this._frame < this._frames.length) { - var frame = this._frames[this._frame]; - this.texture = frame.texture; - } - else - this.texture = null; - }; - MovieClip.prototype.checkTimer = function () { - if (this._playing && this._frameCount > 0 && this.stage != null) - fgui.GTimers.inst.add(1, 0, this.update, this); - else - fgui.GTimers.inst.remove(this.update, this); - }; - MovieClip.prototype.$onAddToStage = function (stage, nestLevel) { - _super_1.prototype.$onAddToStage.call(this, stage, nestLevel); - if (this._playing && this._frameCount > 0) - fgui.GTimers.inst.add(1, 0, this.update, this); - }; - MovieClip.prototype.$onRemoveFromStage = function () { - _super_1.prototype.$onRemoveFromStage.call(this); - fgui.GTimers.inst.remove(this.update, this); - }; - return MovieClip; - }(fgui.Image)); - fgui.MovieClip = MovieClip; -})(fgui || (fgui = {})); - -(function (fgui) { - var UIContainer = (function (_super_1) { - __extends(UIContainer, _super_1); - function UIContainer() { - var _this = _super_1.call(this) || this; - _this.touchEnabled = true; - _this.touchChildren = true; - return _this; - } - UIContainer.prototype.cacheHitArea = function (value) { - this._cachedHitArea = value; - if (value) { - if (!this._cachedMatrix) - this._cachedMatrix = new egret.Matrix(); - this._cachedMatrix.copyFrom(this.$getInvertedConcatenatedMatrix()); - } - }; - Object.defineProperty(UIContainer.prototype, "hitArea", { - get: function () { - return this._hitArea; - }, - set: function (value) { - this._hitArea = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(UIContainer.prototype, "opaque", { - get: function () { - return this._opaque; - }, - set: function (value) { - this._opaque = value; - }, - enumerable: true, - configurable: true - }); - UIContainer.prototype.$hitTest = function (stageX, stageY) { - if (!this.$visible) - return null; - if (this._hitArea) { - if (!this.touchEnabled) - return null; - if (this._hitArea.$graphics) { - if (!this._hitArea.$graphics.$hitTest(stageX, stageY)) - return null; - } - else { - var m = this._cachedHitArea ? this._cachedMatrix : this.$getInvertedConcatenatedMatrix(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - if (!this._hitArea.contains(localX, localY)) - return null; - } - return this; - } - var ret = _super_1.prototype.$hitTest.call(this, stageX, stageY); - if (ret == this && !this.touchEnabled) - return null; - if (ret == null && this._opaque) { - var m = this._cachedHitArea ? this._cachedMatrix : this.$getInvertedConcatenatedMatrix(); - var localX = m.a * stageX + m.c * stageY + m.tx; - var localY = m.b * stageX + m.d * stageY + m.ty; - if (localX >= 0 && localY >= 0 && localX <= this.$explicitWidth && localY <= this.$explicitHeight) - return this; - else - return null; - } - else if (ret == this && !this._opaque) - return null; - else - return ret; - }; - return UIContainer; - }(egret.DisplayObjectContainer)); - fgui.UIContainer = UIContainer; -})(fgui || (fgui = {})); - -(function (fgui) { - var DragEvent = (function (_super_1) { - __extends(DragEvent, _super_1); - function DragEvent(type, stageX, stageY, touchPointID) { - if (stageX === void 0) { stageX = 0; } - if (stageY === void 0) { stageY = 0; } - if (touchPointID === void 0) { touchPointID = -1; } - var _this = _super_1.call(this, type, false) || this; - _this.touchPointID = 0; - _this.stageX = stageX; - _this.stageY = stageY; - _this.touchPointID = touchPointID; - return _this; - } - DragEvent.prototype.preventDefault = function () { - this._prevented = true; - }; - DragEvent.prototype.isDefaultPrevented = function () { - return this._prevented; - }; - DragEvent.DRAG_START = "__dragStart"; - DragEvent.DRAG_END = "__dragEnd"; - DragEvent.DRAG_MOVING = "__dragMoving"; - return DragEvent; - }(egret.Event)); - fgui.DragEvent = DragEvent; -})(fgui || (fgui = {})); - -(function (fgui) { - var DropEvent = (function (_super_1) { - __extends(DropEvent, _super_1); - function DropEvent(type, source) { - var _this = _super_1.call(this, type, false) || this; - _this.source = source; - return _this; - } - DropEvent.DROP = "__drop"; - return DropEvent; - }(egret.Event)); - fgui.DropEvent = DropEvent; -})(fgui || (fgui = {})); - -(function (fgui) { - var ItemEvent = (function (_super_1) { - __extends(ItemEvent, _super_1); - function ItemEvent(type, itemObject, stageX, stageY) { - if (itemObject === void 0) { itemObject = null; } - if (stageX === void 0) { stageX = 0; } - if (stageY === void 0) { stageY = 0; } - var _this = _super_1.call(this, type, false) || this; - _this.itemObject = itemObject; - _this.stageX = stageX; - _this.stageY = stageY; - return _this; - } - ItemEvent.CLICK = "___itemClick"; - return ItemEvent; - }(egret.Event)); - fgui.ItemEvent = ItemEvent; -})(fgui || (fgui = {})); - -(function (fgui) { - var StateChangeEvent = (function (_super_1) { - __extends(StateChangeEvent, _super_1); - function StateChangeEvent(type) { - return _super_1.call(this, type, false) || this; - } - StateChangeEvent.CHANGED = "___stateChanged"; - return StateChangeEvent; - }(egret.Event)); - fgui.StateChangeEvent = StateChangeEvent; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearBase = (function () { - function GearBase(owner) { - this._owner = owner; - } - GearBase.create = function (owner, index) { - if (!Classes) - Classes = [ - fgui.GearDisplay, fgui.GearXY, fgui.GearSize, fgui.GearLook, fgui.GearColor, - fgui.GearAnimation, fgui.GearText, fgui.GearIcon, fgui.GearDisplay2, fgui.GearFontSize - ]; - return new (Classes[index])(owner); - }; - GearBase.prototype.dispose = function () { - if (this._tweenConfig && this._tweenConfig._tweener) { - this._tweenConfig._tweener.kill(); - this._tweenConfig._tweener = null; - } - }; - Object.defineProperty(GearBase.prototype, "controller", { - get: function () { - return this._controller; - }, - set: function (val) { - if (val != this._controller) { - this._controller = val; - if (this._controller) - this.init(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GearBase.prototype, "tweenConfig", { - get: function () { - if (!this._tweenConfig) - this._tweenConfig = new GearTweenConfig(); - return this._tweenConfig; - }, - enumerable: true, - configurable: true - }); - GearBase.prototype.setup = function (buffer) { - this._controller = this._owner.parent.getControllerAt(buffer.readShort()); - this.init(); - var i; - var page; - var cnt = buffer.readShort(); - if (this instanceof fgui.GearDisplay) { - this.pages = buffer.readSArray(cnt); - } - else if (this instanceof fgui.GearDisplay2) { - this.pages = buffer.readSArray(cnt); - } - else { - for (i = 0; i < cnt; i++) { - page = buffer.readS(); - if (page == null) - continue; - this.addStatus(page, buffer); - } - if (buffer.readBool()) - this.addStatus(null, buffer); - } - if (buffer.readBool()) { - this._tweenConfig = new GearTweenConfig(); - this._tweenConfig.easeType = buffer.readByte(); - this._tweenConfig.duration = buffer.readFloat(); - this._tweenConfig.delay = buffer.readFloat(); - } - if (buffer.version >= 2) { - if (this instanceof fgui.GearXY) { - if (buffer.readBool()) { - this.positionsInPercent = true; - for (i = 0; i < cnt; i++) { - page = buffer.readS(); - if (page == null) - continue; - this.addExtStatus(page, buffer); - } - if (buffer.readBool()) - this.addExtStatus(null, buffer); - } - } - else if (this instanceof fgui.GearDisplay2) - this.condition = buffer.readByte(); - } - }; - GearBase.prototype.updateFromRelations = function (dx, dy) { - }; - GearBase.prototype.addStatus = function (pageId, buffer) { - }; - GearBase.prototype.init = function () { - }; - GearBase.prototype.apply = function () { - }; - GearBase.prototype.updateState = function () { - }; - return GearBase; - }()); - fgui.GearBase = GearBase; - var Classes; - var GearTweenConfig = (function () { - function GearTweenConfig() { - this.tween = true; - this.easeType = fgui.EaseType.QuadOut; - this.duration = 0.3; - this.delay = 0; - } - return GearTweenConfig; - }()); - fgui.GearTweenConfig = GearTweenConfig; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearAnimation = (function (_super_1) { - __extends(GearAnimation, _super_1); - function GearAnimation(owner) { - return _super_1.call(this, owner) || this; - } - GearAnimation.prototype.init = function () { - this._default = { - playing: this._owner.getProp(fgui.ObjectPropID.Playing), - frame: this._owner.getProp(fgui.ObjectPropID.Frame) - }; - this._storage = {}; - }; - GearAnimation.prototype.addStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - this._storage[pageId] = gv = {}; - gv.playing = buffer.readBool(); - gv.frame = buffer.readInt(); - }; - GearAnimation.prototype.apply = function () { - this._owner._gearLocked = true; - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - gv = this._default; - this._owner.setProp(fgui.ObjectPropID.Playing, gv.playing); - this._owner.setProp(fgui.ObjectPropID.Frame, gv.frame); - this._owner._gearLocked = false; - }; - GearAnimation.prototype.updateState = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - this._storage[this._controller.selectedPageId] = gv = {}; - gv.playing = this._owner.getProp(fgui.ObjectPropID.Playing); - gv.frame = this._owner.getProp(fgui.ObjectPropID.Frame); - }; - return GearAnimation; - }(fgui.GearBase)); - fgui.GearAnimation = GearAnimation; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearColor = (function (_super_1) { - __extends(GearColor, _super_1); - function GearColor(owner) { - return _super_1.call(this, owner) || this; - } - GearColor.prototype.init = function () { - this._default = { - color: this._owner.getProp(fgui.ObjectPropID.Color), - strokeColor: this._owner.getProp(fgui.ObjectPropID.OutlineColor) - }; - this._storage = {}; - }; - GearColor.prototype.addStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - this._storage[pageId] = gv = {}; - gv.color = buffer.readColor(); - gv.strokeColor = buffer.readColor(); - }; - GearColor.prototype.apply = function () { - this._owner._gearLocked = true; - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - gv = this._default; - this._owner.setProp(fgui.ObjectPropID.Color, gv.color); - this._owner.setProp(fgui.ObjectPropID.OutlineColor, gv.strokeColor); - this._owner._gearLocked = false; - }; - GearColor.prototype.updateState = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - this._storage[this._controller.selectedPageId] = gv = {}; - gv.color = this._owner.getProp(fgui.ObjectPropID.Color); - gv.strokeColor = this._owner.getProp(fgui.ObjectPropID.OutlineColor); - }; - return GearColor; - }(fgui.GearBase)); - fgui.GearColor = GearColor; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearDisplay = (function (_super_1) { - __extends(GearDisplay, _super_1); - function GearDisplay(owner) { - var _this = _super_1.call(this, owner) || this; - _this._displayLockToken = 1; - _this._visible = 0; - return _this; - } - GearDisplay.prototype.init = function () { - this.pages = null; - }; - GearDisplay.prototype.apply = function () { - this._displayLockToken++; - if (this._displayLockToken == 0) - this._displayLockToken = 1; - if (this.pages == null || this.pages.length == 0 - || this.pages.indexOf(this._controller.selectedPageId) != -1) - this._visible = 1; - else - this._visible = 0; - }; - GearDisplay.prototype.addLock = function () { - this._visible++; - return this._displayLockToken; - }; - GearDisplay.prototype.releaseLock = function (token) { - if (token == this._displayLockToken) - this._visible--; - }; - Object.defineProperty(GearDisplay.prototype, "connected", { - get: function () { - return this._controller == null || this._visible > 0; - }, - enumerable: true, - configurable: true - }); - return GearDisplay; - }(fgui.GearBase)); - fgui.GearDisplay = GearDisplay; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearDisplay2 = (function (_super_1) { - __extends(GearDisplay2, _super_1); - function GearDisplay2(owner) { - var _this = _super_1.call(this, owner) || this; - _this._visible = 0; - return _this; - } - GearDisplay2.prototype.init = function () { - this.pages = null; - }; - GearDisplay2.prototype.apply = function () { - if (this.pages == null || this.pages.length == 0 - || this.pages.indexOf(this._controller.selectedPageId) != -1) - this._visible = 1; - else - this._visible = 0; - }; - GearDisplay2.prototype.evaluate = function (connected) { - var v = this._controller == null || this._visible > 0; - if (this.condition == 0) - v = v && connected; - else - v = v || connected; - return v; - }; - return GearDisplay2; - }(fgui.GearBase)); - fgui.GearDisplay2 = GearDisplay2; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearFontSize = (function (_super_1) { - __extends(GearFontSize, _super_1); - function GearFontSize(owner) { - var _this = _super_1.call(this, owner) || this; - _this._default = 0; - return _this; - } - GearFontSize.prototype.init = function () { - this._default = this._owner.getProp(fgui.ObjectPropID.FontSize); - this._storage = {}; - }; - GearFontSize.prototype.addStatus = function (pageId, buffer) { - if (pageId == null) - this._default = buffer.readInt(); - else - this._storage[pageId] = buffer.readInt(); - }; - GearFontSize.prototype.apply = function () { - this._owner._gearLocked = true; - var data = this._storage[this._controller.selectedPageId]; - if (data != undefined) - this._owner.setProp(fgui.ObjectPropID.FontSize, data); - else - this._owner.setProp(fgui.ObjectPropID.FontSize, this._default); - this._owner._gearLocked = false; - }; - GearFontSize.prototype.updateState = function () { - this._storage[this._controller.selectedPageId] = this._owner.getProp(fgui.ObjectPropID.FontSize); - }; - return GearFontSize; - }(fgui.GearBase)); - fgui.GearFontSize = GearFontSize; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearIcon = (function (_super_1) { - __extends(GearIcon, _super_1); - function GearIcon(owner) { - return _super_1.call(this, owner) || this; - } - GearIcon.prototype.init = function () { - this._default = this._owner.icon; - this._storage = {}; - }; - GearIcon.prototype.addStatus = function (pageId, buffer) { - if (pageId == null) - this._default = buffer.readS(); - else - this._storage[pageId] = buffer.readS(); - }; - GearIcon.prototype.apply = function () { - this._owner._gearLocked = true; - var data = this._storage[this._controller.selectedPageId]; - if (data !== undefined) - this._owner.icon = data; - else - this._owner.icon = this._default; - this._owner._gearLocked = false; - }; - GearIcon.prototype.updateState = function () { - this._storage[this._controller.selectedPageId] = this._owner.icon; - }; - return GearIcon; - }(fgui.GearBase)); - fgui.GearIcon = GearIcon; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearLook = (function (_super_1) { - __extends(GearLook, _super_1); - function GearLook(owner) { - return _super_1.call(this, owner) || this; - } - GearLook.prototype.init = function () { - this._default = { - alpha: this._owner.alpha, - rotation: this._owner.rotation, - grayed: this._owner.grayed, - touchable: this._owner.touchable - }; - this._storage = {}; - }; - GearLook.prototype.addStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - this._storage[pageId] = gv = {}; - gv.alpha = buffer.readFloat(); - gv.rotation = buffer.readFloat(); - gv.grayed = buffer.readBool(); - gv.touchable = buffer.readBool(); - }; - GearLook.prototype.apply = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - gv = this._default; - if (this._tweenConfig && this._tweenConfig.tween && !fgui.UIPackage._constructing && !fgui.GearBase.disableAllTweenEffect) { - this._owner._gearLocked = true; - this._owner.grayed = gv.grayed; - this._owner.touchable = gv.touchable; - this._owner._gearLocked = false; - if (this._tweenConfig._tweener) { - if (this._tweenConfig._tweener.endValue.x != gv.alpha || this._tweenConfig._tweener.endValue.y != gv.rotation) { - this._tweenConfig._tweener.kill(true); - this._tweenConfig._tweener = null; - } - else - return; - } - var a = gv.alpha != this._owner.alpha; - var b = gv.rotation != this._owner.rotation; - if (a || b) { - if (this._owner.checkGearController(0, this._controller)) - this._tweenConfig._displayLockToken = this._owner.addDisplayLock(); - this._tweenConfig._tweener = fgui.GTween.to2(this._owner.alpha, this._owner.rotation, gv.alpha, gv.rotation, this._tweenConfig.duration) - .setDelay(this._tweenConfig.delay) - .setEase(this._tweenConfig.easeType) - .setUserData((a ? 1 : 0) + (b ? 2 : 0)) - .setTarget(this) - .onUpdate(this.__tweenUpdate, this) - .onComplete(this.__tweenComplete, this); - } - } - else { - this._owner._gearLocked = true; - this._owner.grayed = gv.grayed; - this._owner.touchable = gv.touchable; - this._owner.alpha = gv.alpha; - this._owner.rotation = gv.rotation; - this._owner._gearLocked = false; - } - }; - GearLook.prototype.__tweenUpdate = function (tweener) { - var flag = tweener.userData; - this._owner._gearLocked = true; - if ((flag & 1) != 0) - this._owner.alpha = tweener.value.x; - if ((flag & 2) != 0) - this._owner.rotation = tweener.value.y; - this._owner._gearLocked = false; - }; - GearLook.prototype.__tweenComplete = function () { - if (this._tweenConfig._displayLockToken != 0) { - this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken); - this._tweenConfig._displayLockToken = 0; - } - this._tweenConfig._tweener = null; - }; - GearLook.prototype.updateState = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - this._storage[this._controller.selectedPageId] = gv = {}; - gv.alpha = this._owner.alpha; - gv.rotation = this._owner.rotation; - gv.grayed = this._owner.grayed; - gv.touchable = this._owner.touchable; - }; - return GearLook; - }(fgui.GearBase)); - fgui.GearLook = GearLook; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearSize = (function (_super_1) { - __extends(GearSize, _super_1); - function GearSize(owner) { - return _super_1.call(this, owner) || this; - } - GearSize.prototype.init = function () { - this._default = { - width: this._owner.width, - height: this._owner.height, - scaleX: this._owner.scaleX, - scaleY: this._owner.scaleY - }; - this._storage = {}; - }; - GearSize.prototype.addStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - this._storage[pageId] = gv = {}; - gv.width = buffer.readInt(); - gv.height = buffer.readInt(); - gv.scaleX = buffer.readFloat(); - gv.scaleY = buffer.readFloat(); - }; - GearSize.prototype.apply = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - gv = this._default; - if (this._tweenConfig && this._tweenConfig.tween && !fgui.UIPackage._constructing && !fgui.GearBase.disableAllTweenEffect) { - if (this._tweenConfig._tweener) { - if (this._tweenConfig._tweener.endValue.x != gv.width || this._tweenConfig._tweener.endValue.y != gv.height - || this._tweenConfig._tweener.endValue.z != gv.scaleX || this._tweenConfig._tweener.endValue.w != gv.scaleY) { - this._tweenConfig._tweener.kill(true); - this._tweenConfig._tweener = null; - } - else - return; - } - var a = gv.width != this._owner.width || gv.height != this._owner.height; - var b = gv.scaleX != this._owner.scaleX || gv.scaleY != this._owner.scaleY; - if (a || b) { - if (this._owner.checkGearController(0, this._controller)) - this._tweenConfig._displayLockToken = this._owner.addDisplayLock(); - this._tweenConfig._tweener = fgui.GTween.to4(this._owner.width, this._owner.height, this._owner.scaleX, this._owner.scaleY, gv.width, gv.height, gv.scaleX, gv.scaleY, this._tweenConfig.duration) - .setDelay(this._tweenConfig.delay) - .setEase(this._tweenConfig.easeType) - .setUserData((a ? 1 : 0) + (b ? 2 : 0)) - .setTarget(this) - .onUpdate(this.__tweenUpdate, this) - .onComplete(this.__tweenComplete, this); - } - } - else { - this._owner._gearLocked = true; - this._owner.setSize(gv.width, gv.height, this._owner.gearXY.controller == this._controller); - this._owner.setScale(gv.scaleX, gv.scaleY); - this._owner._gearLocked = false; - } - }; - GearSize.prototype.__tweenUpdate = function (tweener) { - var flag = tweener.userData; - this._owner._gearLocked = true; - if ((flag & 1) != 0) - this._owner.setSize(tweener.value.x, tweener.value.y, this._owner.checkGearController(1, this._controller)); - if ((flag & 2) != 0) - this._owner.setScale(tweener.value.z, tweener.value.w); - this._owner._gearLocked = false; - }; - GearSize.prototype.__tweenComplete = function () { - if (this._tweenConfig._displayLockToken != 0) { - this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken); - this._tweenConfig._displayLockToken = 0; - } - this._tweenConfig._tweener = null; - }; - GearSize.prototype.updateState = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - this._storage[this._controller.selectedPageId] = gv = {}; - gv.width = this._owner.width; - gv.height = this._owner.height; - gv.scaleX = this._owner.scaleX; - gv.scaleY = this._owner.scaleY; - }; - GearSize.prototype.updateFromRelations = function (dx, dy) { - if (this._controller == null || this._storage == null) - return; - for (var key in this._storage) { - var gv = this._storage[key]; - gv.width += dx; - gv.height += dy; - } - this._default.width += dx; - this._default.height += dy; - this.updateState(); - }; - return GearSize; - }(fgui.GearBase)); - fgui.GearSize = GearSize; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearText = (function (_super_1) { - __extends(GearText, _super_1); - function GearText(owner) { - return _super_1.call(this, owner) || this; - } - GearText.prototype.init = function () { - this._default = this._owner.text; - this._storage = {}; - }; - GearText.prototype.addStatus = function (pageId, buffer) { - if (pageId == null) - this._default = buffer.readS(); - else - this._storage[pageId] = buffer.readS(); - }; - GearText.prototype.apply = function () { - this._owner._gearLocked = true; - var data = this._storage[this._controller.selectedPageId]; - if (data !== undefined) - this._owner.text = data; - else - this._owner.text = this._default; - this._owner._gearLocked = false; - }; - GearText.prototype.updateState = function () { - this._storage[this._controller.selectedPageId] = this._owner.text; - }; - return GearText; - }(fgui.GearBase)); - fgui.GearText = GearText; -})(fgui || (fgui = {})); - -(function (fgui) { - var GearXY = (function (_super_1) { - __extends(GearXY, _super_1); - function GearXY(owner) { - return _super_1.call(this, owner) || this; - } - GearXY.prototype.init = function () { - this._default = { - x: this._owner.x, - y: this._owner.y, - px: this._owner.x / this._owner.parent.width, - py: this._owner.y / this._owner.parent.height - }; - this._storage = {}; - }; - GearXY.prototype.addStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - this._storage[pageId] = gv = {}; - gv.x = buffer.readInt(); - gv.y = buffer.readInt(); - }; - GearXY.prototype.addExtStatus = function (pageId, buffer) { - var gv; - if (pageId == null) - gv = this._default; - else - gv = this._storage[pageId]; - gv.px = buffer.readFloat(); - gv.py = buffer.readFloat(); - }; - GearXY.prototype.apply = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - gv = this._default; - var ex; - var ey; - if (this.positionsInPercent && this._owner.parent) { - ex = gv.px * this._owner.parent.width; - ey = gv.py * this._owner.parent.height; - } - else { - ex = gv.x; - ey = gv.y; - } - if (this._tweenConfig && this._tweenConfig.tween && !fgui.UIPackage._constructing && !fgui.GearBase.disableAllTweenEffect) { - if (this._tweenConfig._tweener) { - if (this._tweenConfig._tweener.endValue.x != ex || this._tweenConfig._tweener.endValue.y != ey) { - this._tweenConfig._tweener.kill(true); - this._tweenConfig._tweener = null; - } - else - return; - } - var ox = this._owner.x; - var oy = this._owner.y; - if (ox != ex || oy != ey) { - if (this._owner.checkGearController(0, this._controller)) - this._tweenConfig._displayLockToken = this._owner.addDisplayLock(); - this._tweenConfig._tweener = fgui.GTween.to2(ox, oy, ex, ey, this._tweenConfig.duration) - .setDelay(this._tweenConfig.delay) - .setEase(this._tweenConfig.easeType) - .setTarget(this) - .onUpdate(this.__tweenUpdate, this) - .onComplete(this.__tweenComplete, this); - } - } - else { - this._owner._gearLocked = true; - this._owner.setXY(ex, ey); - this._owner._gearLocked = false; - } - }; - GearXY.prototype.__tweenUpdate = function (tweener) { - this._owner._gearLocked = true; - this._owner.setXY(tweener.value.x, tweener.value.y); - this._owner._gearLocked = false; - }; - GearXY.prototype.__tweenComplete = function () { - if (this._tweenConfig._displayLockToken != 0) { - this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken); - this._tweenConfig._displayLockToken = 0; - } - this._tweenConfig._tweener = null; - }; - GearXY.prototype.updateState = function () { - var gv = this._storage[this._controller.selectedPageId]; - if (!gv) - this._storage[this._controller.selectedPageId] = gv = {}; - gv.x = this._owner.x; - gv.y = this._owner.y; - gv.px = this._owner.x / this._owner.parent.width; - gv.py = this._owner.y / this._owner.parent.height; - }; - GearXY.prototype.updateFromRelations = function (dx, dy) { - if (this._controller == null || this._storage == null || this.positionsInPercent) - return; - for (var key in this._storage) { - var pt = this._storage[key]; - pt.x += dx; - pt.y += dy; - } - this._default.x += dx; - this._default.y += dy; - this.updateState(); - }; - return GearXY; - }(fgui.GearBase)); - fgui.GearXY = GearXY; -})(fgui || (fgui = {})); - -(function (fgui) { - var _PiOver2 = Math.PI * 0.5; - var _TwoPi = Math.PI * 2; - function evaluateEase(easeType, time, duration, overshootOrAmplitude, period) { - switch (easeType) { - case fgui.EaseType.Linear: - return time / duration; - case fgui.EaseType.SineIn: - return -Math.cos(time / duration * _PiOver2) + 1; - case fgui.EaseType.SineOut: - return Math.sin(time / duration * _PiOver2); - case fgui.EaseType.SineInOut: - return -0.5 * (Math.cos(Math.PI * time / duration) - 1); - case fgui.EaseType.QuadIn: - return (time /= duration) * time; - case fgui.EaseType.QuadOut: - return -(time /= duration) * (time - 2); - case fgui.EaseType.QuadInOut: - if ((time /= duration * 0.5) < 1) - return 0.5 * time * time; - return -0.5 * ((--time) * (time - 2) - 1); - case fgui.EaseType.CubicIn: - return (time /= duration) * time * time; - case fgui.EaseType.CubicOut: - return ((time = time / duration - 1) * time * time + 1); - case fgui.EaseType.CubicInOut: - if ((time /= duration * 0.5) < 1) - return 0.5 * time * time * time; - return 0.5 * ((time -= 2) * time * time + 2); - case fgui.EaseType.QuartIn: - return (time /= duration) * time * time * time; - case fgui.EaseType.QuartOut: - return -((time = time / duration - 1) * time * time * time - 1); - case fgui.EaseType.QuartInOut: - if ((time /= duration * 0.5) < 1) - return 0.5 * time * time * time * time; - return -0.5 * ((time -= 2) * time * time * time - 2); - case fgui.EaseType.QuintIn: - return (time /= duration) * time * time * time * time; - case fgui.EaseType.QuintOut: - return ((time = time / duration - 1) * time * time * time * time + 1); - case fgui.EaseType.QuintInOut: - if ((time /= duration * 0.5) < 1) - return 0.5 * time * time * time * time * time; - return 0.5 * ((time -= 2) * time * time * time * time + 2); - case fgui.EaseType.ExpoIn: - return (time == 0) ? 0 : Math.pow(2, 10 * (time / duration - 1)); - case fgui.EaseType.ExpoOut: - if (time == duration) - return 1; - return (-Math.pow(2, -10 * time / duration) + 1); - case fgui.EaseType.ExpoInOut: - if (time == 0) - return 0; - if (time == duration) - return 1; - if ((time /= duration * 0.5) < 1) - return 0.5 * Math.pow(2, 10 * (time - 1)); - return 0.5 * (-Math.pow(2, -10 * --time) + 2); - case fgui.EaseType.CircIn: - return -(Math.sqrt(1 - (time /= duration) * time) - 1); - case fgui.EaseType.CircOut: - return Math.sqrt(1 - (time = time / duration - 1) * time); - case fgui.EaseType.CircInOut: - if ((time /= duration * 0.5) < 1) - return -0.5 * (Math.sqrt(1 - time * time) - 1); - return 0.5 * (Math.sqrt(1 - (time -= 2) * time) + 1); - case fgui.EaseType.ElasticIn: - var s0; - if (time == 0) - return 0; - if ((time /= duration) == 1) - return 1; - if (period == 0) - period = duration * 0.3; - if (overshootOrAmplitude < 1) { - overshootOrAmplitude = 1; - s0 = period / 4; - } - else - s0 = period / _TwoPi * Math.asin(1 / overshootOrAmplitude); - return -(overshootOrAmplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time * duration - s0) * _TwoPi / period)); - case fgui.EaseType.ElasticOut: - var s1; - if (time == 0) - return 0; - if ((time /= duration) == 1) - return 1; - if (period == 0) - period = duration * 0.3; - if (overshootOrAmplitude < 1) { - overshootOrAmplitude = 1; - s1 = period / 4; - } - else - s1 = period / _TwoPi * Math.asin(1 / overshootOrAmplitude); - return (overshootOrAmplitude * Math.pow(2, -10 * time) * Math.sin((time * duration - s1) * _TwoPi / period) + 1); - case fgui.EaseType.ElasticInOut: - var s; - if (time == 0) - return 0; - if ((time /= duration * 0.5) == 2) - return 1; - if (period == 0) - period = duration * (0.3 * 1.5); - if (overshootOrAmplitude < 1) { - overshootOrAmplitude = 1; - s = period / 4; - } - else - s = period / _TwoPi * Math.asin(1 / overshootOrAmplitude); - if (time < 1) - return -0.5 * (overshootOrAmplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time * duration - s) * _TwoPi / period)); - return overshootOrAmplitude * Math.pow(2, -10 * (time -= 1)) * Math.sin((time * duration - s) * _TwoPi / period) * 0.5 + 1; - case fgui.EaseType.BackIn: - return (time /= duration) * time * ((overshootOrAmplitude + 1) * time - overshootOrAmplitude); - case fgui.EaseType.BackOut: - return ((time = time / duration - 1) * time * ((overshootOrAmplitude + 1) * time + overshootOrAmplitude) + 1); - case fgui.EaseType.BackInOut: - if ((time /= duration * 0.5) < 1) - return 0.5 * (time * time * (((overshootOrAmplitude *= (1.525)) + 1) * time - overshootOrAmplitude)); - return 0.5 * ((time -= 2) * time * (((overshootOrAmplitude *= (1.525)) + 1) * time + overshootOrAmplitude) + 2); - case fgui.EaseType.BounceIn: - return bounce_easeIn(time, duration); - case fgui.EaseType.BounceOut: - return bounce_easeOut(time, duration); - case fgui.EaseType.BounceInOut: - return bounce_easeInOut(time, duration); - default: - return -(time /= duration) * (time - 2); - } - } - fgui.evaluateEase = evaluateEase; - function bounce_easeIn(time, duration) { - return 1 - bounce_easeOut(duration - time, duration); - } - function bounce_easeOut(time, duration) { - if ((time /= duration) < (1 / 2.75)) { - return (7.5625 * time * time); - } - if (time < (2 / 2.75)) { - return (7.5625 * (time -= (1.5 / 2.75)) * time + 0.75); - } - if (time < (2.5 / 2.75)) { - return (7.5625 * (time -= (2.25 / 2.75)) * time + 0.9375); - } - return (7.5625 * (time -= (2.625 / 2.75)) * time + 0.984375); - } - function bounce_easeInOut(time, duration) { - if (time < duration * 0.5) { - return bounce_easeIn(time * 2, duration) * 0.5; - } - return bounce_easeOut(time * 2 - duration, duration) * 0.5 + 0.5; - } -})(fgui || (fgui = {})); - -(function (fgui) { - var EaseType = (function () { - function EaseType() { - } - EaseType.Linear = 0; - EaseType.SineIn = 1; - EaseType.SineOut = 2; - EaseType.SineInOut = 3; - EaseType.QuadIn = 4; - EaseType.QuadOut = 5; - EaseType.QuadInOut = 6; - EaseType.CubicIn = 7; - EaseType.CubicOut = 8; - EaseType.CubicInOut = 9; - EaseType.QuartIn = 10; - EaseType.QuartOut = 11; - EaseType.QuartInOut = 12; - EaseType.QuintIn = 13; - EaseType.QuintOut = 14; - EaseType.QuintInOut = 15; - EaseType.ExpoIn = 16; - EaseType.ExpoOut = 17; - EaseType.ExpoInOut = 18; - EaseType.CircIn = 19; - EaseType.CircOut = 20; - EaseType.CircInOut = 21; - EaseType.ElasticIn = 22; - EaseType.ElasticOut = 23; - EaseType.ElasticInOut = 24; - EaseType.BackIn = 25; - EaseType.BackOut = 26; - EaseType.BackInOut = 27; - EaseType.BounceIn = 28; - EaseType.BounceOut = 29; - EaseType.BounceInOut = 30; - EaseType.Custom = 31; - return EaseType; - }()); - fgui.EaseType = EaseType; -})(fgui || (fgui = {})); - -(function (fgui) { - var GPath = (function () { - function GPath() { - this._segments = new Array(); - this._points = new Array(); - } - Object.defineProperty(GPath.prototype, "length", { - get: function () { - return this._fullLength; - }, - enumerable: true, - configurable: true - }); - GPath.prototype.create = function (pt1, pt2, pt3, pt4) { - var points; - if (Array.isArray(pt1)) - points = pt1; - else { - points = new Array(); - points.push(pt1); - points.push(pt2); - if (pt3) - points.push(pt3); - if (pt4) - points.push(pt4); - } - this._segments.length = 0; - this._points.length = 0; - this._fullLength = 0; - var cnt = points.length; - if (cnt == 0) - return; - var splinePoints = s_points; - splinePoints.length = 0; - var prev = points[0]; - if (prev.curveType == fgui.CurveType.CRSpline) - splinePoints.push(new egret.Point(prev.x, prev.y)); - for (var i = 1; i < cnt; i++) { - var current = points[i]; - if (prev.curveType != fgui.CurveType.CRSpline) { - var seg = {}; - seg.type = prev.curveType; - seg.ptStart = this._points.length; - if (prev.curveType == fgui.CurveType.Straight) { - seg.ptCount = 2; - this._points.push(new egret.Point(prev.x, prev.y)); - this._points.push(new egret.Point(current.x, current.y)); - } - else if (prev.curveType == fgui.CurveType.Bezier) { - seg.ptCount = 3; - this._points.push(new egret.Point(prev.x, prev.y)); - this._points.push(new egret.Point(current.x, current.y)); - this._points.push(new egret.Point(prev.control1_x, prev.control1_y)); - } - else if (prev.curveType == fgui.CurveType.CubicBezier) { - seg.ptCount = 4; - this._points.push(new egret.Point(prev.x, prev.y)); - this._points.push(new egret.Point(current.x, current.y)); - this._points.push(new egret.Point(prev.control1_x, prev.control1_y)); - this._points.push(new egret.Point(prev.control2_x, prev.control2_y)); - } - seg.length = fgui.ToolSet.distance(prev.x, prev.y, current.x, current.y); - this._fullLength += seg.length; - this._segments.push(seg); - } - if (current.curveType != fgui.CurveType.CRSpline) { - if (splinePoints.length > 0) { - splinePoints.push(new egret.Point(current.x, current.y)); - this.createSplineSegment(); - } - } - else - splinePoints.push(new egret.Point(current.x, current.y)); - prev = current; - } - if (splinePoints.length > 1) - this.createSplineSegment(); - }; - GPath.prototype.createSplineSegment = function () { - var splinePoints = s_points; - var cnt = splinePoints.length; - splinePoints.splice(0, 0, splinePoints[0]); - splinePoints.push(splinePoints[cnt]); - splinePoints.push(splinePoints[cnt]); - cnt += 3; - var seg = {}; - seg.type = fgui.CurveType.CRSpline; - seg.ptStart = this._points.length; - seg.ptCount = cnt; - this._points = this._points.concat(splinePoints); - seg.length = 0; - for (var i = 1; i < cnt; i++) { - seg.length += fgui.ToolSet.distance(splinePoints[i - 1].x, splinePoints[i - 1].y, splinePoints[i].x, splinePoints[i].y); - } - this._fullLength += seg.length; - this._segments.push(seg); - splinePoints.length = 0; - }; - GPath.prototype.clear = function () { - this._segments.length = 0; - this._points.length = 0; - }; - GPath.prototype.getPointAt = function (t, result) { - if (!result) - result = new egret.Point(); - else - result.x = result.y = 0; - t = fgui.ToolSet.clamp01(t); - var cnt = this._segments.length; - if (cnt == 0) { - return result; - } - var seg; - if (t == 1) { - seg = this._segments[cnt - 1]; - if (seg.type == fgui.CurveType.Straight) { - result.x = fgui.ToolSet.lerp(this._points[seg.ptStart].x, this._points[seg.ptStart + 1].x, t); - result.y = fgui.ToolSet.lerp(this._points[seg.ptStart].y, this._points[seg.ptStart + 1].y, t); - return result; - } - else if (seg.type == fgui.CurveType.Bezier || seg.type == fgui.CurveType.CubicBezier) - return this.onBezierCurve(seg.ptStart, seg.ptCount, t, result); - else - return this.onCRSplineCurve(seg.ptStart, seg.ptCount, t, result); - } - var len = t * this._fullLength; - for (var i = 0; i < cnt; i++) { - seg = this._segments[i]; - len -= seg.length; - if (len < 0) { - t = 1 + len / seg.length; - if (seg.type == fgui.CurveType.Straight) { - result.x = fgui.ToolSet.lerp(this._points[seg.ptStart].x, this._points[seg.ptStart + 1].x, t); - result.y = fgui.ToolSet.lerp(this._points[seg.ptStart].y, this._points[seg.ptStart + 1].y, t); - } - else if (seg.type == fgui.CurveType.Bezier || seg.type == fgui.CurveType.CubicBezier) - result = this.onBezierCurve(seg.ptStart, seg.ptCount, t, result); - else - result = this.onCRSplineCurve(seg.ptStart, seg.ptCount, t, result); - break; - } - } - return result; - }; - Object.defineProperty(GPath.prototype, "segmentCount", { - get: function () { - return this._segments.length; - }, - enumerable: true, - configurable: true - }); - GPath.prototype.getAnchorsInSegment = function (segmentIndex, points) { - if (points == null) - points = new Array(); - var seg = this._segments[segmentIndex]; - for (var i = 0; i < seg.ptCount; i++) - points.push(new egret.Point(this._points[seg.ptStart + i].x, this._points[seg.ptStart + i].y)); - return points; - }; - GPath.prototype.getPointsInSegment = function (segmentIndex, t0, t1, points, ts, pointDensity) { - if (points == null) - points = new Array(); - if (!pointDensity || isNaN(pointDensity)) - pointDensity = 0.1; - if (ts) - ts.push(t0); - var seg = this._segments[segmentIndex]; - if (seg.type == fgui.CurveType.Straight) { - points.push(new egret.Point(fgui.ToolSet.lerp(this._points[seg.ptStart].x, this._points[seg.ptStart + 1].x, t0), fgui.ToolSet.lerp(this._points[seg.ptStart].y, this._points[seg.ptStart + 1].y, t0))); - points.push(new egret.Point(fgui.ToolSet.lerp(this._points[seg.ptStart].x, this._points[seg.ptStart + 1].x, t1), fgui.ToolSet.lerp(this._points[seg.ptStart].y, this._points[seg.ptStart + 1].y, t1))); - } - else { - var func; - if (seg.type == fgui.CurveType.Bezier || seg.type == fgui.CurveType.CubicBezier) - func = this.onBezierCurve; - else - func = this.onCRSplineCurve; - points.push(func.call(this, seg.ptStart, seg.ptCount, t0, new egret.Point())); - var SmoothAmount = Math.min(seg.length * pointDensity, 50); - for (var j = 0; j <= SmoothAmount; j++) { - var t = j / SmoothAmount; - if (t > t0 && t < t1) { - points.push(func.call(this, seg.ptStart, seg.ptCount, t, new egret.Point())); - if (ts != null) - ts.push(t); - } - } - points.push(func.call(this, seg.ptStart, seg.ptCount, t1, new egret.Point())); - } - if (ts != null) - ts.push(t1); - return points; - }; - GPath.prototype.getAllPoints = function (points, ts, pointDensity) { - if (points == null) - points = new Array(); - if (!pointDensity || isNaN(pointDensity)) - pointDensity = 0.1; - var cnt = this._segments.length; - for (var i = 0; i < cnt; i++) - this.getPointsInSegment(i, 0, 1, points, ts, pointDensity); - return points; - }; - GPath.prototype.onCRSplineCurve = function (ptStart, ptCount, t, result) { - var adjustedIndex = Math.floor(t * (ptCount - 4)) + ptStart; - var p0x = this._points[adjustedIndex].x; - var p0y = this._points[adjustedIndex].y; - var p1x = this._points[adjustedIndex + 1].x; - var p1y = this._points[adjustedIndex + 1].y; - var p2x = this._points[adjustedIndex + 2].x; - var p2y = this._points[adjustedIndex + 2].y; - var p3x = this._points[adjustedIndex + 3].x; - var p3y = this._points[adjustedIndex + 3].y; - var adjustedT = (t == 1) ? 1 : fgui.ToolSet.repeat(t * (ptCount - 4), 1); - var t0 = ((-adjustedT + 2) * adjustedT - 1) * adjustedT * 0.5; - var t1 = (((3 * adjustedT - 5) * adjustedT) * adjustedT + 2) * 0.5; - var t2 = ((-3 * adjustedT + 4) * adjustedT + 1) * adjustedT * 0.5; - var t3 = ((adjustedT - 1) * adjustedT * adjustedT) * 0.5; - result.x = p0x * t0 + p1x * t1 + p2x * t2 + p3x * t3; - result.y = p0y * t0 + p1y * t1 + p2y * t2 + p3y * t3; - return result; - }; - GPath.prototype.onBezierCurve = function (ptStart, ptCount, t, result) { - var t2 = 1 - t; - var p0x = this._points[ptStart].x; - var p0y = this._points[ptStart].y; - var p1x = this._points[ptStart + 1].x; - var p1y = this._points[ptStart + 1].y; - var cp0x = this._points[ptStart + 2].x; - var cp0y = this._points[ptStart + 2].y; - if (ptCount == 4) { - var cp1x = this._points[ptStart + 3].x; - var cp1y = this._points[ptStart + 3].y; - result.x = t2 * t2 * t2 * p0x + 3 * t2 * t2 * t * cp0x + 3 * t2 * t * t * cp1x + t * t * t * p1x; - result.y = t2 * t2 * t2 * p0y + 3 * t2 * t2 * t * cp0y + 3 * t2 * t * t * cp1y + t * t * t * p1y; - } - else { - result.x = t2 * t2 * p0x + 2 * t2 * t * cp0x + t * t * p1x; - result.y = t2 * t2 * p0y + 2 * t2 * t * cp0y + t * t * p1y; - } - return result; - }; - return GPath; - }()); - fgui.GPath = GPath; - var s_points = new Array(); -})(fgui || (fgui = {})); - -(function (fgui) { - var CurveType; - (function (CurveType) { - CurveType[CurveType["CRSpline"] = 0] = "CRSpline"; - CurveType[CurveType["Bezier"] = 1] = "Bezier"; - CurveType[CurveType["CubicBezier"] = 2] = "CubicBezier"; - CurveType[CurveType["Straight"] = 3] = "Straight"; - })(CurveType = fgui.CurveType || (fgui.CurveType = {})); - var GPathPoint = (function () { - function GPathPoint() { - this.x = 0; - this.y = 0; - this.control1_x = 0; - this.control1_y = 0; - this.control2_x = 0; - this.control2_y = 0; - this.curveType = 0; - } - GPathPoint.newPoint = function (x, y, curveType) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (curveType === void 0) { curveType = 0; } - var pt = new GPathPoint(); - pt.x = x; - pt.y = y; - pt.control1_x = 0; - pt.control1_y = 0; - pt.control2_x = 0; - pt.control2_y = 0; - pt.curveType = curveType; - return pt; - }; - GPathPoint.newBezierPoint = function (x, y, control1_x, control1_y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (control1_x === void 0) { control1_x = 0; } - if (control1_y === void 0) { control1_y = 0; } - var pt = new GPathPoint(); - pt.x = x; - pt.y = y; - pt.control1_x = control1_x; - pt.control1_y = control1_y; - pt.control2_x = 0; - pt.control2_y = 0; - pt.curveType = CurveType.Bezier; - return pt; - }; - GPathPoint.newCubicBezierPoint = function (x, y, control1_x, control1_y, control2_x, control2_y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (control1_x === void 0) { control1_x = 0; } - if (control1_y === void 0) { control1_y = 0; } - if (control2_x === void 0) { control2_x = 0; } - if (control2_y === void 0) { control2_y = 0; } - var pt = new GPathPoint(); - pt.x = x; - pt.y = y; - pt.control1_x = control1_x; - pt.control1_y = control1_y; - pt.control2_x = control2_x; - pt.control2_y = control2_y; - pt.curveType = CurveType.CubicBezier; - return pt; - }; - GPathPoint.prototype.clone = function () { - var ret = new GPathPoint(); - ret.x = this.x; - ret.y = this.y; - ret.control1_x = this.control1_x; - ret.control1_y = this.control1_y; - ret.control2_x = this.control2_x; - ret.control2_y = this.control2_y; - ret.curveType = this.curveType; - return ret; - }; - return GPathPoint; - }()); - fgui.GPathPoint = GPathPoint; -})(fgui || (fgui = {})); - -(function (fgui) { - var GTween = (function () { - function GTween() { - } - GTween.to = function (start, end, duration) { - return fgui.TweenManager.createTween()._to(start, end, duration); - }; - GTween.to2 = function (start, start2, end, end2, duration) { - return fgui.TweenManager.createTween()._to2(start, start2, end, end2, duration); - }; - GTween.to3 = function (start, start2, start3, end, end2, end3, duration) { - return fgui.TweenManager.createTween()._to3(start, start2, start3, end, end2, end3, duration); - }; - GTween.to4 = function (start, start2, start3, start4, end, end2, end3, end4, duration) { - return fgui.TweenManager.createTween()._to4(start, start2, start3, start4, end, end2, end3, end4, duration); - }; - GTween.toColor = function (start, end, duration) { - return fgui.TweenManager.createTween()._toColor(start, end, duration); - }; - GTween.delayedCall = function (delay) { - return fgui.TweenManager.createTween().setDelay(delay); - }; - GTween.shake = function (startX, startY, amplitude, duration) { - return fgui.TweenManager.createTween()._shake(startX, startY, amplitude, duration); - }; - GTween.isTweening = function (target, propType) { - return fgui.TweenManager.isTweening(target, propType); - }; - GTween.kill = function (target, complete, propType) { - fgui.TweenManager.killTweens(target, complete, propType); - }; - GTween.getTween = function (target, propType) { - return fgui.TweenManager.getTween(target, propType); - }; - GTween.catchCallbackExceptions = true; - return GTween; - }()); - fgui.GTween = GTween; -})(fgui || (fgui = {})); - -(function (fgui) { - var GTweener = (function () { - function GTweener() { - this._startValue = new fgui.TweenValue(); - this._endValue = new fgui.TweenValue(); - this._value = new fgui.TweenValue(); - this._deltaValue = new fgui.TweenValue(); - this._reset(); - } - GTweener.prototype.setDelay = function (value) { - this._delay = value; - return this; - }; - Object.defineProperty(GTweener.prototype, "delay", { - get: function () { - return this._delay; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setDuration = function (value) { - this._duration = value; - return this; - }; - Object.defineProperty(GTweener.prototype, "duration", { - get: function () { - return this._duration; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setBreakpoint = function (value) { - this._breakpoint = value; - return this; - }; - GTweener.prototype.setEase = function (value) { - this._easeType = value; - return this; - }; - GTweener.prototype.setEasePeriod = function (value) { - this._easePeriod = value; - return this; - }; - GTweener.prototype.setEaseOvershootOrAmplitude = function (value) { - this._easeOvershootOrAmplitude = value; - return this; - }; - GTweener.prototype.setRepeat = function (repeat, yoyo) { - this._repeat = repeat; - this._yoyo = yoyo; - return this; - }; - Object.defineProperty(GTweener.prototype, "repeat", { - get: function () { - return this._repeat; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setTimeScale = function (value) { - this._timeScale = value; - return this; - }; - GTweener.prototype.setSnapping = function (value) { - this._snapping = value; - return this; - }; - GTweener.prototype.setTarget = function (value, propType) { - this._target = value; - this._propType = propType; - return this; - }; - Object.defineProperty(GTweener.prototype, "target", { - get: function () { - return this._target; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setUserData = function (value) { - this._userData = value; - return this; - }; - Object.defineProperty(GTweener.prototype, "userData", { - get: function () { - return this._userData; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setPath = function (value) { - this._path = value; - return this; - }; - GTweener.prototype.onUpdate = function (callback, caller) { - this._onUpdate = callback; - this._onUpdateCaller = caller; - return this; - }; - GTweener.prototype.onStart = function (callback, caller) { - this._onStart = callback; - this._onStartCaller = caller; - return this; - }; - GTweener.prototype.onComplete = function (callback, caller) { - this._onComplete = callback; - this._onCompleteCaller = caller; - return this; - }; - Object.defineProperty(GTweener.prototype, "startValue", { - get: function () { - return this._startValue; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "endValue", { - get: function () { - return this._endValue; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "value", { - get: function () { - return this._value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "deltaValue", { - get: function () { - return this._deltaValue; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "normalizedTime", { - get: function () { - return this._normalizedTime; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "completed", { - get: function () { - return this._ended != 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GTweener.prototype, "allCompleted", { - get: function () { - return this._ended == 1; - }, - enumerable: true, - configurable: true - }); - GTweener.prototype.setPaused = function (paused) { - this._paused = paused; - return this; - }; - GTweener.prototype.seek = function (time) { - if (this._killed) - return; - this._elapsedTime = time; - if (this._elapsedTime < this._delay) { - if (this._started) - this._elapsedTime = this._delay; - else - return; - } - this.update(); - }; - GTweener.prototype.kill = function (complete) { - if (this._killed) - return; - if (complete) { - if (this._ended == 0) { - if (this._breakpoint >= 0) - this._elapsedTime = this._delay + this._breakpoint; - else if (this._repeat >= 0) - this._elapsedTime = this._delay + this._duration * (this._repeat + 1); - else - this._elapsedTime = this._delay + this._duration * 2; - this.update(); - } - this.callCompleteCallback(); - } - this._killed = true; - }; - GTweener.prototype._to = function (start, end, duration) { - this._valueSize = 1; - this._startValue.x = start; - this._endValue.x = end; - this._value.x = start; - this._duration = duration; - return this; - }; - GTweener.prototype._to2 = function (start, start2, end, end2, duration) { - this._valueSize = 2; - this._startValue.x = start; - this._endValue.x = end; - this._startValue.y = start2; - this._endValue.y = end2; - this._value.x = start; - this._value.y = start2; - this._duration = duration; - return this; - }; - GTweener.prototype._to3 = function (start, start2, start3, end, end2, end3, duration) { - this._valueSize = 3; - this._startValue.x = start; - this._endValue.x = end; - this._startValue.y = start2; - this._endValue.y = end2; - this._startValue.z = start3; - this._endValue.z = end3; - this._value.x = start; - this._value.y = start2; - this._value.z = start3; - this._duration = duration; - return this; - }; - GTweener.prototype._to4 = function (start, start2, start3, start4, end, end2, end3, end4, duration) { - this._valueSize = 4; - this._startValue.x = start; - this._endValue.x = end; - this._startValue.y = start2; - this._endValue.y = end2; - this._startValue.z = start3; - this._endValue.z = end3; - this._startValue.w = start4; - this._endValue.w = end4; - this._value.x = start; - this._value.y = start2; - this._value.z = start3; - this._value.w = start4; - this._duration = duration; - return this; - }; - GTweener.prototype._toColor = function (start, end, duration) { - this._valueSize = 4; - this._startValue.color = start; - this._endValue.color = end; - this._value.color = start; - this._duration = duration; - return this; - }; - GTweener.prototype._shake = function (startX, startY, amplitude, duration) { - this._valueSize = 5; - this._startValue.x = startX; - this._startValue.y = startY; - this._startValue.w = amplitude; - this._duration = duration; - return this; - }; - GTweener.prototype._init = function () { - this._delay = 0; - this._duration = 0; - this._breakpoint = -1; - this._easeType = fgui.EaseType.QuadOut; - this._timeScale = 1; - this._easePeriod = 0; - this._easeOvershootOrAmplitude = 1.70158; - this._snapping = false; - this._repeat = 0; - this._yoyo = false; - this._valueSize = 0; - this._started = false; - this._paused = false; - this._killed = false; - this._elapsedTime = 0; - this._normalizedTime = 0; - this._ended = 0; - }; - GTweener.prototype._reset = function () { - this._target = null; - this._propType = null; - this._userData = null; - this._path = null; - this._onStart = this._onUpdate = this._onComplete = null; - this._onStartCaller = this._onUpdateCaller = this._onCompleteCaller = null; - }; - GTweener.prototype._update = function (dt) { - if (this._timeScale != 1) - dt *= this._timeScale; - if (dt == 0) - return; - if (this._ended != 0) { - this.callCompleteCallback(); - this._killed = true; - return; - } - this._elapsedTime += dt; - this.update(); - if (this._ended != 0) { - if (!this._killed) { - this.callCompleteCallback(); - this._killed = true; - } - } - }; - GTweener.prototype.update = function () { - this._ended = 0; - if (this._valueSize == 0) { - if (this._elapsedTime >= this._delay + this._duration) - this._ended = 1; - return; - } - if (!this._started) { - if (this._elapsedTime < this._delay) - return; - this._started = true; - this.callStartCallback(); - if (this._killed) - return; - } - var reversed = false; - var tt = this._elapsedTime - this._delay; - if (this._breakpoint >= 0 && tt >= this._breakpoint) { - tt = this._breakpoint; - this._ended = 2; - } - if (this._repeat != 0) { - var round = Math.floor(tt / this._duration); - tt -= this._duration * round; - if (this._yoyo) - reversed = round % 2 == 1; - if (this._repeat > 0 && this._repeat - round < 0) { - if (this._yoyo) - reversed = this._repeat % 2 == 1; - tt = this._duration; - this._ended = 1; - } - } - else if (tt >= this._duration) { - tt = this._duration; - this._ended = 1; - } - this._normalizedTime = fgui.evaluateEase(this._easeType, reversed ? (this._duration - tt) : tt, this._duration, this._easeOvershootOrAmplitude, this._easePeriod); - this._value.setZero(); - this._deltaValue.setZero(); - if (this._valueSize == 5) { - if (this._ended == 0) { - var r = this._startValue.w * (1 - this._normalizedTime); - var rx = r * (Math.random() > 0.5 ? 1 : -1); - var ry = r * (Math.random() > 0.5 ? 1 : -1); - this._deltaValue.x = rx; - this._deltaValue.y = ry; - this._value.x = this._startValue.x + rx; - this._value.y = this._startValue.y + ry; - } - else { - this._value.x = this._startValue.x; - this._value.y = this._startValue.y; - } - } - else if (this._path) { - var pt = s_vec2; - this._path.getPointAt(this._normalizedTime, pt); - if (this._snapping) { - pt.x = Math.round(pt.x); - pt.y = Math.round(pt.y); - } - this._deltaValue.x = pt.x - this._value.x; - this._deltaValue.y = pt.y - this._value.y; - this._value.x = pt.x; - this._value.y = pt.y; - } - else { - for (var i = 0; i < this._valueSize; i++) { - var n1 = this._startValue.getField(i); - var n2 = this._endValue.getField(i); - var f = n1 + (n2 - n1) * this._normalizedTime; - if (this._snapping) - f = Math.round(f); - this._deltaValue.setField(i, f - this._value.getField(i)); - this._value.setField(i, f); - } - } - if (this._target != null && this._propType != null) { - if (this._propType instanceof Function) { - switch (this._valueSize) { - case 1: - this._propType.call(this._target, this._value.x); - break; - case 2: - this._propType.call(this._target, this._value.x, this._value.y); - break; - case 3: - this._propType.call(this._target, this._value.x, this._value.y, this._value.z); - break; - case 4: - this._propType.call(this._target, this._value.x, this._value.y, this._value.z, this._value.w); - break; - case 5: - this._propType.call(this._target, this._value.color); - break; - case 6: - this._propType.call(this._target, this._value.x, this._value.y); - break; - } - } - else { - if (this._valueSize == 5) - this._target[this._propType] = this._value.color; - else - this._target[this._propType] = this._value.x; - } - } - this.callUpdateCallback(); - }; - GTweener.prototype.callStartCallback = function () { - if (this._onStart != null) { - try { - this._onStart.call(this._onStartCaller, this); - } - catch (err) { - console.log("FairyGUI: error in start callback > " + err); - } - } - }; - GTweener.prototype.callUpdateCallback = function () { - if (this._onUpdate != null) { - try { - this._onUpdate.call(this._onUpdateCaller, this); - } - catch (err) { - console.log("FairyGUI: error in update callback > " + err); - } - } - }; - GTweener.prototype.callCompleteCallback = function () { - if (this._onComplete != null) { - try { - this._onComplete.call(this._onCompleteCaller, this); - } - catch (err) { - console.log("FairyGUI: error in complete callback > " + err); - } - } - }; - return GTweener; - }()); - fgui.GTweener = GTweener; - var s_vec2 = new egret.Point(); -})(fgui || (fgui = {})); - -(function (fgui) { - var TweenManager = (function () { - function TweenManager() { - } - TweenManager.createTween = function () { - if (!_inited) { - egret.startTick(TweenManager.update, null); - _inited = true; - _lastTime = egret.getTimer(); - } - var tweener; - var cnt = _tweenerPool.length; - if (cnt > 0) { - tweener = _tweenerPool.pop(); - } - else - tweener = new fgui.GTweener(); - tweener._init(); - _activeTweens[_totalActiveTweens++] = tweener; - if (_totalActiveTweens == _activeTweens.length) - _activeTweens.length = _activeTweens.length + Math.ceil(_activeTweens.length * 0.5); - return tweener; - }; - TweenManager.isTweening = function (target, propType) { - if (target == null) - return false; - var anyType = propType == null; - for (var i = 0; i < _totalActiveTweens; i++) { - var tweener = _activeTweens[i]; - if (tweener != null && tweener.target == target && !tweener._killed - && (anyType || tweener._propType == propType)) - return true; - } - return false; - }; - TweenManager.killTweens = function (target, completed, propType) { - if (target == null) - return false; - var flag = false; - var cnt = _totalActiveTweens; - var anyType = propType == null; - for (var i = 0; i < cnt; i++) { - var tweener = _activeTweens[i]; - if (tweener != null && tweener.target == target && !tweener._killed - && (anyType || tweener._propType == propType)) { - tweener.kill(completed); - flag = true; - } - } - return flag; - }; - TweenManager.getTween = function (target, propType) { - if (target == null) - return null; - var cnt = _totalActiveTweens; - var anyType = propType == null; - for (var i = 0; i < cnt; i++) { - var tweener = _activeTweens[i]; - if (tweener != null && tweener.target == target && !tweener._killed - && (anyType || tweener._propType == propType)) { - return tweener; - } - } - return null; - }; - TweenManager.update = function (timestamp) { - var dt = timestamp - _lastTime; - _lastTime = timestamp; - dt /= 1000; - var cnt = _totalActiveTweens; - var freePosStart = -1; - var freePosCount = 0; - for (var i = 0; i < cnt; i++) { - var tweener = _activeTweens[i]; - if (tweener == null) { - if (freePosStart == -1) - freePosStart = i; - freePosCount++; - } - else if (tweener._killed) { - tweener._reset(); - _tweenerPool.push(tweener); - _activeTweens[i] = null; - if (freePosStart == -1) - freePosStart = i; - freePosCount++; - } - else { - if ((tweener._target instanceof fgui.GObject) && (tweener._target).isDisposed) - tweener._killed = true; - else if (!tweener._paused) - tweener._update(dt); - if (freePosStart != -1) { - _activeTweens[freePosStart] = tweener; - _activeTweens[i] = null; - freePosStart++; - } - } - } - if (freePosStart >= 0) { - if (_totalActiveTweens != cnt) { - var j = cnt; - cnt = _totalActiveTweens - cnt; - for (i = 0; i < cnt; i++) - _activeTweens[freePosStart++] = _activeTweens[j++]; - } - _totalActiveTweens = freePosStart; - } - return false; - }; - return TweenManager; - }()); - fgui.TweenManager = TweenManager; - var _activeTweens = new Array(30); - var _tweenerPool = new Array(); - var _totalActiveTweens = 0; - var _lastTime = 0; - var _inited; -})(fgui || (fgui = {})); - -(function (fgui) { - var TweenValue = (function () { - function TweenValue() { - this.x = this.y = this.z = this.w = 0; - } - Object.defineProperty(TweenValue.prototype, "color", { - get: function () { - return (this.w << 24) + (this.x << 16) + (this.y << 8) + this.z; - }, - set: function (value) { - this.x = (value & 0xFF0000) >> 16; - this.y = (value & 0x00FF00) >> 8; - this.z = (value & 0x0000FF); - this.w = (value & 0xFF000000) >> 24; - }, - enumerable: true, - configurable: true - }); - TweenValue.prototype.getField = function (index) { - switch (index) { - case 0: - return this.x; - case 1: - return this.y; - case 2: - return this.z; - case 3: - return this.w; - default: - throw new Error("Index out of bounds: " + index); - } - }; - TweenValue.prototype.setField = function (index, value) { - switch (index) { - case 0: - this.x = value; - break; - case 1: - this.y = value; - break; - case 2: - this.z = value; - break; - case 3: - this.w = value; - break; - default: - throw new Error("Index out of bounds: " + index); - } - }; - TweenValue.prototype.setZero = function () { - this.x = this.y = this.z = this.w = 0; - }; - return TweenValue; - }()); - fgui.TweenValue = TweenValue; -})(fgui || (fgui = {})); - -(function (fgui) { - var ByteBuffer = (function (_super_1) { - __extends(ByteBuffer, _super_1); - function ByteBuffer(buffer, bufferExtSize) { - var _this = _super_1.call(this, buffer, bufferExtSize) || this; - _this.version = 0; - return _this; - } - ByteBuffer.prototype.skip = function (count) { - this.position += count; - }; - ByteBuffer.prototype.readBool = function () { - return this.readByte() == 1; - }; - ByteBuffer.prototype.readS = function () { - var index = this.readUnsignedShort(); - if (index == 65534) - return null; - else if (index == 65533) - return ""; - else - return this.stringTable[index]; - }; - ByteBuffer.prototype.readSArray = function (cnt) { - var ret = new Array(cnt); - for (var i = 0; i < cnt; i++) - ret[i] = this.readS(); - return ret; - }; - ByteBuffer.prototype.writeS = function (value) { - var index = this.readUnsignedShort(); - if (index != 65534 && index != 65533) - this.stringTable[index] = value; - }; - ByteBuffer.prototype.readColor = function (hasAlpha) { - var r = this.readUnsignedByte(); - var g = this.readUnsignedByte(); - var b = this.readUnsignedByte(); - var a = this.readUnsignedByte(); - return (hasAlpha ? (a << 24) : 0) + (r << 16) + (g << 8) + b; - }; - ByteBuffer.prototype.readChar = function () { - var i = this.readUnsignedShort(); - return String.fromCharCode(i); - }; - ByteBuffer.prototype.readBuffer = function () { - var count = this.readUnsignedInt(); - var ba = new ByteBuffer(new Uint8Array(this.buffer, this.position, count)); - ba.stringTable = this.stringTable; - ba.version = this.version; - this.position += count; - return ba; - }; - ByteBuffer.prototype.seek = function (indexTablePos, blockIndex) { - var tmp = this.position; - this.position = indexTablePos; - var segCount = this.readByte(); - if (blockIndex < segCount) { - var useShort = this.readByte() == 1; - var newPos; - if (useShort) { - this.position += 2 * blockIndex; - newPos = this.readUnsignedShort(); - } - else { - this.position += 4 * blockIndex; - newPos = this.readUnsignedInt(); - } - if (newPos > 0) { - this.position = indexTablePos + newPos; - return true; - } - else { - this.position = tmp; - return false; - } - } - else { - this.position = tmp; - return false; - } - }; - return ByteBuffer; - }(egret.ByteArray)); - fgui.ByteBuffer = ByteBuffer; -})(fgui || (fgui = {})); - -(function (fgui) { - var ColorMatrix = (function () { - function ColorMatrix(p_brightness, p_contrast, p_saturation, p_hue) { - this.matrix = new Array(LENGTH); - this.reset(); - if (p_brightness !== undefined || p_contrast !== undefined || p_saturation !== undefined || p_hue !== undefined) - this.adjustColor(p_brightness, p_contrast, p_saturation, p_hue); - } - ColorMatrix.prototype.reset = function () { - for (var i = 0; i < LENGTH; i++) { - this.matrix[i] = IDENTITY_MATRIX[i]; - } - }; - ColorMatrix.prototype.invert = function () { - this.multiplyMatrix([-1, 0, 0, 0, 255, - 0, -1, 0, 0, 255, - 0, 0, -1, 0, 255, - 0, 0, 0, 1, 0]); - }; - ColorMatrix.prototype.adjustColor = function (p_brightness, p_contrast, p_saturation, p_hue) { - this.adjustHue(p_hue || 0); - this.adjustContrast(p_contrast || 0); - this.adjustBrightness(p_brightness || 0); - this.adjustSaturation(p_saturation || 0); - }; - ColorMatrix.prototype.adjustBrightness = function (p_val) { - p_val = this.cleanValue(p_val, 1) * 255; - this.multiplyMatrix([ - 1, 0, 0, 0, p_val, - 0, 1, 0, 0, p_val, - 0, 0, 1, 0, p_val, - 0, 0, 0, 1, 0 - ]); - }; - ColorMatrix.prototype.adjustContrast = function (p_val) { - p_val = this.cleanValue(p_val, 1); - var s = p_val + 1; - var o = 128 * (1 - s); - this.multiplyMatrix([ - s, 0, 0, 0, o, - 0, s, 0, 0, o, - 0, 0, s, 0, o, - 0, 0, 0, 1, 0 - ]); - }; - ColorMatrix.prototype.adjustSaturation = function (p_val) { - p_val = this.cleanValue(p_val, 1); - p_val += 1; - var invSat = 1 - p_val; - var invLumR = invSat * LUMA_R; - var invLumG = invSat * LUMA_G; - var invLumB = invSat * LUMA_B; - this.multiplyMatrix([ - (invLumR + p_val), invLumG, invLumB, 0, 0, - invLumR, (invLumG + p_val), invLumB, 0, 0, - invLumR, invLumG, (invLumB + p_val), 0, 0, - 0, 0, 0, 1, 0 - ]); - }; - ColorMatrix.prototype.adjustHue = function (p_val) { - p_val = this.cleanValue(p_val, 1); - p_val *= Math.PI; - var cos = Math.cos(p_val); - var sin = Math.sin(p_val); - this.multiplyMatrix([ - ((LUMA_R + (cos * (1 - LUMA_R))) + (sin * -(LUMA_R))), ((LUMA_G + (cos * -(LUMA_G))) + (sin * -(LUMA_G))), ((LUMA_B + (cos * -(LUMA_B))) + (sin * (1 - LUMA_B))), 0, 0, - ((LUMA_R + (cos * -(LUMA_R))) + (sin * 0.143)), ((LUMA_G + (cos * (1 - LUMA_G))) + (sin * 0.14)), ((LUMA_B + (cos * -(LUMA_B))) + (sin * -0.283)), 0, 0, - ((LUMA_R + (cos * -(LUMA_R))) + (sin * -((1 - LUMA_R)))), ((LUMA_G + (cos * -(LUMA_G))) + (sin * LUMA_G)), ((LUMA_B + (cos * (1 - LUMA_B))) + (sin * LUMA_B)), 0, 0, - 0, 0, 0, 1, 0 - ]); - }; - ColorMatrix.prototype.concat = function (p_matrix) { - if (p_matrix.length != LENGTH) { - return; - } - this.multiplyMatrix(p_matrix); - }; - ColorMatrix.prototype.clone = function () { - var result = new ColorMatrix(); - result.copyMatrix(this.matrix); - return result; - }; - ColorMatrix.prototype.copyMatrix = function (p_matrix) { - var l = LENGTH; - for (var i = 0; i < l; i++) { - this.matrix[i] = p_matrix[i]; - } - }; - ColorMatrix.prototype.multiplyMatrix = function (p_matrix) { - var col = []; - var i = 0; - for (var y = 0; y < 4; ++y) { - for (var x = 0; x < 5; ++x) { - col[i + x] = p_matrix[i] * this.matrix[x] + - p_matrix[i + 1] * this.matrix[x + 5] + - p_matrix[i + 2] * this.matrix[x + 10] + - p_matrix[i + 3] * this.matrix[x + 15] + - (x == 4 ? p_matrix[i + 4] : 0); - } - i += 5; - } - this.copyMatrix(col); - }; - ColorMatrix.prototype.cleanValue = function (p_val, p_limit) { - return Math.min(p_limit, Math.max(-p_limit, p_val)); - }; - return ColorMatrix; - }()); - fgui.ColorMatrix = ColorMatrix; - var IDENTITY_MATRIX = [ - 1, 0, 0, 0, 0, - 0, 1, 0, 0, 0, - 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0 - ]; - var LENGTH = IDENTITY_MATRIX.length; - var LUMA_R = 0.299; - var LUMA_G = 0.587; - var LUMA_B = 0.114; -})(fgui || (fgui = {})); - -(function (fgui) { - var GTimers = (function () { - function GTimers() { - this._enumI = 0; - this._enumCount = 0; - this._lastTime = 0; - this._items = new Array(); - this._itemPool = new Array(); - this._lastTime = egret.getTimer(); - GTimers.time = this._lastTime; - egret.startTick(this.__timer, this); - } - GTimers.prototype.getItem = function () { - if (this._itemPool.length) - return this._itemPool.pop(); - else - return new TimerItem(); - }; - GTimers.prototype.findItem = function (callback, thisObj) { - var len = this._items.length; - for (var i = 0; i < len; i++) { - var item = this._items[i]; - if (item.callback == callback && item.thisObj == thisObj) - return item; - } - return null; - }; - GTimers.prototype.add = function (delayInMiniseconds, repeat, callback, thisObj, callbackParam) { - var item = this.findItem(callback, thisObj); - if (!item) { - item = this.getItem(); - item.callback = callback; - item.hasParam = callback.length == 1; - item.thisObj = thisObj; - this._items.push(item); - } - item.delay = delayInMiniseconds; - item.counter = 0; - item.repeat = repeat; - item.param = callbackParam; - item.end = false; - }; - GTimers.prototype.callLater = function (callback, thisObj, callbackParam) { - this.add(1, 1, callback, thisObj, callbackParam); - }; - GTimers.prototype.callDelay = function (delay, callback, thisObj, callbackParam) { - this.add(delay, 1, callback, thisObj, callbackParam); - }; - GTimers.prototype.exists = function (callback, thisObj) { - var item = this.findItem(callback, thisObj); - return item != null; - }; - GTimers.prototype.remove = function (callback, thisObj) { - var item = this.findItem(callback, thisObj); - if (item) { - var i = this._items.indexOf(item); - this._items.splice(i, 1); - if (i < this._enumI) - this._enumI--; - this._enumCount--; - item.reset(); - this._itemPool.push(item); - } - }; - GTimers.prototype.__timer = function (timeStamp) { - GTimers.time = timeStamp; - GTimers.deltaTime = timeStamp - this._lastTime; - this._lastTime = timeStamp; - this._enumI = 0; - this._enumCount = this._items.length; - while (this._enumI < this._enumCount) { - var item = this._items[this._enumI]; - this._enumI++; - if (item.advance(GTimers.deltaTime)) { - if (item.end) { - this._enumI--; - this._enumCount--; - this._items.splice(this._enumI, 1); - } - if (item.hasParam) - item.callback.call(item.thisObj, item.param); - else - item.callback.call(item.thisObj); - if (item.end) { - item.reset(); - this._itemPool.push(item); - } - } - } - return false; - }; - GTimers.deltaTime = 0; - GTimers.time = 0; - GTimers.inst = new GTimers(); - return GTimers; - }()); - fgui.GTimers = GTimers; - var TimerItem = (function () { - function TimerItem() { - this.delay = 0; - this.counter = 0; - this.repeat = 0; - } - TimerItem.prototype.advance = function (elapsed) { - this.counter += elapsed; - if (this.counter >= this.delay) { - this.counter -= this.delay; - if (this.counter > this.delay) - this.counter = this.delay; - if (this.repeat > 0) { - this.repeat--; - if (this.repeat == 0) - this.end = true; - } - return true; - } - else - return false; - }; - TimerItem.prototype.reset = function () { - this.callback = null; - this.thisObj = null; - this.param = null; - }; - return TimerItem; - }()); -})(fgui || (fgui = {})); - -(function (fgui) { - var UBBParser = (function () { - function UBBParser() { - this._readPos = 0; - this.smallFontSize = 12; - this.normalFontSize = 14; - this.largeFontSize = 16; - this.defaultImgWidth = 0; - this.defaultImgHeight = 0; - this._handlers = {}; - this._handlers["url"] = this.onTag_URL; - this._handlers["img"] = this.onTag_IMG; - this._handlers["b"] = this.onTag_Simple; - this._handlers["i"] = this.onTag_Simple; - this._handlers["u"] = this.onTag_Simple; - this._handlers["sup"] = this.onTag_Simple; - this._handlers["sub"] = this.onTag_Simple; - this._handlers["color"] = this.onTag_COLOR; - this._handlers["font"] = this.onTag_FONT; - this._handlers["size"] = this.onTag_SIZE; - } - UBBParser.prototype.onTag_URL = function (tagName, end, attr) { - if (!end) { - if (attr != null) - return ""; - else { - var href = this.getTagText(); - return ""; - } - } - else - return ""; - }; - UBBParser.prototype.onTag_IMG = function (tagName, end, attr) { - if (!end) { - var src = this.getTagText(true); - if (!src) - return null; - if (this.defaultImgWidth) - return ""; - else - return ""; - } - else - return null; - }; - UBBParser.prototype.onTag_Simple = function (tagName, end, attr) { - return end ? ("") : ("<" + tagName + ">"); - }; - UBBParser.prototype.onTag_COLOR = function (tagName, end, attr) { - if (!end) - return ""; - else - return ""; - }; - UBBParser.prototype.onTag_FONT = function (tagName, end, attr) { - if (!end) - return ""; - else - return ""; - }; - UBBParser.prototype.onTag_SIZE = function (tagName, end, attr) { - if (!end) { - if (attr == "normal") - attr = "" + this.normalFontSize; - else if (attr == "small") - attr = "" + this.smallFontSize; - else if (attr == "large") - attr = "" + this.largeFontSize; - else if (attr.length && attr.charAt(0) == "+") - attr = "" + (this.smallFontSize + parseInt(attr.substr(1))); - else if (attr.length && attr.charAt(0) == "-") - attr = "" + (this.smallFontSize - parseInt(attr.substr(1))); - return ""; - } - else - return ""; - }; - UBBParser.prototype.getTagText = function (remove) { - if (remove === void 0) { remove = false; } - var pos1 = this._readPos; - var pos2; - var result = ""; - while ((pos2 = this._text.indexOf("[", pos1)) != -1) { - if (this._text.charCodeAt(pos2 - 1) == 92) { - result += this._text.substring(pos1, pos2 - 1); - result += "["; - pos1 = pos2 + 1; - } - else { - result += this._text.substring(pos1, pos2); - break; - } - } - if (pos2 == -1) - return null; - if (remove) - this._readPos = pos2; - return result; - }; - UBBParser.prototype.parse = function (text, remove) { - this._text = text; - var pos1 = 0, pos2, pos3; - var end; - var tag, attr; - var repl; - var func; - var result = ""; - while ((pos2 = this._text.indexOf("[", pos1)) != -1) { - if (pos2 > 0 && this._text.charCodeAt(pos2 - 1) == 92) { - result += this._text.substring(pos1, pos2 - 1); - result += "["; - pos1 = pos2 + 1; - continue; - } - result += this._text.substring(pos1, pos2); - pos1 = pos2; - pos2 = this._text.indexOf("]", pos1); - if (pos2 == -1) - break; - end = this._text.charAt(pos1 + 1) == '/'; - tag = this._text.substring(end ? pos1 + 2 : pos1 + 1, pos2); - this._readPos = pos2 + 1; - attr = null; - repl = null; - pos3 = tag.indexOf("="); - if (pos3 != -1) { - attr = tag.substring(pos3 + 1); - tag = tag.substring(0, pos3); - } - tag = tag.toLowerCase(); - func = this._handlers[tag]; - if (func != null) { - if (!remove) { - repl = func.call(this, tag, end, attr); - if (repl != null) - result += repl; - } - } - else - result += this._text.substring(pos1, this._readPos); - pos1 = this._readPos; - } - if (pos1 < this._text.length) - result += this._text.substr(pos1); - this._text = null; - return result; - }; - UBBParser.inst = new UBBParser(); - return UBBParser; - }()); - fgui.UBBParser = UBBParser; -})(fgui || (fgui = {})); - -(function (fgui) { - var ToolSet = (function () { - function ToolSet() { - } - ToolSet.startsWith = function (source, str, ignoreCase) { - if (!source) - return false; - else if (source.length < str.length) - return false; - else { - source = source.substring(0, str.length); - if (!ignoreCase) - return source == str; - else - return source.toLowerCase() == str.toLowerCase(); - } - }; - ToolSet.trimRight = function (targetString) { - var tempChar = ""; - for (var i = targetString.length - 1; i >= 0; i--) { - tempChar = targetString.charAt(i); - if (tempChar != " " && tempChar != "\n" && tempChar != "\r") { - break; - } - } - return targetString.substring(0, i + 1); - }; - ToolSet.convertToHtmlColor = function (argb, hasAlpha) { - var alpha; - if (hasAlpha) - alpha = (argb >> 24 & 0xFF).toString(16); - else - alpha = ""; - var red = (argb >> 16 & 0xFF).toString(16); - var green = (argb >> 8 & 0xFF).toString(16); - var blue = (argb & 0xFF).toString(16); - if (alpha.length == 1) - alpha = "0" + alpha; - if (red.length == 1) - red = "0" + red; - if (green.length == 1) - green = "0" + green; - if (blue.length == 1) - blue = "0" + blue; - return "#" + alpha + red + green + blue; - }; - ToolSet.convertFromHtmlColor = function (str, hasAlpha) { - if (str.length < 1) - return 0; - if (str.charAt(0) == "#") - str = str.substr(1); - if (str.length == 8) - return (parseInt(str.substr(0, 2), 16) << 24) + parseInt(str.substr(2), 16); - else if (hasAlpha) - return 0xFF000000 + parseInt(str, 16); - else - return parseInt(str, 16); - }; - ToolSet.displayObjectToGObject = function (obj) { - while (obj && !(obj instanceof egret.Stage)) { - if (obj["$owner"]) - return fgui.GObject.cast(obj); - obj = obj.parent; - } - return null; - }; - ToolSet.encodeHTML = function (str) { - if (!str) - return ""; - else - return str.replace(/&/g, "&").replace(//g, ">").replace(/'/g, "'").replace(/"/g, """); - }; - ToolSet.clamp = function (value, min, max) { - if (value < min) - value = min; - else if (value > max) - value = max; - return value; - }; - ToolSet.clamp01 = function (value) { - if (value > 1) - value = 1; - else if (value < 0) - value = 0; - return value; - }; - ToolSet.lerp = function (start, end, percent) { - return (start + percent * (end - start)); - }; - ToolSet.repeat = function (t, length) { - return t - Math.floor(t / length) * length; - }; - ToolSet.distance = function (x1, y1, x2, y2) { - return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)); - }; - ToolSet.fillPath = function (ctx, points, px, py) { - var cnt = points.length; - ctx.moveTo(points[0] + px, points[1] + py); - for (var i = 2; i < cnt; i += 2) - ctx.lineTo(points[i] + px, points[i + 1] + py); - ctx.lineTo(points[0] + px, points[1] + py); - }; - ToolSet.setColorFilter = function (obj, color) { - var filter = obj.$_colorFilter_; - var filters = obj.filters; - var toApplyColor; - var toApplyGray; - var tp = typeof (color); - if (tp == "boolean") { - toApplyColor = filter ? filter.$_color_ : null; - toApplyGray = color; - } - else { - toApplyColor = color == 0xFFFFFF ? null : color; - toApplyGray = filter ? filter.$_grayed_ : false; - } - if ((!toApplyColor && toApplyColor !== 0) && !toApplyGray) { - if (filters && filter) { - var i = filters.indexOf(filter); - if (i != -1) { - filters.splice(i, 1); - if (filters.length > 0) - obj.filters = filters; - else - obj.filters = null; - } - } - return; - } - if (!filter) { - filter = new egret.ColorMatrixFilter(); - obj.$_colorFilter_ = filter; - } - if (!filters) - filters = [filter]; - else { - var i_1 = filters.indexOf(filter); - if (i_1 == -1) - filters.push(filter); - } - obj.filters = filters; - filter.$_color_ = toApplyColor; - filter.$_grayed_ = toApplyGray; - var mat = filter.matrix; - if (toApplyGray) { - for (var i_2 = 0; i_2 < 20; i_2++) - mat[i_2] = grayScaleMatrix[i_2]; - } - else if (toApplyColor instanceof Array) { - getColorMatrix(toApplyColor[0], toApplyColor[1], toApplyColor[2], toApplyColor[3], mat); - } - else { - for (var i_3 = 0; i_3 < 20; i_3++) { - mat[i_3] = (i_3 == 0 || i_3 == 6 || i_3 == 12 || i_3 == 18) ? 1 : 0; - } - mat[0] = ((color >> 16) & 0xFF) / 255; - mat[6] = ((color >> 8) & 0xFF) / 255; - mat[12] = (color & 0xFF) / 255; - } - filter.matrix = mat; - }; - return ToolSet; - }()); - fgui.ToolSet = ToolSet; - var grayScaleMatrix = [ - 0.3, 0.6, 0, 0, 0, - 0.3, 0.6, 0, 0, 0, - 0.3, 0.6, 0, 0, 0, - 0, 0, 0, 1, 0 - ]; - var helper = new fgui.ColorMatrix(); - function getColorMatrix(p_brightness, p_contrast, p_saturation, p_hue, result) { - if (!result) - result = new Array(fgui.ColorMatrix.length); - helper.reset(); - helper.adjustColor(p_brightness, p_contrast, p_saturation, p_hue); - helper.matrix.forEach(function (e, i) { return result[i] = e; }); - } -})(fgui || (fgui = {})); diff --git a/demo/libs/fairygui/fairygui.min.js b/demo/libs/fairygui/fairygui.min.js deleted file mode 100644 index 180e2cf7..00000000 --- a/demo/libs/fairygui/fairygui.min.js +++ /dev/null @@ -1 +0,0 @@ -window.fgui={},window.fairygui=window.fgui,window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(o,r){function s(t){try{h(n.next(t))}catch(t){r(t)}}function a(t){try{h(n.throw(t))}catch(t){r(t)}}function h(t){t.done?o(t.value):new i(function(e){e(t.value)}).then(s,a)}h((n=n.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,n,o,r,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(o=2&r[0]?n.return:r[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,r[1])).done)return o;switch(n=0,o&&(r=[2&r[0],o.value]),r[0]){case 0:case 1:o=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,n=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===r[0]||2===r[0])){s=0;continue}if(3===r[0]&&(!o||r[1]>o[0]&&r[1]0){for(var i=0;i0){for(n=this._objectPool.length-i.listItemCount-1,o=0;o=s)return}t.GTimers.inst.remove(this.run,this);var h=this._objectPool[0];this._itemList.length=0,this._objectPool.length=0,null!=this.callback&&this.callback.call(this.callbackObj,h)},e}();t.AsyncOperation=e}(fgui||(fgui={})),function(t){var e=0,i=function(i){function n(){var t=i.call(this)||this;return t._pageIds=[],t._pageNames=[],t._selectedIndex=-1,t._previousIndex=-1,t}return __extends(n,i),n.prototype.dispose=function(){},Object.defineProperty(n.prototype,"selectedIndex",{get:function(){return this._selectedIndex},set:function(e){if(this._selectedIndex!=e){if(e>this._pageIds.length-1)throw"index out of bounds: "+e;this.changing=!0,this._previousIndex=this._selectedIndex,this._selectedIndex=e,this.parent.applyController(this),this.dispatchEvent(new t.StateChangeEvent(t.StateChangeEvent.CHANGED)),this.changing=!1}},enumerable:!0,configurable:!0}),n.prototype.setSelectedIndex=function(t){if(this._selectedIndex!=t){if(t>this._pageIds.length-1)throw"index out of bounds: "+t;this.changing=!0,this._previousIndex=this._selectedIndex,this._selectedIndex=t,this.parent.applyController(this),this.changing=!1}},Object.defineProperty(n.prototype,"previsousIndex",{get:function(){return this._previousIndex},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectedPage",{get:function(){return-1==this._selectedIndex?null:this._pageNames[this._selectedIndex]},set:function(t){var e=this._pageNames.indexOf(t);-1==e&&(e=0),this.selectedIndex=e},enumerable:!0,configurable:!0}),n.prototype.setSelectedPage=function(t){var e=this._pageNames.indexOf(t);-1==e&&(e=0),this.setSelectedIndex(e)},Object.defineProperty(n.prototype,"previousPage",{get:function(){return-1==this._previousIndex?null:this._pageNames[this._previousIndex]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"pageCount",{get:function(){return this._pageIds.length},enumerable:!0,configurable:!0}),n.prototype.getPageName=function(t){return this._pageNames[t]},n.prototype.addPage=function(t){this.addPageAt(t||"",this._pageIds.length)},n.prototype.addPageAt=function(t,i){var n=""+e++;i==this._pageIds.length?(this._pageIds.push(n),this._pageNames.push(t)):(this._pageIds.splice(i,0,n),this._pageNames.splice(i,0,t))},n.prototype.removePage=function(t){var e=this._pageNames.indexOf(t);-1!=e&&(this._pageIds.splice(e,1),this._pageNames.splice(e,1),this._selectedIndex>=this._pageIds.length?this.selectedIndex=this._selectedIndex-1:this.parent.applyController(this))},n.prototype.removePageAt=function(t){void 0===t&&(t=0),this._pageIds.splice(t,1),this._pageNames.splice(t,1),this._selectedIndex>=this._pageIds.length?this.selectedIndex=this._selectedIndex-1:this.parent.applyController(this)},n.prototype.clearPages=function(){this._pageIds.length=0,this._pageNames.length=0,-1!=this._selectedIndex?this.selectedIndex=-1:this.parent.applyController(this)},n.prototype.hasPage=function(t){return-1!=this._pageNames.indexOf(t)},n.prototype.getPageIndexById=function(t){return this._pageIds.indexOf(t)},n.prototype.getPageIdByName=function(t){var e=this._pageNames.indexOf(t);return-1!=e?this._pageIds[e]:null},n.prototype.getPageNameById=function(t){var e=this._pageIds.indexOf(t);return-1!=e?this._pageNames[e]:null},n.prototype.getPageId=function(t){return void 0===t&&(t=0),this._pageIds[t]},Object.defineProperty(n.prototype,"selectedPageId",{get:function(){return-1==this._selectedIndex?null:this._pageIds[this._selectedIndex]},set:function(t){var e=this._pageIds.indexOf(t);this.selectedIndex=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"oppositePageId",{set:function(t){this._pageIds.indexOf(t)>0?this.selectedIndex=0:this._pageIds.length>1&&(this.selectedIndex=1)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"previousPageId",{get:function(){return-1==this._previousIndex?null:this._pageIds[this._previousIndex]},enumerable:!0,configurable:!0}),n.prototype.runActions=function(){if(this._actions)for(var t=this._actions.length,e=0;e=2)switch(e.readByte()){case 1:s=e.readShort();break;case 2:-1==(s=this._pageNames.indexOf(t.UIPackage.branch))&&(s=0);break;case 3:-1==(s=this._pageNames.indexOf(t.UIPackage.getVar(e.readS())))&&(s=0)}if(e.seek(o,2),(r=e.readShort())>0)for(this._actions||(this._actions=new Array),i=0;i0?this._selectedIndex=s:this._selectedIndex=-1},n}(egret.EventDispatcher);t.Controller=i}(fgui||(fgui={})),function(t){var e=function(){function e(){this._agent=new t.GLoader,this._agent.draggable=!0,this._agent.touchable=!1,this._agent.setSize(100,100),this._agent.setPivot(.5,.5,!0),this._agent.align=t.AlignType.Center,this._agent.verticalAlign=t.VertAlignType.Middle,this._agent.sortingOrder=1e6,this._agent.addEventListener(t.DragEvent.DRAG_END,this.__dragEnd,this)}return Object.defineProperty(e,"inst",{get:function(){return null==e._inst&&(e._inst=new e),e._inst},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dragAgent",{get:function(){return this._agent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dragging",{get:function(){return null!=this._agent.parent},enumerable:!0,configurable:!0}),e.prototype.startDrag=function(e,i,n,o){if(!this._agent.parent){this._sourceData=n,this._agent.url=i,t.GRoot.inst.addChild(this._agent);var r=t.GRoot.inst.globalToLocal(t.GRoot.mouseX,t.GRoot.mouseY);this._agent.setXY(r.x,r.y),this._agent.startDrag(o)}},e.prototype.cancel=function(){this._agent.parent&&(this._agent.stopDrag(),t.GRoot.inst.removeChild(this._agent),this._sourceData=null)},e.prototype.__dragEnd=function(e){if(null!=this._agent.parent){t.GRoot.inst.removeChild(this._agent);var i=this._sourceData;this._sourceData=null;for(var n=t.GRoot.inst.getObjectUnderPoint(e.stageX,e.stageY);n;){if(n.hasEventListener(t.DropEvent.DROP)){var o=new t.DropEvent(t.DropEvent.DROP,i);return n.requestFocus(),void n.dispatchEvent(o)}n=n.parent}}},e}();t.DragDropManager=e}(fgui||(fgui={})),function(t){!function(t){t[t.Common=0]="Common",t[t.Check=1]="Check",t[t.Radio=2]="Radio"}(t.ButtonMode||(t.ButtonMode={})),function(t){t[t.None=0]="None",t[t.Both=1]="Both",t[t.Height=2]="Height"}(t.AutoSizeType||(t.AutoSizeType={})),function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right"}(t.AlignType||(t.AlignType={})),function(t){t[t.Top=0]="Top",t[t.Middle=1]="Middle",t[t.Bottom=2]="Bottom"}(t.VertAlignType||(t.VertAlignType={})),function(t){t[t.None=0]="None",t[t.Scale=1]="Scale",t[t.ScaleMatchHeight=2]="ScaleMatchHeight",t[t.ScaleMatchWidth=3]="ScaleMatchWidth",t[t.ScaleFree=4]="ScaleFree",t[t.ScaleNoBorder=5]="ScaleNoBorder"}(t.LoaderFillType||(t.LoaderFillType={})),function(t){t[t.SingleColumn=0]="SingleColumn",t[t.SingleRow=1]="SingleRow",t[t.FlowHorizontal=2]="FlowHorizontal",t[t.FlowVertical=3]="FlowVertical",t[t.Pagination=4]="Pagination"}(t.ListLayoutType||(t.ListLayoutType={})),function(t){t[t.Single=0]="Single",t[t.Multiple=1]="Multiple",t[t.Multiple_SingleClick=2]="Multiple_SingleClick",t[t.None=3]="None"}(t.ListSelectionMode||(t.ListSelectionMode={})),function(t){t[t.Visible=0]="Visible",t[t.Hidden=1]="Hidden",t[t.Scroll=2]="Scroll"}(t.OverflowType||(t.OverflowType={})),function(t){t[t.Image=0]="Image",t[t.MovieClip=1]="MovieClip",t[t.Sound=2]="Sound",t[t.Component=3]="Component",t[t.Atlas=4]="Atlas",t[t.Font=5]="Font",t[t.Swf=6]="Swf",t[t.Misc=7]="Misc",t[t.Unknown=8]="Unknown",t[t.Spine=9]="Spine",t[t.DragonBones=10]="DragonBones"}(t.PackageItemType||(t.PackageItemType={})),function(t){t[t.Image=0]="Image",t[t.MovieClip=1]="MovieClip",t[t.Swf=2]="Swf",t[t.Graph=3]="Graph",t[t.Loader=4]="Loader",t[t.Group=5]="Group",t[t.Text=6]="Text",t[t.RichText=7]="RichText",t[t.InputText=8]="InputText",t[t.Component=9]="Component",t[t.List=10]="List",t[t.Label=11]="Label",t[t.Button=12]="Button",t[t.ComboBox=13]="ComboBox",t[t.ProgressBar=14]="ProgressBar",t[t.Slider=15]="Slider",t[t.ScrollBar=16]="ScrollBar",t[t.Tree=17]="Tree",t[t.Loader3D=18]="Loader3D"}(t.ObjectType||(t.ObjectType={})),function(t){t[t.Percent=0]="Percent",t[t.ValueAndMax=1]="ValueAndMax",t[t.Value=2]="Value",t[t.Max=3]="Max"}(t.ProgressTitleType||(t.ProgressTitleType={})),function(t){t[t.Default=0]="Default",t[t.Visible=1]="Visible",t[t.Auto=2]="Auto",t[t.Hidden=3]="Hidden"}(t.ScrollBarDisplayType||(t.ScrollBarDisplayType={})),function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical",t[t.Both=2]="Both"}(t.ScrollType||(t.ScrollType={})),function(t){t[t.None=0]="None",t[t.Horizontal=1]="Horizontal",t[t.Vertical=2]="Vertical",t[t.Both=3]="Both"}(t.FlipType||(t.FlipType={})),function(t){t[t.Ascent=0]="Ascent",t[t.Descent=1]="Descent",t[t.Arch=2]="Arch"}(t.ChildrenRenderOrder||(t.ChildrenRenderOrder={})),function(t){t[t.None=0]="None",t[t.Horizontal=1]="Horizontal",t[t.Vertical=2]="Vertical"}(t.GroupLayoutType||(t.GroupLayoutType={})),function(t){t[t.Auto=0]="Auto",t[t.Up=1]="Up",t[t.Down=2]="Down"}(t.PopupDirection||(t.PopupDirection={})),function(t){t[t.Left_Left=0]="Left_Left",t[t.Left_Center=1]="Left_Center",t[t.Left_Right=2]="Left_Right",t[t.Center_Center=3]="Center_Center",t[t.Right_Left=4]="Right_Left",t[t.Right_Center=5]="Right_Center",t[t.Right_Right=6]="Right_Right",t[t.Top_Top=7]="Top_Top",t[t.Top_Middle=8]="Top_Middle",t[t.Top_Bottom=9]="Top_Bottom",t[t.Middle_Middle=10]="Middle_Middle",t[t.Bottom_Top=11]="Bottom_Top",t[t.Bottom_Middle=12]="Bottom_Middle",t[t.Bottom_Bottom=13]="Bottom_Bottom",t[t.Width=14]="Width",t[t.Height=15]="Height",t[t.LeftExt_Left=16]="LeftExt_Left",t[t.LeftExt_Right=17]="LeftExt_Right",t[t.RightExt_Left=18]="RightExt_Left",t[t.RightExt_Right=19]="RightExt_Right",t[t.TopExt_Top=20]="TopExt_Top",t[t.TopExt_Bottom=21]="TopExt_Bottom",t[t.BottomExt_Top=22]="BottomExt_Top",t[t.BottomExt_Bottom=23]="BottomExt_Bottom",t[t.Size=24]="Size"}(t.RelationType||(t.RelationType={})),function(t){t[t.None=0]="None",t[t.Horizontal=1]="Horizontal",t[t.Vertical=2]="Vertical",t[t.Radial90=3]="Radial90",t[t.Radial180=4]="Radial180",t[t.Radial360=5]="Radial360"}(t.FillMethod||(t.FillMethod={})),function(t){t[t.Top=0]="Top",t[t.Bottom=1]="Bottom",t[t.Left=2]="Left",t[t.Right=3]="Right",t[t.TopLeft=0]="TopLeft",t[t.TopRight=1]="TopRight",t[t.BottomLeft=2]="BottomLeft",t[t.BottomRight=3]="BottomRight"}(t.FillOrigin||(t.FillOrigin={})),function(t){t[t.TopLeft=0]="TopLeft",t[t.TopRight=1]="TopRight",t[t.BottomLeft=2]="BottomLeft",t[t.BottomRight=3]="BottomRight"}(t.FillOrigin90||(t.FillOrigin90={})),function(t){t[t.Text=0]="Text",t[t.Icon=1]="Icon",t[t.Color=2]="Color",t[t.OutlineColor=3]="OutlineColor",t[t.Playing=4]="Playing",t[t.Frame=5]="Frame",t[t.DeltaTime=6]="DeltaTime",t[t.TimeScale=7]="TimeScale",t[t.FontSize=8]="FontSize",t[t.Selected=9]="Selected"}(t.ObjectPropID||(t.ObjectPropID={}))}(fgui||(fgui={})),function(t){var e=function(e){function h(){var i=e.call(this)||this;return i._x=0,i._y=0,i._alpha=1,i._rotation=0,i._visible=!0,i._touchable=!0,i._scaleX=1,i._scaleY=1,i._skewX=0,i._skewY=0,i._pivotX=0,i._pivotY=0,i._pivotOffsetX=0,i._pivotOffsetY=0,i._sortingOrder=0,i._internalVisible=!0,i._disposed=!1,i.sourceWidth=0,i.sourceHeight=0,i.initWidth=0,i.initHeight=0,i.minWidth=0,i.minHeight=0,i.maxWidth=0,i.maxHeight=0,i._width=0,i._height=0,i._rawWidth=0,i._rawHeight=0,i._sizePercentInGroup=0,i._id=""+n++,i._name="",i.createDisplayObject(),i._relations=new t.Relations(i),i._gears=new Array(10),i}return __extends(h,e),Object.defineProperty(h.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"name",{get:function(){return this._name},set:function(t){this._name=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"x",{get:function(){return this._x},set:function(t){this.setXY(t,this._y)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"y",{get:function(){return this._y},set:function(t){this.setXY(this._x,t)},enumerable:!0,configurable:!0}),h.prototype.setXY=function(e,n){if(this._x!=e||this._y!=n){var o=e-this._x,s=n-this._y;this._x=e,this._y=n,this.handleXYChanged(),this instanceof t.GGroup&&this.moveChildren(o,s),this.updateGear(1),!this._parent||this._parent instanceof t.GList||(this._parent.setBoundsChangedFlag(),this._group&&this._group.setBoundsChangedFlag(!0),this.dispatchEventWith(h.XY_CHANGED)),h.draggingObject!=this||i||this.localToGlobalRect(0,0,this._width,this._height,r)}},Object.defineProperty(h.prototype,"xMin",{get:function(){return this._pivotAsAnchor?this._x-this._width*this._pivotX:this._x},set:function(t){this._pivotAsAnchor?this.setXY(t+this._width*this._pivotX,this._y):this.setXY(t,this._y)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"yMin",{get:function(){return this._pivotAsAnchor?this._y-this._height*this._pivotY:this._y},set:function(t){this._pivotAsAnchor?this.setXY(this._x,t+this._height*this._pivotY):this.setXY(this._x,t)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"pixelSnapping",{get:function(){return this._pixelSnapping},set:function(t){this._pixelSnapping!=t&&(this._pixelSnapping=t,this.handleXYChanged())},enumerable:!0,configurable:!0}),h.prototype.center=function(e){var i;i=this._parent?this.parent:this.root,this.setXY((i.width-this._width)/2,(i.height-this._height)/2),e&&(this.addRelation(i,t.RelationType.Center_Center),this.addRelation(i,t.RelationType.Middle_Middle))},Object.defineProperty(h.prototype,"width",{get:function(){return this.ensureSizeCorrect(),this._relations.sizeDirty&&this._relations.ensureRelationsSizeCorrect(),this._width},set:function(t){this.setSize(t,this._rawHeight)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"height",{get:function(){return this.ensureSizeCorrect(),this._relations.sizeDirty&&this._relations.ensureRelationsSizeCorrect(),this._height},set:function(t){this.setSize(this._rawWidth,t)},enumerable:!0,configurable:!0}),h.prototype.setSize=function(e,i,n){if(this._rawWidth!=e||this._rawHeight!=i){this._rawWidth=e,this._rawHeight=i,e0&&e>this.maxWidth&&(e=this.maxWidth),this.maxHeight>0&&i>this.maxHeight&&(i=this.maxHeight);var o=e-this._width,r=i-this._height;this._width=e,this._height=i,this.handleSizeChanged(),0==this._pivotX&&0==this._pivotY||(this._pivotAsAnchor?this.applyPivot():(n||this.setXY(this.x-this._pivotX*o,this.y-this._pivotY*r),this.updatePivotOffset())),this instanceof t.GGroup&&this.resizeChildren(o,r),this.updateGear(2),this._parent&&(this._relations.onOwnerSizeChanged(o,r,this._pivotAsAnchor||!n),this._parent.setBoundsChangedFlag(),this._group&&this._group.setBoundsChangedFlag()),this.dispatchEventWith(h.SIZE_CHANGED)}},h.prototype.makeFullScreen=function(){this.setSize(t.GRoot.inst.width,t.GRoot.inst.height)},h.prototype.ensureSizeCorrect=function(){},Object.defineProperty(h.prototype,"actualWidth",{get:function(){return this.width*Math.abs(this._scaleX)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"actualHeight",{get:function(){return this.height*Math.abs(this._scaleY)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"scaleX",{get:function(){return this._scaleX},set:function(t){this.setScale(t,this._scaleY)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"scaleY",{get:function(){return this._scaleY},set:function(t){this.setScale(this._scaleX,t)},enumerable:!0,configurable:!0}),h.prototype.setScale=function(t,e){this._scaleX==t&&this._scaleY==e||(this._scaleX=t,this._scaleY=e,this.handleScaleChanged(),this.applyPivot(),this.updateGear(2))},Object.defineProperty(h.prototype,"skewX",{get:function(){return this._skewX},set:function(t){this.setSkew(t,this._skewY)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"skewY",{get:function(){return this._skewY},set:function(t){this.setSkew(this._skewX,t)},enumerable:!0,configurable:!0}),h.prototype.setSkew=function(t,e){this._skewX==t&&this._skewY==e||(this._skewX=t,this._skewY=e,this._displayObject&&(this._displayObject.skewX=t,this._displayObject.skewY=e),this.applyPivot())},Object.defineProperty(h.prototype,"pivotX",{get:function(){return this._pivotX},set:function(t){this.setPivot(t,this._pivotY)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"pivotY",{get:function(){return this._pivotY},set:function(t){this.setPivot(this._pivotX,t)},enumerable:!0,configurable:!0}),h.prototype.setPivot=function(t,e,i){this._pivotX==t&&this._pivotY==e&&this._pivotAsAnchor==i||(this._pivotX=t,this._pivotY=e,this._pivotAsAnchor=i,this.updatePivotOffset(),this.handleXYChanged())},Object.defineProperty(h.prototype,"pivotAsAnchor",{get:function(){return this._pivotAsAnchor},enumerable:!0,configurable:!0}),h.prototype.internalSetPivot=function(t,e,i){this._pivotX=t,this._pivotY=e,this._pivotAsAnchor=i,i&&this.handleXYChanged()},h.prototype.updatePivotOffset=function(){if(this._displayObject)if(0!=this._pivotX||0!=this._pivotY){var t=this._pivotX*this._width,e=this._pivotY*this._height,i=this._displayObject.matrix.transformPoint(t,e,s);this._pivotOffsetX=this._pivotX*this._width-(i.x-this._displayObject.x),this._pivotOffsetY=this._pivotY*this._height-(i.y-this._displayObject.y)}else this._pivotOffsetX=0,this._pivotOffsetY=0},h.prototype.applyPivot=function(){0==this._pivotX&&0==this._pivotY||(this.updatePivotOffset(),this.handleXYChanged())},Object.defineProperty(h.prototype,"touchable",{get:function(){return this._touchable},set:function(e){if(this._touchable!=e){if(this._touchable=e,this.updateGear(3),this instanceof t.GImage||this instanceof t.GMovieClip||this instanceof t.GTextField&&!(this instanceof t.GTextInput)&&!(this instanceof t.GRichTextField))return;this._displayObject&&(this._displayObject.touchEnabled=this._touchable,this._displayObject instanceof egret.DisplayObjectContainer&&(this._displayObject.touchChildren=this._touchable))}},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"grayed",{get:function(){return this._grayed},set:function(t){this._grayed!=t&&(this._grayed=t,this.handleGrayedChanged(),this.updateGear(3))},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"enabled",{get:function(){return!this._grayed&&this._touchable},set:function(t){this.grayed=!t,this.touchable=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation!=t&&(this._rotation=t,this._displayObject&&(this._displayObject.rotation=this.normalizeRotation),this.applyPivot(),this.updateGear(3))},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"normalizeRotation",{get:function(){var t=this._rotation%360;return t>180?t-=360:t<-180&&(t+=360),t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!=t&&(this._alpha=t,this.handleAlphaChanged(),this.updateGear(3))},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"visible",{get:function(){return this._visible},set:function(t){this._visible!=t&&(this._visible=t,this.handleVisibleChanged(),this._parent&&this._parent.setBoundsChangedFlag(),this._group&&this._group.excludeInvisibles&&this._group.setBoundsChangedFlag())},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"internalVisible",{get:function(){return this._internalVisible&&(!this._group||this._group.internalVisible)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"internalVisible2",{get:function(){return this._visible&&(!this._group||this._group.internalVisible2)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"internalVisible3",{get:function(){return this._visible&&this._internalVisible},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"sortingOrder",{get:function(){return this._sortingOrder},set:function(t){if(t<0&&(t=0),this._sortingOrder!=t){var e=this._sortingOrder;this._sortingOrder=t,this._parent&&this._parent.childSortingOrderChanged(this,e,this._sortingOrder)}},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"focused",{get:function(){return this.root.focus==this},enumerable:!0,configurable:!0}),h.prototype.requestFocus=function(){this.root.focus=this},Object.defineProperty(h.prototype,"tooltips",{get:function(){return this._tooltips},set:function(t){this._tooltips=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"blendMode",{get:function(){return this._displayObject.blendMode},set:function(t){this._displayObject.blendMode=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"filters",{get:function(){return this._displayObject.filters},set:function(t){this._displayObject.filters=t},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"inContainer",{get:function(){return null!=this._displayObject&&null!=this._displayObject.parent},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"onStage",{get:function(){return null!=this._displayObject&&null!=this._displayObject.stage},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"resourceURL",{get:function(){return this.packageItem?"ui://"+this.packageItem.owner.id+this.packageItem.id:null},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"group",{get:function(){return this._group},set:function(t){this._group!=t&&(this._group&&this._group.setBoundsChangedFlag(),this._group=t,this._group&&this._group.setBoundsChangedFlag())},enumerable:!0,configurable:!0}),h.prototype.getGear=function(e){var i=this._gears[e];return null==i&&(this._gears[e]=i=t.GearBase.create(this,e)),i},h.prototype.updateGear=function(t){if(!this._underConstruct&&!this._gearLocked){var e=this._gears[t];e&&e.controller&&e.updateState()}},h.prototype.checkGearController=function(t,e){return null!=this._gears[t]&&this._gears[t].controller==e},h.prototype.updateGearFromRelations=function(t,e,i){this._gears[t]&&this._gears[t].updateFromRelations(e,i)},h.prototype.addDisplayLock=function(){var t=this._gears[0];if(t&&t.controller){var e=t.addLock();return this.checkGearDisplay(),e}return 0},h.prototype.releaseDisplayLock=function(t){var e=this._gears[0];e&&e.controller&&(e.releaseLock(t),this.checkGearDisplay())},h.prototype.checkGearDisplay=function(){if(!this._handlingController){var t=null==this._gears[0]||this._gears[0].connected;this._gears[8]&&(t=this._gears[8].evaluate(t)),t!=this._internalVisible&&(this._internalVisible=t,this._parent&&this._parent.childStateChanged(this),this._group&&this._group.excludeInvisibles&&this._group.setBoundsChangedFlag())}},Object.defineProperty(h.prototype,"gearXY",{get:function(){return this.getGear(1)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"gearSize",{get:function(){return this.getGear(2)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"gearLook",{get:function(){return this.getGear(3)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"relations",{get:function(){return this._relations},enumerable:!0,configurable:!0}),h.prototype.addRelation=function(t,e,i){this._relations.add(t,e,i)},h.prototype.removeRelation=function(t,e){this._relations.remove(t,e||0)},Object.defineProperty(h.prototype,"displayObject",{get:function(){return this._displayObject},enumerable:!0,configurable:!0}),h.prototype.setDisplayObject=function(t){this._displayObject!=t&&(this._displayObject&&delete this._displayObject.$owner,this._displayObject=t,this._displayObject.$owner=this)},Object.defineProperty(h.prototype,"parent",{get:function(){return this._parent},set:function(t){this._parent=t},enumerable:!0,configurable:!0}),h.prototype.removeFromParent=function(){this._parent&&this._parent.removeChild(this)},Object.defineProperty(h.prototype,"root",{get:function(){if(this instanceof t.GRoot)return this;for(var e=this._parent;e;){if(e instanceof t.GRoot)return e;e=e.parent}return t.GRoot.inst},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asCom",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asButton",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asLabel",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asProgress",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asTextField",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asRichTextField",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asTextInput",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asLoader",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asList",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asTree",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asGraph",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asGroup",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asSlider",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asComboBox",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asImage",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"asMovieClip",{get:function(){return this},enumerable:!0,configurable:!0}),h.cast=function(t){return t.$owner},Object.defineProperty(h.prototype,"text",{get:function(){return null},set:function(t){},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"icon",{get:function(){return null},set:function(t){},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"isDisposed",{get:function(){return this._disposed},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"treeNode",{get:function(){return this._treeNode},enumerable:!0,configurable:!0}),h.prototype.dispose=function(){if(!this._disposed){this._disposed=!0,this.removeFromParent(),this._relations.dispose(),this._displayObject=null;for(var t=0;t<10;t++){var e=this._gears[t];e&&e.dispose()}}},h.prototype.addClickListener=function(t,e){this.addEventListener(egret.TouchEvent.TOUCH_TAP,t,e)},h.prototype.removeClickListener=function(t,e){this.removeEventListener(egret.TouchEvent.TOUCH_TAP,t,e)},h.prototype.hasClickListener=function(){return this.hasEventListener(egret.TouchEvent.TOUCH_TAP)},h.prototype.addEventListener=function(t,i,n){e.prototype.addEventListener.call(this,t,i,n),this._displayObject&&this._displayObject.addEventListener(t,this._reDispatch,this)},h.prototype.removeEventListener=function(t,i,n){e.prototype.removeEventListener.call(this,t,i,n),this._displayObject&&!this.hasEventListener(t)&&this._displayObject.removeEventListener(t,this._reDispatch,this)},h.prototype._reDispatch=function(t){this.dispatchEvent(t)},Object.defineProperty(h.prototype,"draggable",{get:function(){return this._draggable},set:function(t){this._draggable!=t&&(this._draggable=t,this.initDrag())},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"dragBounds",{get:function(){return this._dragBounds},set:function(t){this._dragBounds=t},enumerable:!0,configurable:!0}),h.prototype.startDrag=function(t,e,i){null!=this._displayObject.stage&&this.dragBegin(t,e,i)},h.prototype.stopDrag=function(){this.dragEnd()},Object.defineProperty(h.prototype,"dragging",{get:function(){return h.draggingObject==this},enumerable:!0,configurable:!0}),h.prototype.localToGlobal=function(t,e,i){return t=t||0,e=e||0,this._pivotAsAnchor&&(t+=this._pivotX*this._width,e+=this._pivotY*this._height),this._displayObject.localToGlobal(t,e,i)},h.prototype.globalToLocal=function(t,e,i){t=t||0,e=e||0;var n=this._displayObject.globalToLocal(t,e,i);return this._pivotAsAnchor&&(n.x-=this._pivotX*this._width,n.y-=this._pivotY*this._height),n},h.prototype.localToRoot=function(e,i,n){e=e||0,i=i||0;var o=this._displayObject.localToGlobal(e,i,n);return o.x/=t.GRoot.contentScaleFactor,o.y/=t.GRoot.contentScaleFactor,o},h.prototype.rootToLocal=function(e,i,n){return e=e||0,i=i||0,e*=t.GRoot.contentScaleFactor,i*=t.GRoot.contentScaleFactor,this._displayObject.globalToLocal(e,i,n)},h.prototype.localToGlobalRect=function(t,e,i,n,o){t=t||0,e=e||0,i=i||0,n=n||0,o=o||new egret.Rectangle;var r=this.localToGlobal(t,e);return o.x=r.x,o.y=r.y,r=this.localToGlobal(t+i,e+n),o.right=r.x,o.bottom=r.y,o},h.prototype.globalToLocalRect=function(t,e,i,n,o){t=t||0,e=e||0,i=i||0,n=n||0,o=o||new egret.Rectangle;var r=this.globalToLocal(t,e);return o.x=r.x,o.y=r.y,r=this.globalToLocal(t+i,e+n),o.right=r.x,o.bottom=r.y,o},h.prototype.handleControllerChanged=function(t){this._handlingController=!0;for(var e=0;e<10;e++){var i=this._gears[e];i&&i.controller==t&&i.apply()}this._handlingController=!1,this.checkGearDisplay()},h.prototype.createDisplayObject=function(){},h.prototype.switchDisplayObject=function(e){if(e!=this._displayObject){var i=this._displayObject;if(this._displayObject&&this._displayObject.parent){var n=this._displayObject.parent.getChildIndex(this._displayObject);this._displayObject.parent.addChildAt(e,n),this._displayObject.parent.removeChild(this._displayObject)}this._displayObject=e,this._displayObject.x=i.x,this._displayObject.y=i.y,this._displayObject.rotation=i.rotation,this._displayObject.alpha=i.alpha,this._displayObject.visible=i.visible,this._displayObject.touchEnabled=i.touchEnabled,this._displayObject.scaleX=i.scaleX,this._displayObject.scaleY=i.scaleY,t.ToolSet.setColorFilter(this._displayObject,this._grayed),this._displayObject instanceof egret.DisplayObjectContainer&&(this._displayObject.touchChildren=this._touchable)}},h.prototype.handleXYChanged=function(){if(this._displayObject){var t=this._x,e=this._y;this._pivotAsAnchor&&(t-=this._pivotX*this._width,e-=this._pivotY*this._height),this._pixelSnapping&&(t=Math.round(t),e=Math.round(e)),this._displayObject.x=t+this._pivotOffsetX,this._displayObject.y=e+this._pivotOffsetY}},h.prototype.handleSizeChanged=function(){this._displayObject&&(this._displayObject.width=this._width,this._displayObject.height=this._height)},h.prototype.handleScaleChanged=function(){this._displayObject&&(this._displayObject.scaleX=this._scaleX,this._displayObject.scaleY=this._scaleY)},h.prototype.handleGrayedChanged=function(){this._displayObject&&t.ToolSet.setColorFilter(this._displayObject,this._grayed)},h.prototype.handleAlphaChanged=function(){this._displayObject&&(this._displayObject.alpha=this._alpha)},h.prototype.handleVisibleChanged=function(){this._displayObject&&(this._displayObject.visible=this.internalVisible2),this instanceof t.GGroup&&this.handleVisibleChanged()},h.prototype.getProp=function(e){switch(e){case t.ObjectPropID.Text:return this.text;case t.ObjectPropID.Icon:return this.icon;case t.ObjectPropID.Color:case t.ObjectPropID.OutlineColor:return NaN;case t.ObjectPropID.Playing:return!1;case t.ObjectPropID.Frame:case t.ObjectPropID.DeltaTime:return 0;case t.ObjectPropID.TimeScale:return 1;case t.ObjectPropID.FontSize:return 0;case t.ObjectPropID.Selected:return!1;default:return}},h.prototype.setProp=function(e,i){switch(e){case t.ObjectPropID.Text:this.text=i;break;case t.ObjectPropID.Icon:this.icon=i}},h.prototype.constructFromResource=function(){},h.prototype.setup_beforeAdd=function(e,i){var n,o;e.seek(i,0),e.skip(5),this._id=e.readS(),this._name=e.readS(),n=e.readInt(),o=e.readInt(),this.setXY(n,o),e.readBool()&&(this.initWidth=e.readInt(),this.initHeight=e.readInt(),this.setSize(this.initWidth,this.initHeight,!0)),e.readBool()&&(this.minWidth=e.readInt(),this.maxWidth=e.readInt(),this.minHeight=e.readInt(),this.maxHeight=e.readInt()),e.readBool()&&(n=e.readFloat(),o=e.readFloat(),this.setScale(n,o)),e.readBool()&&(n=e.readFloat(),o=e.readFloat(),this.setSkew(n,o)),e.readBool()&&(n=e.readFloat(),o=e.readFloat(),this.setPivot(n,o,e.readBool())),1!=(n=e.readFloat())&&(this.alpha=n),0!=(n=e.readFloat())&&(this.rotation=n),e.readBool()||(this.visible=!1),e.readBool()||(this.touchable=!1),e.readBool()&&(this.grayed=!0);var r=e.readByte();2==r?this.blendMode=egret.BlendMode.ADD:5==r&&(this.blendMode=egret.BlendMode.ERASE),1==e.readByte()&&this._displayObject&&t.ToolSet.setColorFilter(this._displayObject,[e.readFloat(),e.readFloat(),e.readFloat(),e.readFloat()]);var s=e.readS();null!=s&&(this.data=s)},h.prototype.setup_afterAdd=function(t,e){t.seek(e,1);var i=t.readS();null!=i&&(this.tooltips=i);var n=t.readShort();n>=0&&(this.group=this.parent.getChildAt(n)),t.seek(e,2);for(var o=t.readShort(),r=0;ru.right&&(l=u.right-r.width)u.bottom&&(c=u.bottom-r.height)=0;--t){var n=this._children[t];n.parent=null,n.dispose()}this._boundsChanged=!1,e.prototype.dispose.call(this)},Object.defineProperty(i.prototype,"displayListContainer",{get:function(){return this._container},enumerable:!0,configurable:!0}),i.prototype.addChild=function(t){return this.addChildAt(t,this._children.length),t},i.prototype.addChildAt=function(t,e){if(void 0===e&&(e=0),!t)throw"child is null";var i=this._children.length;if(e>=0&&e<=i){if(t.parent==this)this.setChildIndex(t,e);else{t.removeFromParent(),t.parent=this;var n=this._children.length;0!=t.sortingOrder?(this._sortingChildCount++,e=this.getInsertPosForSortingChild(t)):this._sortingChildCount>0&&e>n-this._sortingChildCount&&(e=n-this._sortingChildCount),e==n?this._children.push(t):this._children.splice(e,0,t),this.childStateChanged(t),this.setBoundsChangedFlag()}return t}throw"Invalid child index"},i.prototype.getInsertPosForSortingChild=function(t){var e=this._children.length,i=0;for(i=0;i=0&&e=this.numChildren)&&(e=this.numChildren-1);for(var n=t;n<=e;++n)this.removeChildAt(t,i)},i.prototype.getChildAt=function(t){if(t>=0&&t0&&e>n-this._sortingChildCount-1&&(e=n-this._sortingChildCount-1),this._setChildIndex(t,i,e)}},i.prototype.setChildIndexBefore=function(t,e){var i=this._children.indexOf(t);if(-1==i)throw"Not a child of this container";if(0!=t.sortingOrder)return i;var n=this._children.length;return this._sortingChildCount>0&&e>n-this._sortingChildCount-1&&(e=n-this._sortingChildCount-1),io&&(n=o),i==n)return i;if(this._children.splice(i,1),this._children.splice(n,0,e),e.inContainer){var r,s=0;if(this._childrenRenderOrder==t.ChildrenRenderOrder.Ascent){for(r=0;rn;r--)this._children[r].inContainer&&s++;s==this._container.numChildren&&s--,this._container.setChildIndex(e.displayObject,s)}else t.GTimers.inst.callLater(this.buildNativeDisplayList,this);this.setBoundsChangedFlag()}return n},i.prototype.swapChildren=function(t,e){var i=this._children.indexOf(t),n=this._children.indexOf(e);if(-1==i||-1==n)throw"Not a child of this container";this.swapChildrenAt(i,n)},i.prototype.swapChildrenAt=function(t,e){var i=this._children[t],n=this._children[e];this.setChildIndex(i,e),this.setChildIndex(n,t)},Object.defineProperty(i.prototype,"numChildren",{get:function(){return this._children.length},enumerable:!0,configurable:!0}),i.prototype.isAncestorOf=function(t){if(!t)return!1;for(var e=t.parent;e;){if(e==this)return!0;e=e.parent}return!1},i.prototype.addController=function(t){this._controllers.push(t),t.parent=this,this.applyController(t)},i.prototype.getControllerAt=function(t){return this._controllers[t]},i.prototype.getController=function(t){for(var e=this._controllers.length,i=0;i=0&&(i=this._children[n])!=e;n--)i.displayObject&&i.displayObject.parent&&r++;this._container.addChildAt(e.displayObject,r)}else this._container.addChild(e.displayObject),t.GTimers.inst.callLater(this.buildNativeDisplayList,this)}}else e.displayObject.parent&&this._container.removeChild(e.displayObject)}},i.prototype.buildNativeDisplayList=function(){var e,i,n=this._children.length;if(0!=n)switch(this._childrenRenderOrder){case t.ChildrenRenderOrder.Ascent:for(e=0;e=0;e--)(i=this._children[e]).displayObject&&i.internalVisible&&this._container.addChild(i.displayObject);break;case t.ChildrenRenderOrder.Arch:var o=t.ToolSet.clamp(this._apexIndex,0,n);for(e=0;e=o;e--)(i=this._children[e]).displayObject&&i.internalVisible&&this._container.addChild(i.displayObject)}},i.prototype.applyController=function(t){this._applyingController=t;for(var e=this._children.length,i=0;ia&&(a=n);s=0&&t.x<=this.width&&t.y+t.height>=0&&t.y<=this.height:!this._scrollPane||this._scrollPane.isChildInView(t)},i.prototype.getFirstChildInView=function(){for(var t=this._children.length,e=0;e0)for(var e=0;e0)for(var e=0;e0){t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY;var r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY,a=0,h=0;for(h=0;hr&&(r=a),(a=l.y+l.actualHeight)>s&&(s=a)}i=r-t,n=s-e}this.setBounds(t,e,i,n)},i.prototype.setBounds=function(t,e,i,n){void 0===n&&(n=0),this._boundsChanged=!1,this._scrollPane&&this._scrollPane.setContentSize(Math.round(t+i),Math.round(e+n))},Object.defineProperty(i.prototype,"viewWidth",{get:function(){return this._scrollPane?this._scrollPane.viewWidth:this.width-this._margin.left-this._margin.right},set:function(t){this._scrollPane?this._scrollPane.viewWidth=t:this.width=t+this._margin.left+this._margin.right},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"viewHeight",{get:function(){return this._scrollPane?this._scrollPane.viewHeight:this.height-this._margin.top-this._margin.bottom},set:function(t){this._scrollPane?this._scrollPane.viewHeight=t:this.height=t+this._margin.top+this._margin.bottom},enumerable:!0,configurable:!0}),i.prototype.getSnappingPosition=function(t,e,i){i||(i=new egret.Point);var n=this._children.length;if(0==n)return i.x=0,i.y=0,i;this.ensureBoundsCorrect();var o=null,r=null,s=0;if(0!=e){for(;s0&&s--;s0&&(this.displayObject.addEventListener(egret.Event.ADDED_TO_STAGE,this.___added,this),this.displayObject.addEventListener(egret.Event.REMOVED_FROM_STAGE,this.___removed,this)),this.applyAllControllers(),this._buildingDisplayList=!1,this._underConstruct=!1,this.buildNativeDisplayList(),this.setBoundsChangedFlag(),u.objectType!=t.ObjectType.Component&&this.constructExtension(_),this.onConstruct()},i.prototype.onConstruct=function(){this.constructFromXML(null)},i.prototype.constructExtension=function(t){},i.prototype.constructFromXML=function(t){},i.prototype.setup_afterAdd=function(t,i){e.prototype.setup_afterAdd.call(this,t,i),t.seek(i,4);var n=t.readShort();-1!=n&&this._scrollPane&&(this._scrollPane.pageController=this._parent.getControllerAt(n));for(var o=t.readShort(),r=0;r=2)for(o=t.readShort(),r=0;r=0&&(this._relatedController=this.parent.getControllerAt(o)),this._relatedPageId=t.readS(),null!=(n=t.readS())&&(this._sound=n),t.readBool()&&(this._soundVolumeScale=t.readFloat()),this.selected=t.readBool()))},i.prototype.__mousedown=function(e){this._down=!0,t.GRoot.inst.nativeStage.addEventListener(egret.TouchEvent.TOUCH_END,this.__mouseup,this),this._mode==t.ButtonMode.Common&&(this.grayed&&this._buttonController&&this._buttonController.hasPage(i.DISABLED)?this.setState(i.SELECTED_DISABLED):this.setState(i.DOWN)),this._linkedPopup&&(this._linkedPopup instanceof t.Window?this._linkedPopup.toggleStatus():this.root.togglePopup(this._linkedPopup,this))},i.prototype.__mouseup=function(e){if(this._down){if(t.GRoot.inst.nativeStage.removeEventListener(egret.TouchEvent.TOUCH_END,this.__mouseup,this),this._down=!1,!this.displayObject)return;this._mode==t.ButtonMode.Common&&(this.grayed&&this._buttonController&&this._buttonController.hasPage(i.DISABLED)?this.setState(i.DISABLED):this._over?this.setState(i.OVER):this.setState(i.UP))}},i.prototype.__click=function(e){if(this._sound){var i=t.UIPackage.getItemByURL(this._sound);if(i){var n=i.owner.getItemAsset(i);n&&t.GRoot.inst.playOneShotSound(n,this._soundVolumeScale)}}this._mode==t.ButtonMode.Check?this._changeStateOnClick&&(this.selected=!this._selected,this.dispatchEvent(new t.StateChangeEvent(t.StateChangeEvent.CHANGED))):this._mode==t.ButtonMode.Radio?this._changeStateOnClick&&!this._selected&&(this.selected=!0,this.dispatchEvent(new t.StateChangeEvent(t.StateChangeEvent.CHANGED))):this._relatedController&&(this._relatedController.selectedPageId=this._relatedPageId)},i.UP="up",i.DOWN="down",i.OVER="over",i.SELECTED_OVER="selectedOver",i.DISABLED="disabled",i.SELECTED_DISABLED="selectedDisabled",i}(t.GComponent);t.GButton=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i._visibleItemCount=0,i._selectedIndex=0,i._popupDirection=t.PopupDirection.Auto,i._visibleItemCount=t.UIConfig.defaultComboBoxVisibleItemCount,i._itemsUpdated=!0,i._selectedIndex=-1,i._items=[],i._values=[],i}return __extends(i,e),Object.defineProperty(i.prototype,"text",{get:function(){return this._titleObject?this._titleObject.text:null},set:function(t){this._titleObject&&(this._titleObject.text=t),this.updateGear(6)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._iconObject?this._iconObject.icon:null},set:function(t){this._iconObject&&(this._iconObject.icon=t),this.updateGear(7)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"titleColor",{get:function(){var t=this.getTextField();return t?t.color:0},set:function(t){var e=this.getTextField();e&&(e.color=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"titleFontSize",{get:function(){var t=this.getTextField();return t?t.fontSize:0},set:function(t){var e=this.getTextField();e&&(e.fontSize=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visibleItemCount",{get:function(){return this._visibleItemCount},set:function(t){this._visibleItemCount=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"popupDirection",{get:function(){return this._popupDirection},set:function(t){this._popupDirection=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"items",{get:function(){return this._items},set:function(t){t?this._items=t.concat():this._items.length=0,this._items.length>0?(this._selectedIndex>=this._items.length?this._selectedIndex=this._items.length-1:-1==this._selectedIndex&&(this._selectedIndex=0),this.text=this._items[this._selectedIndex],this._icons&&this._selectedIndex=0&&this._selectedIndex0?(this._selectedIndex=0,this.text=this._items[0]):this._selectedIndex=-1,null!=(s=t.readS())&&(this.icon=s),t.readBool()&&(this.titleColor=t.readColor()),(o=t.readInt())>0&&(this._visibleItemCount=o),this._popupDirection=t.readByte(),(o=t.readShort())>=0&&(this._selectionController=this.parent.getControllerAt(o))}},i.prototype.showDropdown=function(){if(this._itemsUpdated){this._itemsUpdated=!1,this._list.removeChildrenToPool();for(var e=this._items.length,i=0;i>24&255)/255,r=t.readColor(!0),this._fillColor=16777215&r,this._fillAlpha=(r>>24&255)/255,t.readBool())for(this._cornerRadius=new Array(4),n=0;n<4;n++)this._cornerRadius[n]=t.readFloat();if(3==this._type)for(o=t.readShort(),this._polygonPoints=[],this._polygonPoints.length=o,n=0;n0))for(this._distances=[],n=0;na&&(a=n),(n=i.yMin+i.height)>h&&(h=n),l=!1);var c=0,u=0;l||(this._updating|=1,this.setXY(r,s),this._updating&=2,c=a-r,u=h-s),0==(2&this._updating)?(this._updating|=2,this.setSize(c,u),this._updating&=1):(this._updating&=1,this.resizeChildren(this._width-c,this._height-u))},i.prototype.handleLayout=function(){var e,i,n;if(this._updating|=1,this._layout==t.GroupLayoutType.Horizontal){var o=this.x;for(n=this._parent.numChildren,i=0;i0?o._sizePercentInGroup=(1==this._layout?o.width:o.height)/this._totalSize:o._sizePercentInGroup=0)}var a=0,h=1,l=!1;if(1==this._layout){a=this.width-(this._numChildren-1)*this._columnGap,-1!=this._mainChildIndex&&a>=this._totalSize&&((o=this._parent.getChildAt(this._mainChildIndex)).setSize(a-(this._totalSize-this._mainGridMinSize),o._rawHeight+i,!0),a-=o.width,h-=o._sizePercentInGroup,l=!0);var c=this.x;for(n=0;n=this._totalSize&&((o=this._parent.getChildAt(this._mainChildIndex)).setSize(o._rawWidth+e,a-(this._totalSize-this._mainGridMinSize),!0),a-=o.height,h-=o._sizePercentInGroup,l=!0);var u=this.y;for(n=0;n=2&&(this._excludeInvisibles=t.readBool(),this._autoSizeDisabled=t.readBool(),this._mainChildIndex=t.readInt())},i.prototype.setup_afterAdd=function(t,i){e.prototype.setup_afterAdd.call(this,t,i),this.visible||this.handleVisibleChanged()},i}(t.GObject);t.GGroup=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i._flip=t.FlipType.None,i}return __extends(i,e),Object.defineProperty(i.prototype,"color",{get:function(){return this._content.color},set:function(t){this._content.color!=t&&(this._content.color=t,this.updateGear(4))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"flip",{get:function(){return this._flip},set:function(e){if(this._flip!=e){this._flip=e;var i=1,n=1;this._flip!=t.FlipType.Horizontal&&this._flip!=t.FlipType.Both||(i=-1),this._flip!=t.FlipType.Vertical&&this._flip!=t.FlipType.Both||(n=-1),this._content.scaleX=i,this._content.scaleY=n,this.handleXYChanged()}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillMethod",{get:function(){return this._content.fillMethod},set:function(t){this._content.fillMethod=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillOrigin",{get:function(){return this._content.fillOrigin},set:function(t){this._content.fillOrigin=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillClockwise",{get:function(){return this._content.fillClockwise},set:function(t){this._content.fillClockwise=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillAmount",{get:function(){return this._content.fillAmount},set:function(t){this._content.fillAmount=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"texture",{get:function(){return this._content.texture},set:function(t){t?(this.sourceWidth=t.textureWidth,this.sourceHeight=t.textureHeight):(this.sourceWidth=0,this.sourceHeight=0),this.initWidth=this.sourceWidth,this.initHeight=this.sourceHeight,this._content.scale9Grid=null,this._content.fillMode=egret.BitmapFillMode.SCALE,this._content.texture=t},enumerable:!0,configurable:!0}),i.prototype.createDisplayObject=function(){this._content=new t.Image,this._content.touchEnabled=!1,this.setDisplayObject(this._content)},i.prototype.constructFromResource=function(){var t=this.packageItem.getBranch();this.sourceWidth=t.width,this.sourceHeight=t.height,this.initWidth=this.sourceWidth,this.initHeight=this.sourceHeight,this.setSize(this.sourceWidth,this.sourceHeight),(t=t.getHighResolution()).load(),this._content.scale9Grid=t.scale9Grid,this._content.smoothing=t.smoothing,t.scaleByTile&&(this._content.fillMode=egret.BitmapFillMode.REPEAT),this.setSize(this.sourceWidth,this.sourceHeight),this._content.texture=t.asset},i.prototype.handleXYChanged=function(){e.prototype.handleXYChanged.call(this),this._flip!=t.FlipType.None&&(-1==this._content.scaleX&&(this._content.x+=this.width),-1==this._content.scaleY&&(this._content.y+=this.height))},i.prototype.getProp=function(i){return i==t.ObjectPropID.Color?this.color:e.prototype.getProp.call(this,i)},i.prototype.setProp=function(i,n){i==t.ObjectPropID.Color?this.color=n:e.prototype.setProp.call(this,i,n)},i.prototype.setup_beforeAdd=function(t,i){e.prototype.setup_beforeAdd.call(this,t,i),t.seek(i,5),t.readBool()&&(this.color=t.readColor()),this.flip=t.readByte(),this._content.fillMethod=t.readByte(),0!=this._content.fillMethod&&(this._content.fillOrigin=t.readByte(),this._content.fillClockwise=t.readBool(),this._content.fillAmount=t.readFloat())},i}(t.GObject);t.GImage=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){return e.call(this)||this}return __extends(i,e),Object.defineProperty(i.prototype,"icon",{get:function(){if(this._iconObject)return this._iconObject.icon},set:function(t){this._iconObject&&(this._iconObject.icon=t),this.updateGear(7)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._titleObject?this._titleObject.text:null},set:function(t){this._titleObject&&(this._titleObject.text=t),this.updateGear(6)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"text",{get:function(){return this.title},set:function(t){this.title=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"titleColor",{get:function(){var t=this.getTextField();return t?t.color:0},set:function(t){var e=this.getTextField();e&&(e.color=t),this.updateGear(4)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"titleFontSize",{get:function(){var t=this.getTextField();return t?t.fontSize:0},set:function(t){var e=this.getTextField();e&&(e.fontSize=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"editable",{get:function(){return!!(this._titleObject&&this._titleObject instanceof t.GTextInput)&&this._titleObject.asTextInput.editable},set:function(t){this._titleObject&&(this._titleObject.asTextInput.editable=t)},enumerable:!0,configurable:!0}),i.prototype.getTextField=function(){return this._titleObject instanceof t.GTextField?this._titleObject:this._titleObject instanceof i||this._titleObject instanceof t.GButton?this._titleObject.getTextField():null},i.prototype.getProp=function(i){switch(i){case t.ObjectPropID.Color:return this.titleColor;case t.ObjectPropID.OutlineColor:var n=this.getTextField();return n?n.strokeColor:0;case t.ObjectPropID.FontSize:return this.titleFontSize;default:return e.prototype.getProp.call(this,i)}},i.prototype.setProp=function(i,n){switch(i){case t.ObjectPropID.Color:this.titleColor=n;break;case t.ObjectPropID.OutlineColor:var o=this.getTextField();o&&(o.strokeColor=n);break;case t.ObjectPropID.FontSize:this.titleFontSize=n;break;default:e.prototype.setProp.call(this,i,n)}},i.prototype.constructExtension=function(t){this._titleObject=this.getChild("title"),this._iconObject=this.getChild("icon")},i.prototype.setup_afterAdd=function(i,n){if(e.prototype.setup_afterAdd.call(this,i,n),i.seek(n,6)&&i.readByte()==this.packageItem.objectType){var o;null!=(o=i.readS())&&(this.title=o),null!=(o=i.readS())&&(this.icon=o),i.readBool()&&(this.titleColor=i.readColor());var r=i.readInt();if(0!=r&&(this.titleFontSize=r),i.readBool()){var s=this.getTextField();s instanceof t.GTextInput?(null!=(o=i.readS())&&(s.promptText=o),null!=(o=i.readS())&&(s.restrict=o),0!=(r=i.readInt())&&(s.maxLength=r),r=i.readInt(),i.readBool()&&(s.password=!0)):i.skip(13)}}},i}(t.GComponent);t.GLabel=e}(fgui||(fgui={})),function(t){var e=function(e){function n(){var i=e.call(this)||this;return i.scrollItemToViewOnClick=!0,i.foldInvisibleItems=!1,i._lineCount=0,i._columnCount=0,i._lineGap=0,i._columnGap=0,i._lastSelectedIndex=0,i._numItems=0,i._realNumItems=0,i._firstIndex=0,i._curLineItemCount=0,i._curLineItemCount2=0,i._virtualListChanged=0,i.itemInfoVer=0,i._trackBounds=!0,i._pool=new t.GObjectPool,i._layout=t.ListLayoutType.SingleColumn,i._autoResizeItem=!0,i._lastSelectedIndex=-1,i._selectionMode=t.ListSelectionMode.Single,i.opaque=!0,i._align=t.AlignType.Left,i._verticalAlign=t.VertAlignType.Top,i._container=new egret.DisplayObjectContainer,i._rootContainer.addChild(i._container),i}return __extends(n,e),n.prototype.dispose=function(){this._pool.clear(),e.prototype.dispose.call(this)},Object.defineProperty(n.prototype,"layout",{get:function(){return this._layout},set:function(t){this._layout!=t&&(this._layout=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"lineCount",{get:function(){return this._lineCount},set:function(t){this._lineCount!=t&&(this._lineCount=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"columnCount",{get:function(){return this._columnCount},set:function(t){this._columnCount!=t&&(this._columnCount=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"lineGap",{get:function(){return this._lineGap},set:function(t){this._lineGap!=t&&(this._lineGap=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"columnGap",{get:function(){return this._columnGap},set:function(t){this._columnGap!=t&&(this._columnGap=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"align",{get:function(){return this._align},set:function(t){this._align!=t&&(this._align=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"verticalAlign",{get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!=t&&(this._verticalAlign=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"virtualItemSize",{get:function(){return this._itemSize},set:function(t){this._virtual&&(this._itemSize||(this._itemSize=new egret.Point),this._itemSize.copyFrom(t),this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"defaultItem",{get:function(){return this._defaultItem},set:function(t){this._defaultItem=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"autoResizeItem",{get:function(){return this._autoResizeItem},set:function(t){this._autoResizeItem!=t&&(this._autoResizeItem=t,this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectionMode",{get:function(){return this._selectionMode},set:function(t){this._selectionMode=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectionController",{get:function(){return this._selectionController},set:function(t){this._selectionController=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"itemPool",{get:function(){return this._pool},enumerable:!0,configurable:!0}),n.prototype.getFromPool=function(t){t||(t=this._defaultItem);var e=this._pool.getObject(t);return e&&(e.visible=!0),e},n.prototype.returnToPool=function(t){t.displayObject.cacheAsBitmap=!1,this._pool.returnObject(t)},n.prototype.addChildAt=function(i,n){return e.prototype.addChildAt.call(this,i,n),i instanceof t.GButton&&(i.selected=!1,i.changeStateOnClick=!1),i.addEventListener(egret.TouchEvent.TOUCH_TAP,this.__clickItem,this),i},n.prototype.addItem=function(e){return e||(e=this._defaultItem),this.addChild(t.UIPackage.createObjectFromURL(e))},n.prototype.addItemFromPool=function(t){return this.addChild(this.getFromPool(t))},n.prototype.removeChildAt=function(t,i){var n=e.prototype.removeChildAt.call(this,t,i);return n.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.__clickItem,this),n},n.prototype.removeChildToPoolAt=function(t){var i=e.prototype.removeChildAt.call(this,t);this.returnToPool(i)},n.prototype.removeChildToPool=function(t){e.prototype.removeChild.call(this,t),this.returnToPool(t)},n.prototype.removeChildrenToPool=function(t,e){null==t&&(t=0),null==e&&(e=-1),(e<0||e>=this._children.length)&&(e=this._children.length-1);for(var i=t;i<=e;++i)this.removeChildToPoolAt(t)},Object.defineProperty(n.prototype,"selectedIndex",{get:function(){var e;if(this._virtual)for(e=0;e=0&&e=0&&(this.clearSelection(),this.addSelection(i,!0));else if(this._layout==t.ListLayoutType.FlowHorizontal||this._layout==t.ListLayoutType.Pagination){for(var n=this._children[i],o=0,r=i-1;r>=0;r--){var s=this._children[r];if(s.y!=n.y){n=s;break}o++}for(;r>=0;r--)if((s=this._children[r]).y!=n.y){this.clearSelection(),this.addSelection(r+o+1,!0);break}}break;case 3:if(this._layout==t.ListLayoutType.SingleRow||this._layout==t.ListLayoutType.FlowHorizontal||this._layout==t.ListLayoutType.Pagination)++i=0&&(this.clearSelection(),this.addSelection(i,!0));else if(this._layout==t.ListLayoutType.FlowVertical){for(n=this._children[i],o=0,r=i-1;r>=0;r--){if((s=this._children[r]).x!=n.x){n=s;break}o++}for(;r>=0;r--)if((s=this._children[r]).x!=n.x){this.clearSelection(),this.addSelection(r+o+1,!0);break}}}},n.prototype.__clickItem=function(e){if(!this._scrollPane||!this._scrollPane.isDragged){var i=e.currentTarget;this.setSelectionOnEvent(i),this._scrollPane&&this.scrollItemToViewOnClick&&this._scrollPane.scrollToView(i,!0);var n=new t.ItemEvent(t.ItemEvent.CLICK,i);n.stageX=e.stageX,n.stageY=e.stageY,this.dispatchItemEvent(n)}},n.prototype.dispatchItemEvent=function(t){this.dispatchEvent(t)},n.prototype.setSelectionOnEvent=function(e){if(e instanceof t.GButton&&this._selectionMode!=t.ListSelectionMode.None){var i=!1,n=this.childIndexToItemIndex(this.getChildIndex(e));if(this._selectionMode==t.ListSelectionMode.Single)e.selected||(this.clearSelectionExcept(e),e.selected=!0);else if(t.GRoot.shiftKeyDown){if(!e.selected)if(-1!=this._lastSelectedIndex){var o,r=Math.min(this._lastSelectedIndex,n),s=Math.max(this._lastSelectedIndex,n);if(s=Math.min(s,this.numItems-1),this._virtual)for(o=r;o<=s;o++){var a=this._virtualItems[o];a.obj instanceof t.GButton&&(a.obj.selected=!0),a.selected=!0}else for(o=r;o<=s;o++){var h=this.getChildAt(o);h instanceof t.GButton&&(h.selected=!0)}i=!0}else e.selected=!0}else t.GRoot.ctrlKeyDown||this._selectionMode==t.ListSelectionMode.Multiple_SingleClick?e.selected=!e.selected:e.selected?this.clearSelectionExcept(e):(this.clearSelectionExcept(e),e.selected=!0);i||(this._lastSelectedIndex=n),e.selected&&this.updateSelectionController(n)}},n.prototype.resizeToFit=function(e,i){void 0===e&&(e=Number.POSITIVE_INFINITY),void 0===i&&(i=0),this.ensureBoundsCorrect();var n=this.numItems;if(e>n&&(e=n),this._virtual){var o=Math.ceil(e/this._curLineItemCount);this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal?this.viewHeight=o*this._itemSize.y+Math.max(0,o-1)*this._lineGap:this.viewWidth=o*this._itemSize.x+Math.max(0,o-1)*this._columnGap}else if(0==e)this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal?this.viewHeight=i:this.viewWidth=i;else{for(var r,s=e-1;s>=0&&(r=this.getChildAt(s),this.foldInvisibleItems&&!r.visible);)s--;if(s<0)this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal?this.viewHeight=i:this.viewWidth=i;else{var a=0;this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal?((a=r.y+r.height)e&&(e=n.width)}return e},n.prototype.handleSizeChanged=function(){e.prototype.handleSizeChanged.call(this),this.setBoundsChangedFlag(),this._virtual&&this.setVirtualListChangedFlag(!0)},n.prototype.handleControllerChanged=function(t){e.prototype.handleControllerChanged.call(this,t),this._selectionController==t&&(this.selectedIndex=t.selectedIndex)},n.prototype.updateSelectionController=function(t){if(this._selectionController&&!this._selectionController.changing&&tthis._virtualItems[a].height/2&&athis._virtualItems[a].width/2&&athis._virtualItems[a].width/2&&a=this._virtualItems.length)throw"Invalid child index: "+e+">"+this._virtualItems.length;var o;this._loop&&(e=Math.floor(this._firstIndex/this._numItems)*this._numItems+e);var r,s=this._virtualItems[e],a=0;if(this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal){for(r=this._curLineItemCount-1;r0&&(e%=this._numItems),e},n.prototype.itemIndexToChildIndex=function(e){if(!this._virtual)return e;if(this._layout==t.ListLayoutType.Pagination)return this.getChildIndex(this._virtualItems[e].obj);if(this._loop&&this._numItems>0){var i=this._firstIndex%this._numItems;e>=i?e-=i:e=this._numItems-i+e}else e-=this._firstIndex;return e},n.prototype.setVirtual=function(){this._setVirtual(!1)},n.prototype.setVirtualAndLoop=function(){this._setVirtual(!0)},n.prototype._setVirtual=function(e){if(!this._virtual){if(null==this._scrollPane)throw"Virtual list must be scrollable!";if(e){if(this._layout==t.ListLayoutType.FlowHorizontal||this._layout==t.ListLayoutType.FlowVertical)throw"Loop list is not supported for FlowHorizontal or FlowVertical layout!";this._scrollPane.bouncebackEffect=!1}if(this._virtual=!0,this._loop=e,this._virtualItems=new Array,this.removeChildrenToPool(),null==this._itemSize){this._itemSize=new egret.Point;var i=this.getFromPool(null);if(null==i)throw"Virtual List must have a default list item resource.";this._itemSize.x=i.width,this._itemSize.y=i.height,this.returnToPool(i)}this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal?(this._scrollPane.scrollStep=this._itemSize.y,this._loop&&(this._scrollPane._loop=2)):(this._scrollPane.scrollStep=this._itemSize.x,this._loop&&(this._scrollPane._loop=1)),this._scrollPane.addEventListener(t.ScrollPane.SCROLL,this.__scrolled,this),this.setVirtualListChangedFlag(!0)}},Object.defineProperty(n.prototype,"numItems",{get:function(){return this._virtual?this._numItems:this._children.length},set:function(e){if(this._virtual){if(null==this.itemRenderer)throw"Set itemRenderer first!";this._numItems=e,this._loop?this._realNumItems=6*this._numItems:this._realNumItems=this._numItems;var i=this._virtualItems.length;if(this._realNumItems>i)for(r=i;ro)for(var r=o;r0?this._curLineItemCount=this._columnCount:(this._curLineItemCount=Math.floor((this._scrollPane.viewWidth+this._columnGap)/(this._itemSize.x+this._columnGap)),this._curLineItemCount<=0&&(this._curLineItemCount=1)):this._layout==t.ListLayoutType.FlowVertical?this._lineCount>0?this._curLineItemCount=this._lineCount:(this._curLineItemCount=Math.floor((this._scrollPane.viewHeight+this._lineGap)/(this._itemSize.y+this._lineGap)),this._curLineItemCount<=0&&(this._curLineItemCount=1)):(this._columnCount>0?this._curLineItemCount=this._columnCount:(this._curLineItemCount=Math.floor((this._scrollPane.viewWidth+this._columnGap)/(this._itemSize.x+this._columnGap)),this._curLineItemCount<=0&&(this._curLineItemCount=1)),this._lineCount>0?this._curLineItemCount2=this._lineCount:(this._curLineItemCount2=Math.floor((this._scrollPane.viewHeight+this._lineGap)/(this._itemSize.y+this._lineGap)),this._curLineItemCount2<=0&&(this._curLineItemCount2=1))));var i=0,n=0;if(this._realNumItems>0){var o,r=Math.ceil(this._realNumItems/this._curLineItemCount)*this._curLineItemCount,s=Math.min(this._curLineItemCount,this._realNumItems);if(this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal){for(o=0;o0&&(i-=this._lineGap),this._autoResizeItem)n=this._scrollPane.viewWidth;else{for(o=0;o0&&(n-=this._columnGap)}}else if(this._layout==t.ListLayoutType.SingleRow||this._layout==t.ListLayoutType.FlowVertical){for(o=0;o0&&(n-=this._columnGap),this._autoResizeItem)i=this._scrollPane.viewHeight;else{for(o=0;o0&&(i-=this._lineGap)}}else{n=Math.ceil(r/(this._curLineItemCount*this._curLineItemCount2))*this.viewWidth,i=this.viewHeight}}this.handleAlign(n,i),this._scrollPane.setContentSize(n,i),this._eventLocked=!1,this.handleScroll(!0)},n.prototype.__scrolled=function(t){this.handleScroll(!1)},n.prototype.getIndexOnPos1=function(t){if(this._realNumItems0&&!t){if((n=this.getChildAt(0).y)>i){for(e=this._firstIndex-this._curLineItemCount;e>=0;e-=this._curLineItemCount)if((n-=this._virtualItems[e].height+this._lineGap)<=i)return i=n,e;return i=0,0}for(e=this._firstIndex;ei)return i=n,e;n=o}return i=n,this._realNumItems-this._curLineItemCount}for(n=0,e=0;ei)return i=n,e;n=o}return i=n,this._realNumItems-this._curLineItemCount},n.prototype.getIndexOnPos2=function(t){if(this._realNumItems0&&!t){if((n=this.getChildAt(0).x)>i){for(e=this._firstIndex-this._curLineItemCount;e>=0;e-=this._curLineItemCount)if((n-=this._virtualItems[e].width+this._columnGap)<=i)return i=n,e;return i=0,0}for(e=this._firstIndex;ei)return i=n,e;n=o}return i=n,this._realNumItems-this._curLineItemCount}for(n=0,e=0;ei)return i=n,e;n=o}return i=n,this._realNumItems-this._curLineItemCount},n.prototype.getIndexOnPos3=function(t){if(this._realNumItemsi)return i=a,s+e;a=n}return i=a,s+this._curLineItemCount-1},n.prototype.handleScroll=function(e){if(!this._eventLocked){if(this._layout==t.ListLayoutType.SingleColumn||this._layout==t.ListLayoutType.FlowHorizontal){for(var i=0;this.handleScroll1(e);)if(e=!1,++i>20){console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size.");break}this.handleArchOrder1()}else if(this._layout==t.ListLayoutType.SingleRow||this._layout==t.ListLayoutType.FlowVertical){for(i=0;this.handleScroll2(e);)if(e=!1,++i>20){console.log("FairyGUI: list will never be filled as the item renderer function always returns a different size.");break}this.handleArchOrder2()}else this.handleScroll3(e);this._boundsChanged=!1}},n.prototype.handleScroll1=function(e){var n=this._scrollPane.scrollingPosY,o=n+this._scrollPane.viewHeight,r=o==this._scrollPane.contentHeight;i=n;var s=this.getIndexOnPos1(e);if(n=i,s==this._firstIndex&&!e)return!1;var a=this._firstIndex;this._firstIndex=s;var h,l,c,u,_,p=s,d=a>s,g=this.numChildren,f=a+g-1,y=d?f:a,m=0,b=n,v=0,w=0,C=this.defaultItem,S=(this._scrollPane.viewWidth-this._columnGap*(this._curLineItemCount-1))/this._curLineItemCount;for(this.itemInfoVer++;p=a;_--)if((c=this._virtualItems[_]).obj&&c.updateFlag!=this.itemInfoVer&&c.obj.resourceURL==C){c.obj instanceof t.GButton&&(c.selected=c.obj.selected),l.obj=c.obj,c.obj=null,_==y&&y--;break}}else for(_=y;_<=f;_++)if((c=this._virtualItems[_]).obj&&c.updateFlag!=this.itemInfoVer&&c.obj.resourceURL==C){c.obj instanceof t.GButton&&(c.selected=c.obj.selected),l.obj=c.obj,c.obj=null,_==y&&y++;break}l.obj?this.setChildIndex(l.obj,d?p-s:this.numChildren):(l.obj=this._pool.getObject(C),d?this.addChildAt(l.obj,p-s):this.addChild(l.obj)),l.obj instanceof t.GButton&&(l.obj.selected=l.selected),h=!0}else h=e;h&&(this._autoResizeItem&&(this._layout==t.ListLayoutType.SingleColumn||this._columnCount>0)&&l.obj.setSize(S,l.obj.height,!0),this.itemRenderer.call(this.callbackThisObj,p%this._numItems,l.obj),p%this._curLineItemCount==0&&(v+=Math.ceil(l.obj.height)-l.height,p==s&&a>s&&(w=Math.ceil(l.obj.height)-l.height)),l.width=Math.ceil(l.obj.width),l.height=Math.ceil(l.obj.height)),l.updateFlag=this.itemInfoVer,l.obj.setXY(m,b),p==s&&(o+=l.height),m+=l.width+this._columnGap,p%this._curLineItemCount==this._curLineItemCount-1&&(m=0,b+=l.height+this._lineGap),p++}for(u=0;u0&&this.numChildren>0&&this._container.y<=0&&this.getChildAt(0).y>-this._container.y},n.prototype.handleScroll2=function(e){var n=this._scrollPane.scrollingPosX,o=n+this._scrollPane.viewWidth,r=n==this._scrollPane.contentWidth;i=n;var s=this.getIndexOnPos2(e);if(n=i,s==this._firstIndex&&!e)return!1;var a=this._firstIndex;this._firstIndex=s;var h,l,c,u,_,p=s,d=a>s,g=this.numChildren,f=a+g-1,y=d?f:a,m=n,b=0,v=0,w=0,C=this.defaultItem,S=(this._scrollPane.viewHeight-this._lineGap*(this._curLineItemCount-1))/this._curLineItemCount;for(this.itemInfoVer++;p=a;_--)if((c=this._virtualItems[_]).obj&&c.updateFlag!=this.itemInfoVer&&c.obj.resourceURL==C){c.obj instanceof t.GButton&&(c.selected=c.obj.selected),l.obj=c.obj,c.obj=null,_==y&&y--;break}}else for(_=y;_<=f;_++)if((c=this._virtualItems[_]).obj&&c.updateFlag!=this.itemInfoVer&&c.obj.resourceURL==C){c.obj instanceof t.GButton&&(c.selected=c.obj.selected),l.obj=c.obj,c.obj=null,_==y&&y++;break}l.obj?this.setChildIndex(l.obj,d?p-s:this.numChildren):(l.obj=this._pool.getObject(C),d?this.addChildAt(l.obj,p-s):this.addChild(l.obj)),l.obj instanceof t.GButton&&(l.obj.selected=l.selected),h=!0}else h=e;h&&(this._autoResizeItem&&(this._layout==t.ListLayoutType.SingleRow||this._lineCount>0)&&l.obj.setSize(l.obj.width,S,!0),this.itemRenderer.call(this.callbackThisObj,p%this._numItems,l.obj),p%this._curLineItemCount==0&&(v+=Math.ceil(l.obj.width)-l.width,p==s&&a>s&&(w=Math.ceil(l.obj.width)-l.width)),l.width=Math.ceil(l.obj.width),l.height=Math.ceil(l.obj.height)),l.updateFlag=this.itemInfoVer,l.obj.setXY(m,b),p==s&&(o+=l.width),b+=l.height+this._lineGap,p%this._curLineItemCount==this._curLineItemCount-1&&(b=0,m+=l.width+this._columnGap),p++}for(u=0;u0&&this.numChildren>0&&this._container.x<=0&&this.getChildAt(0).x>-this._container.x},n.prototype.handleScroll3=function(e){var n=this._scrollPane.scrollingPosX;i=n;var o=this.getIndexOnPos3(e);if(n=i,o!=this._firstIndex||e){var r=this._firstIndex;this._firstIndex=o;var s,a,h,l,c,u,_=r,p=this._virtualItems.length,d=this._curLineItemCount*this._curLineItemCount2,g=o%this._curLineItemCount,f=this.viewWidth,y=Math.floor(o/d)*d,m=y+2*d,b=this._defaultItem,v=(this._scrollPane.viewWidth-this._columnGap*(this._curLineItemCount-1))/this._curLineItemCount,w=(this._scrollPane.viewHeight-this._lineGap*(this._curLineItemCount2-1))/this._curLineItemCount2;for(this.itemInfoVer++,a=y;a=this._realNumItems)){if(c=a%this._curLineItemCount,a-yg)continue;(h=this._virtualItems[a]).updateFlag=this.itemInfoVer}var C=0;for(a=y;a=this._realNumItems)&&(h=this._virtualItems[a]).updateFlag==this.itemInfoVer){if(null==h.obj){for(;_=this._realNumItems||((h=this._virtualItems[a]).updateFlag==this.itemInfoVer&&h.obj.setXY(x,T),h.height>I&&(I=h.height),a%this._curLineItemCount==this._curLineItemCount-1?(x=S,T+=I+this._lineGap,I=0,a==y+d-1&&(x=S+=f,T=0)):x+=h.width+this._columnGap);for(a=_;ar&&(r=i.width));if((h=o)<=d&&this._autoResizeItem&&this._scrollPane&&this._scrollPane._displayInDemand&&this._scrollPane.vtScrollBar)for(p+=this._scrollPane.vtScrollBar.width,e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(i.setSize(p,i.height,!0),i.width>r&&(r=i.width));a=Math.ceil(r)}else if(this._layout==t.ListLayoutType.SingleRow){for(e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(0!=n&&(n+=this._columnGap),i.x=n,this._autoResizeItem&&i.setSize(i.width,d,!0),n+=Math.ceil(i.width),i.height>s&&(s=i.height));if((a=n)<=p&&this._autoResizeItem&&this._scrollPane&&this._scrollPane._displayInDemand&&this._scrollPane.hzScrollBar)for(d+=this._scrollPane.hzScrollBar.height,e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(i.setSize(i.width,d,!0),i.height>s&&(s=i.height));h=Math.ceil(s)}else if(this._layout==t.ListLayoutType.FlowHorizontal)if(this._autoResizeItem&&this._columnCount>0){for(e=0;e<_;e++)if(i=this.getChildAt(e),(!this.foldInvisibleItems||i.visible)&&(g+=i.sourceWidth,++l==this._columnCount||e==_-1)){for(y=(p-g-(l-1)*this._columnGap)/g,n=0,l=f;l<=e;l++)i=this.getChildAt(l),this.foldInvisibleItems&&!i.visible||(i.setXY(n,o),ls&&(s=i.height));o+=Math.ceil(s)+this._lineGap,s=0,l=0,f=e+1,g=0}h=o+Math.ceil(s),a=p}else{for(e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(0!=n&&(n+=this._columnGap),(0!=this._columnCount&&l>=this._columnCount||0==this._columnCount&&n+i.width>p&&0!=s)&&(n=0,o+=Math.ceil(s)+this._lineGap,s=0,l=0),i.setXY(n,o),(n+=Math.ceil(i.width))>r&&(r=n),i.height>s&&(s=i.height),l++);h=o+Math.ceil(s),a=Math.ceil(r)}else if(this._layout==t.ListLayoutType.FlowVertical)if(this._autoResizeItem&&this._lineCount>0){for(e=0;e<_;e++)if(i=this.getChildAt(e),(!this.foldInvisibleItems||i.visible)&&(g+=i.sourceHeight,++l==this._lineCount||e==_-1)){for(y=(d-g-(l-1)*this._lineGap)/g,o=0,l=f;l<=e;l++)i=this.getChildAt(l),this.foldInvisibleItems&&!i.visible||(i.setXY(n,o),lr&&(r=i.width));n+=Math.ceil(r)+this._columnGap,r=0,l=0,f=e+1,g=0}a=n+Math.ceil(r),h=d}else{for(e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(0!=o&&(o+=this._lineGap),(0!=this._lineCount&&l>=this._lineCount||0==this._lineCount&&o+i.height>d&&0!=r)&&(o=0,n+=Math.ceil(r)+this._columnGap,r=0,l=0),i.setXY(n,o),(o+=Math.ceil(i.height))>s&&(s=o),i.width>r&&(r=i.width),l++);a=n+Math.ceil(r),h=Math.ceil(s)}else{var m;if(this._autoResizeItem&&this._lineCount>0&&(m=Math.floor((d-(this._lineCount-1)*this._lineGap)/this._lineCount)),this._autoResizeItem&&this._columnCount>0){for(e=0;e<_;e++)if(i=this.getChildAt(e),(!this.foldInvisibleItems||i.visible)&&(0==l&&(0!=this._lineCount&&u>=this._lineCount||0==this._lineCount&&o+(this._lineCount>0?m:i.height)>d)&&(c++,o=0,u=0),g+=i.sourceWidth,++l==this._columnCount||e==_-1)){for(y=(p-g-(l-1)*this._columnGap)/g,n=0,l=f;l<=e;l++)i=this.getChildAt(l),this.foldInvisibleItems&&!i.visible||(i.setXY(c*p+n,o),l0?m:i.height,!0),n+=Math.ceil(i.width)+this._columnGap):i.setSize(p-n,this._lineCount>0?m:i.height,!0),i.height>s&&(s=i.height));o+=Math.ceil(s)+this._lineGap,s=0,l=0,f=e+1,g=0,u++}}else for(e=0;e<_;e++)i=this.getChildAt(e),this.foldInvisibleItems&&!i.visible||(0!=n&&(n+=this._columnGap),this._autoResizeItem&&this._lineCount>0&&i.setSize(i.width,m,!0),(0!=this._columnCount&&l>=this._columnCount||0==this._columnCount&&n+i.width>p&&0!=s)&&(n=0,o+=Math.ceil(s)+this._lineGap,s=0,l=0,u++,(0!=this._lineCount&&u>=this._lineCount||0==this._lineCount&&o+i.height>d&&0!=r)&&(c++,o=0,u=0)),i.setXY(c*p+n,o),(n+=Math.ceil(i.width))>r&&(r=n),i.height>s&&(s=i.height),l++);h=c>0?d:o+Math.ceil(s),a=(c+1)*p}this.handleAlign(a,h),this.setBounds(0,0,a,h)}},n.prototype.setup_beforeAdd=function(i,n){e.prototype.setup_beforeAdd.call(this,i,n),i.seek(n,5),this._layout=i.readByte(),this._selectionMode=i.readByte(),this._align=i.readByte(),this._verticalAlign=i.readByte(),this._lineGap=i.readShort(),this._columnGap=i.readShort(),this._lineCount=i.readShort(),this._columnCount=i.readShort(),this._autoResizeItem=i.readBool(),this._childrenRenderOrder=i.readByte(),this._apexIndex=i.readShort(),i.readBool()&&(this._margin.top=i.readInt(),this._margin.bottom=i.readInt(),this._margin.left=i.readInt(),this._margin.right=i.readInt());var o=i.readByte();if(o==t.OverflowType.Scroll){var r=i.position;i.seek(n,7),this.setupScroll(i),i.position=r}else this.setupOverflow(o);i.readBool()&&i.skip(8),i.version>=2&&(this.scrollItemToViewOnClick=i.readBool(),this.foldInvisibleItems=i.readBool()),i.seek(n,8),this._defaultItem=i.readS(),this.readItems(i)},n.prototype.readItems=function(t){var e,i,n,o;for(e=t.readShort(),i=0;i=2)for(o=e.readShort(),r=0;rs?r=s:s=r:this._fill==t.LoaderFillType.ScaleNoBorder&&(r>s?s=r:r=s),this._shrinkOnly&&(r>1&&(r=1),s>1&&(s=1)),e=this.sourceWidth*r,i=this.sourceHeight*s)),this._content2?this._content2.setScale(r,s):(this._content.width=e,this._content.height=i),n=this._align==t.AlignType.Center?Math.floor((this.width-e)/2):this._align==t.AlignType.Right?this.width-e:0,o=this._verticalAlign==t.VertAlignType.Middle?Math.floor((this.height-i)/2):this._verticalAlign==t.VertAlignType.Bottom?this.height-i:0,this._content2?this._content2.setXY(n,o):(this._content.x=n,this._content.y=o)}}else this._autoSize&&(this._updatingLayout=!0,this.setSize(50,30),this._updatingLayout=!1)},i.prototype.clearContent=function(){this.clearErrorState(),!this._contentItem&&this._content.texture&&this.freeExternal(this._content.texture),this._content.texture=null,this._content.frames=null,this._content2&&(this._container.removeChild(this._content2.displayObject),this._content2.dispose(),this._content2=null),this._contentItem=null},i.prototype.handleSizeChanged=function(){e.prototype.handleSizeChanged.call(this),this._updatingLayout||this.updateLayout()},i.prototype.getProp=function(i){switch(i){case t.ObjectPropID.Color:return this.color;case t.ObjectPropID.Playing:return this.playing;case t.ObjectPropID.Frame:return this.frame;case t.ObjectPropID.TimeScale:return this._content.timeScale;default:return e.prototype.getProp.call(this,i)}},i.prototype.setProp=function(i,n){switch(i){case t.ObjectPropID.Color:this.color=n;break;case t.ObjectPropID.Playing:this.playing=n;break;case t.ObjectPropID.Frame:this.frame=n;break;case t.ObjectPropID.TimeScale:this._content.timeScale=n;break;case t.ObjectPropID.DeltaTime:this._content.advance(n);break;default:e.prototype.setProp.call(this,i,n)}},i.prototype.setup_beforeAdd=function(t,i){e.prototype.setup_beforeAdd.call(this,t,i),t.seek(i,5),this._url=t.readS(),this._align=t.readByte(),this._verticalAlign=t.readByte(),this._fill=t.readByte(),this._shrinkOnly=t.readBool(),this._autoSize=t.readBool(),this._showErrorSign=t.readBool(),this._content.playing=t.readBool(),this._content.frame=t.readInt(),t.readBool()&&(this.color=t.readColor()),this._content.fillMethod=t.readByte(),0!=this._content.fillMethod&&(this._content.fillOrigin=t.readByte(),this._content.fillClockwise=t.readBool(),this._content.fillAmount=t.readFloat()),this._url&&this.loadContent()},i._errorSignPool=new t.GObjectPool,i}(t.GObject);t.GLoader=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i._frame=0,i._playing=!0,i._url="",i._fill=t.LoaderFillType.None,i._align=t.AlignType.Left,i._verticalAlign=t.VertAlignType.Top,i._color=16777215,i}return __extends(i,e),i.prototype.createDisplayObject=function(){var e=new t.UIContainer;e.opaque=!0,this.setDisplayObject(e),this._container=new egret.DisplayObjectContainer,e.addChild(this._container)},i.prototype.dispose=function(){e.prototype.dispose.call(this)},Object.defineProperty(i.prototype,"url",{get:function(){return this._url},set:function(t){this._url!=t&&(this._url=t,this.loadContent(),this.updateGear(7))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._url},set:function(t){this.url=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"align",{get:function(){return this._align},set:function(t){this._align!=t&&(this._align=t,this.updateLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"verticalAlign",{get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!=t&&(this._verticalAlign=t,this.updateLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fill",{get:function(){return this._fill},set:function(t){this._fill!=t&&(this._fill=t,this.updateLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shrinkOnly",{get:function(){return this._shrinkOnly},set:function(t){this._shrinkOnly!=t&&(this._shrinkOnly=t,this.updateLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"autoSize",{get:function(){return this._autoSize},set:function(t){this._autoSize!=t&&(this._autoSize=t,this.updateLayout())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"playing",{get:function(){return this._playing},set:function(t){this._playing!=t&&(this._playing=t,this.updateGear(5),this.onChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frame",{get:function(){return this._frame},set:function(t){this._frame!=t&&(this._frame=t,this.updateGear(5),this.onChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationName",{get:function(){return this._animationName},set:function(t){this._animationName!=t&&(this._animationName=t,this.onChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skinName",{get:function(){return this._skinName},set:function(t){this._skinName!=t&&(this._skinName=t,this.onChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"loop",{get:function(){return this._loop},set:function(t){this._loop!=t&&(this._loop=t,this.onChange())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"color",{get:function(){return this._color},set:function(t){this._color!=t&&(this._color=t,this.updateGear(4),this._content&&(this._content.tint=t))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"content",{get:function(){},enumerable:!0,configurable:!0}),i.prototype.loadContent=function(){this.clearContent(),this._url&&(t.ToolSet.startsWith(this._url,"ui://")?this.loadFromPackage(this._url):this.loadExternal())},i.prototype.loadFromPackage=function(e){this._contentItem=t.UIPackage.getItemByURL(e),this._contentItem&&(this._contentItem=this._contentItem.getBranch(),this.sourceWidth=this._contentItem.width,this.sourceHeight=this._contentItem.height,this._contentItem=this._contentItem.getHighResolution(),this._autoSize&&this.setSize(this.sourceWidth,this.sourceHeight),this._contentItem.type!=t.PackageItemType.Spine&&this._contentItem.type!=t.PackageItemType.DragonBones||this._contentItem.owner.getItemAssetAsync(this._contentItem,this.onLoaded.bind(this)))},i.prototype.onLoaded=function(e,i){this._contentItem==i&&(e&&console.warn(e),this._contentItem.asset&&this._contentItem.type==t.PackageItemType.DragonBones&&this.setDragonBones(this._contentItem.armatureName,this._contentItem.asset.name,this._contentItem.atlasAsset.name,this._skinName,this._contentItem.skeletonAnchor))},i.prototype.setDragonBones=function(t,e,i,n,o){this.url=null;var r=dragonBones.EgretFactory.factory;this._content=r.buildArmatureDisplay(t,e,i,n),this._container.addChild(this._content),this._content.x=o.x,this._content.y=o.y,this._content.tint=this._color,this.onChangeDragonBones(),this.updateLayout()},i.prototype.onChange=function(){this.onChangeDragonBones()},i.prototype.onChangeDragonBones=function(){this._content instanceof dragonBones.EgretArmatureDisplay&&(this._animationName?this._playing?this._content.animation.play(this._animationName,this._loop?0:1):this._content.animation.gotoAndStopByFrame(this._animationName,this._frame):this._content.animation.reset())},i.prototype.loadExternal=function(){},i.prototype.updateLayout=function(){var e=this.sourceWidth,i=this.sourceHeight;if(this._autoSize&&(this._updatingLayout=!0,0==e&&(e=50),0==i&&(i=30),this.setSize(e,i),this._updatingLayout=!1,e==this._width&&i==this._height))return this._container.scaleX=this._container.scaleY=1,void(this._container.x=this._container.y=0);var n,o,r=1,s=1;this._fill!=t.LoaderFillType.None&&(r=this.width/this.sourceWidth,s=this.height/this.sourceHeight,1==r&&1==s||(this._fill==t.LoaderFillType.ScaleMatchHeight?r=s:this._fill==t.LoaderFillType.ScaleMatchWidth?s=r:this._fill==t.LoaderFillType.Scale?r>s?r=s:s=r:this._fill==t.LoaderFillType.ScaleNoBorder&&(r>s?s=r:r=s),this._shrinkOnly&&(r>1&&(r=1),s>1&&(s=1)),e=this.sourceWidth*r,i=this.sourceHeight*s)),this._container.scaleX=r,this._container.scaleY=s,n=this._align==t.AlignType.Center?Math.floor((this.width-e)/2):this._align==t.AlignType.Right?this.width-e:0,o=this._verticalAlign==t.VertAlignType.Middle?Math.floor((this.height-i)/2):this._verticalAlign==t.VertAlignType.Bottom?this.height-i:0,this._container.x=n,this._container.y=o},i.prototype.clearContent=function(){this._contentItem=null,this._content&&(this._container.removeChild(this._content),"dispose"in this._content&&this._content.dispose(),this._content=null)},i.prototype.handleSizeChanged=function(){e.prototype.handleSizeChanged.call(this),this._updatingLayout||this.updateLayout()},i.prototype.handleGrayedChanged=function(){},i.prototype.getProp=function(i){switch(i){case t.ObjectPropID.Color:return this.color;case t.ObjectPropID.Playing:return this.playing;case t.ObjectPropID.Frame:return this.frame;case t.ObjectPropID.TimeScale:return 1;default:return e.prototype.getProp.call(this,i)}},i.prototype.setProp=function(i,n){switch(i){case t.ObjectPropID.Color:this.color=n;break;case t.ObjectPropID.Playing:this.playing=n;break;case t.ObjectPropID.Frame:this.frame=n;break;case t.ObjectPropID.TimeScale:case t.ObjectPropID.DeltaTime:break;default:e.prototype.setProp.call(this,i,n)}},i.prototype.setup_beforeAdd=function(t,i){e.prototype.setup_beforeAdd.call(this,t,i),t.seek(i,5),this._url=t.readS(),this._align=t.readByte(),this._verticalAlign=t.readByte(),this._fill=t.readByte(),this._shrinkOnly=t.readBool(),this._autoSize=t.readBool(),this._animationName=t.readS(),this._skinName=t.readS(),this._playing=t.readBool(),this._frame=t.readInt(),this._loop=t.readBool(),t.readBool()&&(this.color=t.readColor()),this._url&&this.loadContent()},i}(t.GObject);t.GLoader3D=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){return e.call(this)||this}return __extends(i,e),Object.defineProperty(i.prototype,"color",{get:function(){return this._content.color},set:function(t){this._content.color!=t&&(this._content.color=t,this.updateGear(4))},enumerable:!0,configurable:!0}),i.prototype.createDisplayObject=function(){this._content=new t.MovieClip,this._content.touchEnabled=!1,this.setDisplayObject(this._content)},Object.defineProperty(i.prototype,"playing",{get:function(){return this._content.playing},set:function(t){this._content.playing!=t&&(this._content.playing=t,this.updateGear(5))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frame",{get:function(){return this._content.frame},set:function(t){this._content.frame!=t&&(this._content.frame=t,this.updateGear(5))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"timeScale",{get:function(){return this._content.timeScale},set:function(t){this._content.timeScale=t},enumerable:!0,configurable:!0}),i.prototype.rewind=function(){this._content.rewind()},i.prototype.syncStatus=function(t){this._content.syncStatus(t._content)},i.prototype.advance=function(t){this._content.advance(t)},i.prototype.setPlaySettings=function(t,e,i,n,o,r){this._content.setPlaySettings(t,e,i,n,o,r)},i.prototype.getProp=function(i){switch(i){case t.ObjectPropID.Color:return this.color;case t.ObjectPropID.Playing:return this.playing;case t.ObjectPropID.Frame:return this.frame;case t.ObjectPropID.TimeScale:return this.timeScale;default:return e.prototype.getProp.call(this,i)}},i.prototype.setProp=function(i,n){switch(i){case t.ObjectPropID.Color:this.color=n;break;case t.ObjectPropID.Playing:this.playing=n;break;case t.ObjectPropID.Frame:this.frame=n;break;case t.ObjectPropID.TimeScale:this.timeScale=n;break;case t.ObjectPropID.DeltaTime:this.advance(n);break;default:e.prototype.setProp.call(this,i,n)}},i.prototype.constructFromResource=function(){var t=this.packageItem.getBranch();this.sourceWidth=t.width,this.sourceHeight=t.height,this.initWidth=this.sourceWidth,this.initHeight=this.sourceHeight,this.setSize(this.sourceWidth,this.sourceHeight),(t=t.getHighResolution()).load(),this._content.interval=t.interval,this._content.swing=t.swing,this._content.repeatDelay=t.repeatDelay,this._content.frames=t.frames,this._content.smoothing=t.smoothing},i.prototype.setup_beforeAdd=function(t,i){e.prototype.setup_beforeAdd.call(this,t,i),t.seek(i,5),t.readBool()&&(this.color=t.readColor()),t.readByte(),this._content.frame=t.readInt(),this._content.playing=t.readBool()},i}(t.GObject);t.GMovieClip=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i._min=0,i._max=0,i._value=0,i._barMaxWidth=0,i._barMaxHeight=0,i._barMaxWidthDelta=0,i._barMaxHeightDelta=0,i._barStartX=0,i._barStartY=0,i._titleType=t.ProgressTitleType.Percent,i._value=50,i._max=100,i}return __extends(i,e),Object.defineProperty(i.prototype,"titleType",{get:function(){return this._titleType},set:function(t){this._titleType!=t&&(this._titleType=t,this.update(this._value))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"min",{get:function(){return this._min},set:function(t){this._min!=t&&(this._min=t,this.update(this._value))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"max",{get:function(){return this._max},set:function(t){this._max!=t&&(this._max=t,this.update(this._value))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"value",{get:function(){return this._value},set:function(e){this._value!=e&&(t.GTween.kill(this,!1,this.update),this._value=e,this.update(e))},enumerable:!0,configurable:!0}),i.prototype.tweenValue=function(e,i){var n,o=t.GTween.getTween(this,this.update);return o?(n=o.value.x,o.kill()):n=this._value,this._value=e,t.GTween.to(n,this._value,i).setTarget(this,this.update).setEase(t.EaseType.Linear)},i.prototype.update=function(e){var i=t.ToolSet.clamp01((e-this._min)/(this._max-this._min));if(this._titleObject)switch(this._titleType){case t.ProgressTitleType.Percent:this._titleObject.text=Math.floor(100*i)+"%";break;case t.ProgressTitleType.ValueAndMax:this._titleObject.text=Math.floor(e)+"/"+Math.floor(this._max);break;case t.ProgressTitleType.Value:this._titleObject.text=""+Math.floor(e);break;case t.ProgressTitleType.Max:this._titleObject.text=""+Math.floor(this._max)}var n=this.width-this._barMaxWidthDelta,o=this.height-this._barMaxHeightDelta;this._reverse?(this._barObjectH&&(this.setFillAmount(this._barObjectH,1-i)||(this._barObjectH.width=Math.round(n*i),this._barObjectH.x=this._barStartX+(n-this._barObjectH.width))),this._barObjectV&&(this.setFillAmount(this._barObjectV,1-i)||(this._barObjectV.height=Math.round(o*i),this._barObjectV.y=this._barStartY+(o-this._barObjectV.height)))):(this._barObjectH&&(this.setFillAmount(this._barObjectH,i)||(this._barObjectH.width=Math.round(n*i))),this._barObjectV&&(this.setFillAmount(this._barObjectV,i)||(this._barObjectV.height=Math.round(o*i)))),this._aniObject&&this._aniObject.setProp(t.ObjectPropID.Frame,Math.floor(100*i))},i.prototype.setFillAmount=function(e,i){return(e instanceof t.GImage||e instanceof t.GLoader)&&e.fillMethod!=t.FillMethod.None&&(e.fillAmount=i,!0)},i.prototype.constructExtension=function(t){t.seek(0,6),this._titleType=t.readByte(),this._reverse=t.readBool(),this._titleObject=this.getChild("title"),this._barObjectH=this.getChild("bar"),this._barObjectV=this.getChild("bar_v"),this._aniObject=this.getChild("ani"),this._barObjectH&&(this._barMaxWidth=this._barObjectH.width,this._barMaxWidthDelta=this.width-this._barMaxWidth,this._barStartX=this._barObjectH.x),this._barObjectV&&(this._barMaxHeight=this._barObjectV.height,this._barMaxHeightDelta=this.height-this._barMaxHeight,this._barStartY=this._barObjectV.y)},i.prototype.handleSizeChanged=function(){e.prototype.handleSizeChanged.call(this),this._barObjectH&&(this._barMaxWidth=this.width-this._barMaxWidthDelta),this._barObjectV&&(this._barMaxHeight=this.height-this._barMaxHeightDelta),this._underConstruct||this.update(this._value)},i.prototype.setup_afterAdd=function(t,i){e.prototype.setup_afterAdd.call(this,t,i),t.seek(i,6)&&t.readByte()==this.packageItem.objectType?(this._value=t.readInt(),this._max=t.readInt(),t.version>=2&&(this._min=t.readInt()),this.update(this._value)):this.update(this._value)},i}(t.GComponent);t.GProgressBar=e}(fgui||(fgui={})),function(t){var e=function(e){function s(){var i=e.call(this)||this;return i._fontSize=0,i._leading=0,i._letterSpacing=0,i._textWidth=0,i._textHeight=0,i._fontSize=12,i._align=t.AlignType.Left,i._verticalAlign=t.VertAlignType.Top,i._text="",i._leading=3,i._color=0,i._autoSize=t.AutoSizeType.Both,i._widthAutoSize=!0,i._heightAutoSize=!0,i}return __extends(s,e),s.prototype.createDisplayObject=function(){this._textField=new egret.TextField,this._textField.touchEnabled=!1,this.setDisplayObject(this._textField)},s.prototype.switchBitmapMode=function(t){t&&this.displayObject==this._textField?(null==this._bitmapContainer&&(this._bitmapContainer=new egret.Sprite),this.switchDisplayObject(this._bitmapContainer)):t||this.displayObject!=this._bitmapContainer||this.switchDisplayObject(this._textField)},s.prototype.dispose=function(){e.prototype.dispose.call(this),this._bitmapFont=null,this._requireRender=!1},Object.defineProperty(s.prototype,"text",{get:function(){return this._text},set:function(t){this._text=t,null==this._text&&(this._text=""),this.updateGear(6),this.parent&&this.parent._underConstruct?this.renderNow():this.render()},enumerable:!0,configurable:!0}),s.prototype.updateTextFieldText=function(){var e=this._text;if(this._templateVars&&(e=this.parseTemplate(e)),this._ubbEnabled){var i=s._htmlParser.parser(t.UBBParser.inst.parse(t.ToolSet.encodeHTML(e)));if(this._underline)for(var n=0;n0&&(this._textWidth+=4),this._textHeight=Math.ceil(this._textField.textHeight),this._textHeight>0&&(this._textHeight+=4);var e,i=0;this._widthAutoSize?(e=this._textWidth,this._textField.width=e):e=this.width,this._heightAutoSize?(i=this._textHeight,this._textField.height!=this._textHeight&&(this._textField.height=this._textHeight)):(i=this.height,this._textHeight>i&&(this._textHeight=i)),t&&(this._updatingSize=!0,this.setSize(e,i),this._updatingSize=!1)}},s.prototype.renderWithBitmapFont=function(e){this.switchBitmapMode(!0),this._bitmapPool||(this._bitmapPool=[]);for(var s=this._bitmapContainer.numChildren,a=0;a=65&&B<=90||B>=97&&B<=122?(0==m&&(b=p),m++):(m>0&&(v=p),m=0),32==B)f=Math.ceil(this._fontSize/2),y=this._fontSize;else{var L=this._bitmapFont.glyphs[k];L?(f=Math.ceil(L.advance*T),y=Math.ceil(L.lineHeight*T)):(f=0,y=0)}if(y>g&&(g=y),y>d&&(d=y),0!=p&&(p+=c),p+=f,!x||p<=_)C+=k;else{if((l=n()).height=d,l.textHeight=g,0==C.length)l.text=k;else if(m>0&&v>0){var A=(C+=k).length-m;l.text=t.ToolSet.trimRight(C.substr(0,A)),l.width=v,C=C.substr(A),p-=b}else l.text=C,l.width=p-(f+c),C=k,p=f,d=y,g=y;l.y=S,S+=l.height+u,l.width>this._textWidth&&(this._textWidth=l.width),m=0,b=0,v=0,this._lines.push(l)}}else C+=k,(l=n()).width=p,0==g&&(0==w&&(w=this._fontSize),0==d&&(d=w),g=d),l.height=d,w=d,l.textHeight=g,l.text=C,l.y=S,S+=l.height+u,l.width>this._textWidth&&(this._textWidth=l.width),this._lines.push(l),C="",p=0,d=0,g=0,m=0,b=0,v=0}C.length>0&&((l=n()).width=p,0==d&&(d=w),0==g&&(g=d),l.height=d,l.textHeight=g,l.text=C,l.y=S,l.width>this._textWidth&&(this._textWidth=l.width),this._lines.push(l)),this._textWidth>0&&(this._textWidth+=2*o),0==this._lines.length?this._textHeight=0:(l=this._lines[this._lines.length-1],this._textHeight=l.y+l.height+r);var z,E=0;if(z=this._widthAutoSize?0==this._textWidth?0:this._textWidth:this.width,E=this._heightAutoSize?0==this._textHeight?0:this._textHeight:this.height,e&&(this._updatingSize=!0,this.setSize(z,E),this._updatingSize=!1),0!=z&&0!=E){var M=o,F=0,R=0;_=this.width-2*o;var D=this._lines.length;for(a=0;a0&&92==t.charCodeAt(e-1))s+=t.substring(r,e-1),s+="{",r=e+1;else{if(s+=t.substring(r,e),r=e,-1==(e=t.indexOf("}",r)))break;e!=r+1?(-1!=(i=(n=t.substring(r+1,e)).indexOf("="))?s+=null==(o=this._templateVars[n.substring(0,i)])?n.substring(i+1):o:null!=(o=this._templateVars[n])&&(s+=o),r=e+1):(s+=t.substr(r,2),r=e+1)}return rthis.width?t.x=this.width-t.width:t.x+t.width<0&&(t.x=0),t.y>this.height?t.y=this.height-t.height:t.y+t.height<0&&(t.y=0),this.adjustModalLayer()},i.prototype.hideWindow=function(t){t.hide()},i.prototype.hideWindowImmediately=function(t){t.parent==this&&this.removeChild(t),this.adjustModalLayer()},i.prototype.bringToFront=function(e){var i,n=this.numChildren;for(i=null==this._modalLayer.parent||e.modal?n-1:this.getChildIndex(this._modalLayer)-1;i>=0;i--){var o=this.getChildAt(i);if(o==e)return;if(o instanceof t.Window)break}i>=0&&this.setChildIndex(e,i)},i.prototype.showModalWait=function(e){null!=t.UIConfig.globalModalWaiting&&(null==this._modalWaitPane&&(this._modalWaitPane=t.UIPackage.createObjectFromURL(t.UIConfig.globalModalWaiting)),this._modalWaitPane.setSize(this.width,this.height),this._modalWaitPane.addRelation(this,t.RelationType.Size),this.addChild(this._modalWaitPane),this._modalWaitPane.text=e)},i.prototype.closeModalWait=function(){null!=this._modalWaitPane&&null!=this._modalWaitPane.parent&&this.removeChild(this._modalWaitPane)},i.prototype.closeAllExceptModals=function(){for(var e=this._children.slice(),i=e.length,n=0;n=0;e--){var i=this.getChildAt(e);if(i instanceof t.Window)return i}return null},Object.defineProperty(i.prototype,"modalLayer",{get:function(){return this._modalLayer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasModalWindow",{get:function(){return null!=this._modalLayer.parent},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"modalWaiting",{get:function(){return this._modalWaitPane&&this._modalWaitPane.inContainer},enumerable:!0,configurable:!0}),i.prototype.showPopup=function(e,n,o){if(this._popupStack.length>0){var r=this._popupStack.indexOf(e);if(-1!=r)for(var s=this._popupStack.length-1;s>=r;s--)this.removeChild(this._popupStack.pop())}if(this._popupStack.push(e),n)for(var a=n;a;){if(a.parent==this){e.sortingOrderthis.width&&(l=l+u-e.width),c=h.y+_,((void 0===o||o===t.PopupDirection.Auto)&&h.y+e.height>this.height||!1===o||o===t.PopupDirection.Up)&&(c=h.y-e.height-1)<0&&(c=0,l+=u/2),e.x=l,e.y=c},i.prototype.togglePopup=function(t,e,i){-1==this._justClosedPopups.indexOf(t)&&this.showPopup(t,e,i)},i.prototype.hidePopup=function(t){if(t){var e=this._popupStack.indexOf(t);if(-1!=e)for(var i=this._popupStack.length-1;i>=e;i--)this.closePopup(this._popupStack.pop())}else{for(i=this._popupStack.length-1;i>=0;i--)this.closePopup(this._popupStack[i]);this._popupStack.length=0}},Object.defineProperty(i.prototype,"hasAnyPopup",{get:function(){return 0!=this._popupStack.length},enumerable:!0,configurable:!0}),i.prototype.closePopup=function(e){e.parent&&(e instanceof t.Window?e.hide():this.removeChild(e))},i.prototype.showTooltips=function(e){if(null==this._defaultTooltipWin){var i=t.UIConfig.tooltipsWin;if(!i)return void console.error("UIConfig.tooltipsWin not defined");this._defaultTooltipWin=t.UIPackage.createObjectFromURL(i)}this._defaultTooltipWin.text=e,this.showTooltipsWin(this._defaultTooltipWin)},i.prototype.showTooltipsWin=function(t,e){this.hideTooltips(),this._tooltipWin=t;var n=0,o=0;e?(n=e.x,o=e.y):(n=i.mouseX+10,o=i.mouseY+20);var r=this.globalToLocal(n,o);n=r.x,o=r.y,n+this._tooltipWin.width>this.width&&(n=n-this._tooltipWin.width-1)<0&&(n=10),o+this._tooltipWin.height>this.height&&(o=o-this._tooltipWin.height-1,n-this._tooltipWin.width-1>0&&(n=n-this._tooltipWin.width-1),o<0&&(o=10)),this._tooltipWin.x=n,this._tooltipWin.y=o,this.addChild(this._tooltipWin)},i.prototype.hideTooltips=function(){this._tooltipWin&&(this._tooltipWin.parent&&this.removeChild(this._tooltipWin),this._tooltipWin=null)},i.prototype.getObjectUnderPoint=function(e,i){var n=this._nativeStage.$hitTest(e,i);return n?t.ToolSet.displayObjectToGObject(n):null},Object.defineProperty(i.prototype,"focus",{get:function(){return null},set:function(t){},enumerable:!0,configurable:!0}),i.prototype.setFocus=function(t){},Object.defineProperty(i.prototype,"volumeScale",{get:function(){return this._volumeScale},set:function(t){this._volumeScale=t},enumerable:!0,configurable:!0}),i.prototype.playOneShotSound=function(t,e){e=e||1;var i=this._volumeScale*e;t.play(0,1).volume=i},i.prototype.adjustModalLayer=function(){var e=this.numChildren;this._modalWaitPane&&this._modalWaitPane.parent&&this.setChildIndex(this._modalWaitPane,e-1);for(var i=e-1;i>=0;i--){var n=this.getChildAt(i);if(n instanceof t.Window&&n.modal)return void(null==this._modalLayer.parent?this.addChildAt(this._modalLayer,i):this.setChildIndexBefore(this._modalLayer,i))}this._modalLayer.parent&&this.removeChild(this._modalLayer)},i.prototype.__addedToStage=function(e){this.displayObject.removeEventListener(egret.Event.ADDED_TO_STAGE,this.__addedToStage,this),this._nativeStage=this.displayObject.stage,this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__stageMouseDownCapture,this,!0),this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_END,this.__stageMouseUpCapture,this,!0),this._nativeStage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.__stageMouseMoveCapture,this,!0),this._modalLayer=new t.GGraph,this._modalLayer.setSize(this.width,this.height),this._modalLayer.drawRect(0,0,0,t.UIConfig.modalLayerColor,t.UIConfig.modalLayerAlpha),this._modalLayer.addRelation(this,t.RelationType.Size),this.displayObject.stage.addEventListener(egret.Event.RESIZE,this.__winResize,this),this.__winResize(null)},i.prototype.__stageMouseDownCapture=function(t){if(i.mouseX=t.stageX,i.mouseY=t.stageY,i.touchDown=!0,this._tooltipWin&&this.hideTooltips(),this._justClosedPopups.length=0,this._popupStack.length>0){for(var e=t.target;e!=this.displayObject.stage&&e;){if(e.$owner){var n=this._popupStack.indexOf(e.$owner);if(-1!=n){for(var o=this._popupStack.length-1;o>n;o--){var r=this._popupStack.pop();this.closePopup(r),this._justClosedPopups.push(r)}return}}e=e.parent}for(o=this._popupStack.length-1;o>=0;o--)r=this._popupStack[o],this.closePopup(r),this._justClosedPopups.push(r);this._popupStack.length=0}},i.prototype.__stageMouseMoveCapture=function(t){i.mouseX=t.stageX,i.mouseY=t.stageY},i.prototype.__stageMouseUpCapture=function(t){i.touchDown=!1},i.prototype.__winResize=function(t){this.setSize(this._nativeStage.stageWidth,this._nativeStage.stageHeight)},i.prototype.updateContentScaleLevel=function(){i.contentScaleLevel=0},i.contentScaleLevel=0,i.contentScaleFactor=1,i}(t.GComponent);t.GRoot=e}(fgui||(fgui={})),function(t){var e=function(t){function e(){var e=t.call(this)||this;return e._dragOffset=new egret.Point,e._scrollPerc=0,e}return __extends(e,t),e.prototype.setScrollPane=function(t,e){this._target=t,this._vertical=e},e.prototype.setDisplayPerc=function(t){this._vertical?(this._fixedGripSize||(this._grip.height=Math.floor(t*this._bar.height)),this._grip.y=this._bar.y+(this._bar.height-this._grip.height)*this._scrollPerc):(this._fixedGripSize||(this._grip.width=Math.floor(t*this._bar.width)),this._grip.x=this._bar.x+(this._bar.width-this._grip.width)*this._scrollPerc),this._grip.visible=0!=t&&1!=t},e.prototype.setScrollPerc=function(t){this._scrollPerc=t,this._vertical?this._grip.y=this._bar.y+(this._bar.height-this._grip.height)*this._scrollPerc:this._grip.x=this._bar.x+(this._bar.width-this._grip.width)*this._scrollPerc},Object.defineProperty(e.prototype,"minSize",{get:function(){return this._vertical?(this._arrowButton1?this._arrowButton1.height:0)+(this._arrowButton2?this._arrowButton2.height:0):(this._arrowButton1?this._arrowButton1.width:0)+(this._arrowButton2?this._arrowButton2.width:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gripDragging",{get:function(){return this._gripDragging},enumerable:!0,configurable:!0}),e.prototype.constructExtension=function(t){t.seek(0,6),this._fixedGripSize=t.readBool(),this._grip=this.getChild("grip"),this._grip?(this._bar=this.getChild("bar"),this._bar?(this._arrowButton1=this.getChild("arrow1"),this._arrowButton2=this.getChild("arrow2"),this._grip.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__gripMouseDown,this),this._arrowButton1&&this._arrowButton1.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__arrowButton1Click,this),this._arrowButton2&&this._arrowButton2.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__arrowButton2Click,this),this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__barMouseDown,this)):console.error("需要定义bar")):console.error("需要定义grip")},e.prototype.__gripMouseDown=function(t){this._gripDragging=!0,this._target.updateScrollBarVisible(),t.stopPropagation(),this.globalToLocal(t.stageX,t.stageY,this._dragOffset),this._dragOffset.x-=this._grip.x,this._dragOffset.y-=this._grip.y,this._grip.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.__gripMouseMove,this),this._grip.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.__gripMouseUp,this)},e.prototype.__gripMouseMove=function(t){if(this.onStage){var e=this.globalToLocal(t.stageX,t.stageY,i);if(this._vertical){var n=e.y-this._dragOffset.y;this._target.setPercY((n-this._bar.y)/(this._bar.height-this._grip.height),!1)}else{var o=e.x-this._dragOffset.x;this._target.setPercX((o-this._bar.x)/(this._bar.width-this._grip.width),!1)}}},e.prototype.__gripMouseUp=function(t){var e=t.currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.__gripMouseMove,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.__gripMouseUp,this),this.onStage||(this._gripDragging=!1,this._target.updateScrollBarVisible())},e.prototype.__arrowButton1Click=function(t){t.stopPropagation(),this._vertical?this._target.scrollUp():this._target.scrollLeft()},e.prototype.__arrowButton2Click=function(t){t.stopPropagation(),this._vertical?this._target.scrollDown():this._target.scrollRight()},e.prototype.__barMouseDown=function(t){var e=this._grip.globalToLocal(t.stageX,t.stageY,i);this._vertical?e.y<0?this._target.scrollUp(4):this._target.scrollDown(4):e.x<0?this._target.scrollLeft(4):this._target.scrollRight(4)},e}(t.GComponent);t.GScrollBar=e;var i=new egret.Point}(fgui||(fgui={})),function(t){var e=function(e){function n(){var i=e.call(this)||this;return i._min=0,i._max=0,i._value=0,i._barMaxWidth=0,i._barMaxHeight=0,i._barMaxWidthDelta=0,i._barMaxHeightDelta=0,i._clickPercent=0,i._barStartX=0,i._barStartY=0,i.changeOnClick=!0,i.canDrag=!0,i._titleType=t.ProgressTitleType.Percent,i._value=50,i._max=100,i._clickPos=new egret.Point,i}return __extends(n,e),Object.defineProperty(n.prototype,"titleType",{get:function(){return this._titleType},set:function(t){this._titleType=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"wholeNumbers",{get:function(){return this._wholeNumbers},set:function(t){this._wholeNumbers!=t&&(this._wholeNumbers=t,this.update())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"min",{get:function(){return this._min},set:function(t){this._min!=t&&(this._min=t,this.update())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"max",{get:function(){return this._max},set:function(t){this._max!=t&&(this._max=t,this.update())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this._value},set:function(t){this._value!=t&&(this._value=t,this.update())},enumerable:!0,configurable:!0}),n.prototype.update=function(){this.updateWithPercent((this._value-this._min)/(this._max-this._min))},n.prototype.updateWithPercent=function(e,i){if(e=t.ToolSet.clamp01(e),i){var n=t.ToolSet.clamp(this._min+(this._max-this._min)*e,this._min,this._max);this._wholeNumbers&&(n=Math.round(n),e=t.ToolSet.clamp01((n-this._min)/(this._max-this._min))),n!=this._value&&(this._value=n,this.dispatchEvent(new t.StateChangeEvent(t.StateChangeEvent.CHANGED)))}if(this._titleObject)switch(this._titleType){case t.ProgressTitleType.Percent:this._titleObject.text=Math.floor(100*e)+"%";break;case t.ProgressTitleType.ValueAndMax:this._titleObject.text=this._value+"/"+this._max;break;case t.ProgressTitleType.Value:this._titleObject.text=""+this._value;break;case t.ProgressTitleType.Max:this._titleObject.text=""+this._max}var o=this.width-this._barMaxWidthDelta,r=this.height-this._barMaxHeightDelta;this._reverse?(this._barObjectH&&(this._barObjectH.width=Math.round(o*e),this._barObjectH.x=this._barStartX+(o-this._barObjectH.width)),this._barObjectV&&(this._barObjectV.height=Math.round(r*e),this._barObjectV.y=this._barStartY+(r-this._barObjectV.height))):(this._barObjectH&&(this._barObjectH.width=Math.round(o*e)),this._barObjectV&&(this._barObjectV.height=Math.round(r*e)))},n.prototype.constructExtension=function(t){t.seek(0,6),this._titleType=t.readByte(),this._reverse=t.readBool(),t.version>=2&&(this._wholeNumbers=t.readBool(),this.changeOnClick=t.readBool()),this._titleObject=this.getChild("title"),this._barObjectH=this.getChild("bar"),this._barObjectV=this.getChild("bar_v"),this._gripObject=this.getChild("grip"),this._barObjectH&&(this._barMaxWidth=this._barObjectH.width,this._barMaxWidthDelta=this.width-this._barMaxWidth,this._barStartX=this._barObjectH.x),this._barObjectV&&(this._barMaxHeight=this._barObjectV.height,this._barMaxHeightDelta=this.height-this._barMaxHeight,this._barStartY=this._barObjectV.y),this._gripObject&&this._gripObject.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__gripMouseDown,this),this.displayObject.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.__barMouseDown,this)},n.prototype.handleSizeChanged=function(){e.prototype.handleSizeChanged.call(this),this._barObjectH&&(this._barMaxWidth=this.width-this._barMaxWidthDelta),this._barObjectV&&(this._barMaxHeight=this.height-this._barMaxHeightDelta),this._underConstruct||this.update()},n.prototype.setup_afterAdd=function(t,i){e.prototype.setup_afterAdd.call(this,t,i),t.seek(i,6)&&t.readByte()==this.packageItem.objectType?(this._value=t.readInt(),this._max=t.readInt(),t.version>=2&&(this._min=t.readInt()),this.update()):this.update()},n.prototype.__gripMouseDown=function(e){this.canDrag=!0,e.stopPropagation(),this._clickPos=this.globalToLocal(e.stageX,e.stageY),this._clickPercent=t.ToolSet.clamp01((this._value-this._min)/(this._max-this._min)),this._gripObject.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.__gripMouseMove,this),this._gripObject.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.__gripMouseUp,this)},n.prototype.__gripMouseMove=function(t){if(this.canDrag){var e,n=this.globalToLocal(t.stageX,t.stageY,i),o=n.x-this._clickPos.x,r=n.y-this._clickPos.y;this._reverse&&(o=-o,r=-r),e=this._barObjectH?this._clickPercent+o/this._barMaxWidth:this._clickPercent+r/this._barMaxHeight,this.updateWithPercent(e,!0)}},n.prototype.__gripMouseUp=function(t){t.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.__gripMouseMove,this),t.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END,this.__gripMouseUp,this)},n.prototype.__barMouseDown=function(e){if(this.changeOnClick){var n,o=this._gripObject.globalToLocal(e.stageX,e.stageY,i),r=t.ToolSet.clamp01((this._value-this._min)/(this._max-this._min));this._barObjectH&&(n=o.x/this._barMaxWidth),this._barObjectV&&(n=o.y/this._barMaxHeight),this._reverse?r-=n:r+=n,this.updateWithPercent(r,!0)}},n}(t.GComponent);t.GSlider=e;var i=new egret.Point}(fgui||(fgui={})),function(t){var e=function(e){function i(){var t=e.call(this)||this;return t._widthAutoSize=!1,t._heightAutoSize=!1,t.displayObject.touchChildren=!0,t._textField.type=egret.TextFieldType.INPUT,t._textField.addEventListener(egret.Event.CHANGE,t.__textChanged,t),t._textField.addEventListener(egret.FocusEvent.FOCUS_IN,t.__focusIn,t),t._textField.addEventListener(egret.FocusEvent.FOCUS_OUT,t.__focusOut,t),t}return __extends(i,e),i.prototype.dispose=function(){e.prototype.dispose.call(this)},Object.defineProperty(i.prototype,"editable",{get:function(){return this._textField.type==egret.TextFieldType.INPUT},set:function(t){this._textField.type=t?egret.TextFieldType.INPUT:egret.TextFieldType.DYNAMIC},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"maxLength",{get:function(){return this._textField.maxChars},set:function(t){this._textField.maxChars=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"promptText",{get:function(){return this._promptText},set:function(t){this._promptText=t,this.updateTextFieldText()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"restrict",{get:function(){return this._textField.restrict},set:function(t){this._textField.restrict=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"password",{get:function(){return this._password},set:function(t){this._password!=t&&(this._password=t,this._textField.displayAsPassword=this._password,this._textField.inputType=t?egret.TextFieldInputType.PASSWORD:egret.TextFieldInputType.TEXT,this.render())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"verticalAlign",{get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!=t&&(this._verticalAlign=t,this.updateVertAlign())},enumerable:!0,configurable:!0}),i.prototype.updateVertAlign=function(){switch(this._verticalAlign){case t.VertAlignType.Top:this._textField.verticalAlign=egret.VerticalAlign.TOP;break;case t.VertAlignType.Middle:this._textField.verticalAlign=egret.VerticalAlign.MIDDLE;break;case t.VertAlignType.Bottom:this._textField.verticalAlign=egret.VerticalAlign.BOTTOM}},i.prototype.updateTextFieldText=function(){!this._text&&this._promptText?(this._textField.displayAsPassword=!1,this._textField.textFlow=(new egret.HtmlTextParser).parser(t.UBBParser.inst.parse(this._promptText))):(this._textField.displayAsPassword=this._password,this._ubbEnabled?this._textField.textFlow=(new egret.HtmlTextParser).parser(t.UBBParser.inst.parse(t.ToolSet.encodeHTML(this._text))):this._textField.text=this._text)},i.prototype.handleSizeChanged=function(){this._updatingSize||(this._textField.width=Math.ceil(this.width),this._textField.height=Math.ceil(this.height))},i.prototype.setup_beforeAdd=function(t,i){e.prototype.setup_beforeAdd.call(this,t,i),t.seek(i,4);var n=t.readS();null!=n&&(this._promptText=n),null!=(n=t.readS())&&(this._textField.restrict=n);var o=t.readInt();0!=o&&(this._textField.maxChars=o),o=t.readInt(),t.readBool()&&(this.password=!0),this.updateVertAlign()},i.prototype.setup_afterAdd=function(i,n){e.prototype.setup_afterAdd.call(this,i,n),!this._text&&this._promptText&&(this._textField.displayAsPassword=!1,this._textField.textFlow=(new egret.HtmlTextParser).parser(t.UBBParser.inst.parse(t.ToolSet.encodeHTML(this._promptText))))},i.prototype.__textChanged=function(t){this._text=this._textField.text},i.prototype.__focusIn=function(t){!this._text&&this._promptText&&(this._textField.displayAsPassword=this._password,this._textField.text="")},i.prototype.__focusOut=function(e){this._text=this._textField.text,!this._text&&this._promptText&&(this._textField.displayAsPassword=!1,this._textField.textFlow=(new egret.HtmlTextParser).parser(t.UBBParser.inst.parse(t.ToolSet.encodeHTML(this._promptText))))},i}(t.GTextField);t.GTextInput=e}(fgui||(fgui={})),function(t){var e=function(e){function n(){var i=e.call(this)||this;return i._indent=15,i._rootNode=new t.GTreeNode(!0),i._rootNode._setTree(i),i._rootNode.expanded=!0,i}return __extends(n,e),Object.defineProperty(n.prototype,"rootNode",{get:function(){return this._rootNode},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"indent",{get:function(){return this._indent},set:function(t){this._indent=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"clickToExpand",{get:function(){return this._clickToExpand},set:function(t){this._clickToExpand=t},enumerable:!0,configurable:!0}),n.prototype.getSelectedNode=function(){return-1!=this.selectedIndex?this.getChildAt(this.selectedIndex)._treeNode:null},n.prototype.getSelectedNodes=function(t){t||(t=new Array),i.length=0,e.prototype.getSelection.call(this,i);for(var n=i.length,o=new Array,r=0;rl)a.addChild(c);else if(h=0&&e<=i){if(t._parent==this)this.setChildIndex(t,e);else t._parent&&t._parent.removeChild(t),e==this._children.length?this._children.push(t):this._children.splice(e,0,t),t._parent=this,t._level=this._level+1,t._setTree(this._tree),(this._tree&&this==this._tree.rootNode||this._cell&&this._cell.parent&&this._expanded)&&this._tree._afterInserted(t);return t}throw new RangeError("Invalid child index")},t.prototype.removeChild=function(t){var e=this._children.indexOf(t);return-1!=e&&this.removeChildAt(e),t},t.prototype.removeChildAt=function(t){if(t>=0&&t=this.numChildren)&&(e=this.numChildren-1);for(var i=t;i<=e;++i)this.removeChildAt(t)},t.prototype.getChildAt=function(t){if(t>=0&&t=this._parent._children.length-1?null:this._parent._children[t+1]},t.prototype.setChildIndex=function(t,e){var i=this._children.indexOf(t);if(-1==i)throw"Not a child of this container";var n=this._children.length;e<0?e=0:e>n&&(e=n),i!=e&&(this._children.splice(i,1),this._children.splice(e,0,t),(this._tree&&this==this._tree.rootNode||this._cell&&this._cell.parent&&this._expanded)&&this._tree._afterMoved(t))},t.prototype.swapChildren=function(t,e){var i=this._children.indexOf(t),n=this._children.indexOf(e);if(-1==i||-1==n)throw"Not a child of this container";this.swapChildrenAt(i,n)},t.prototype.swapChildrenAt=function(t,e){var i=this._children[t],n=this._children[e];this.setChildIndex(i,e),this.setChildIndex(n,t)},Object.defineProperty(t.prototype,"numChildren",{get:function(){return this._children.length},enumerable:!0,configurable:!0}),t.prototype.expandToRoot=function(){for(var t=this;t;)t.expanded=!0,t=t.parent},Object.defineProperty(t.prototype,"tree",{get:function(){return this._tree},enumerable:!0,configurable:!0}),t.prototype._setTree=function(t){if(this._tree=t,this._tree&&this._tree.treeNodeWillExpand&&this._expanded&&this._tree.treeNodeWillExpand(this,!0),this._children)for(var e=this._children.length,i=0;i=this._data.pixelWidth)return!1;var i=e*this._data.pixelWidth+t,n=Math.floor(i/8),o=i%8;return n>=0&&n>o&1)},t}();t.PixelHitTest=e;var i=function(){function t(){}return t.prototype.load=function(t){t.readInt(),this.pixelWidth=t.readInt(),this.scale=1/t.readByte();var e=t.readInt();this.pixels=[];for(var i=0;i0){var e=this.highResolution[t.GRoot.contentScaleLevel-1];if(e)return this.owner.getItemById(e)}return this},e.prototype.toString=function(){return this.name},e}();t.PackageItem=e}(fgui||(fgui={})),function(t){var e=function(){function e(e){if(!e&&!(e=t.UIConfig.popupMenu))throw"UIConfig.popupMenu not defined";this._contentPane=t.UIPackage.createObjectFromURL(e).asCom,this._contentPane.addEventListener(egret.Event.ADDED_TO_STAGE,this.__addedToStage,this),this._list=this._contentPane.getChild("list"),this._list.removeChildrenToPool(),this._list.addRelation(this._contentPane,t.RelationType.Width),this._list.removeRelation(this._contentPane,t.RelationType.Height),this._contentPane.addRelation(this._list,t.RelationType.Height),this._list.addEventListener(t.ItemEvent.CLICK,this.__clickItem,this)}return e.prototype.dispose=function(){this._contentPane.dispose()},e.prototype.addItem=function(t,e){var i=this._list.addItemFromPool().asButton;i.title=t,i.data=e,i.grayed=!1;var n=i.getController("checked");return n&&(n.selectedIndex=0),i},e.prototype.addItemAt=function(t,e,i){var n=this._list.getFromPool().asButton;this._list.addChildAt(n,e),n.title=t,n.data=i,n.grayed=!1;var o=n.getController("checked");return o&&(o.selectedIndex=0),n},e.prototype.addSeperator=function(){if(null==t.UIConfig.popupMenu_seperator)throw"UIConfig.popupMenu_seperator not defined";this.list.addItemFromPool(t.UIConfig.popupMenu_seperator)},e.prototype.getItemName=function(t){return this._list.getChildAt(t).name},e.prototype.setItemText=function(t,e){this._list.getChild(t).asButton.title=e},e.prototype.setItemVisible=function(t,e){var i=this._list.getChild(t).asButton;i.visible!=e&&(i.visible=e,this._list.setBoundsChangedFlag())},e.prototype.setItemGrayed=function(t,e){this._list.getChild(t).asButton.grayed=e},e.prototype.setItemCheckable=function(t,e){var i=this._list.getChild(t).asButton.getController("checked");i&&(e?0==i.selectedIndex&&(i.selectedIndex=1):i.selectedIndex=0)},e.prototype.setItemChecked=function(t,e){var i=this._list.getChild(t).asButton.getController("checked");i&&(i.selectedIndex=e?2:1)},e.prototype.isItemChecked=function(t){var e=this._list.getChild(t).asButton.getController("checked");return!!e&&2==e.selectedIndex},e.prototype.removeItem=function(t){var e=this._list.getChild(t);if(e){var i=this._list.getChildIndex(e);return this._list.removeChildToPoolAt(i),!0}return!1},e.prototype.clearItems=function(){this._list.removeChildrenToPool()},Object.defineProperty(e.prototype,"itemCount",{get:function(){return this._list.numChildren},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contentPane",{get:function(){return this._contentPane},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"list",{get:function(){return this._list},enumerable:!0,configurable:!0}),e.prototype.show=function(e,i){(e?e.root:t.GRoot.inst).showPopup(this.contentPane,e instanceof t.GRoot?null:e,i)},e.prototype.__clickItem=function(e){t.GTimers.inst.add(100,1,this.__clickItem2,this,e)},e.prototype.__clickItem2=function(t){var e=t.itemObject.asButton;if(null!=e)if(e.grayed)this._list.selectedIndex=-1;else{var i=e.getController("checked");i&&0!=i.selectedIndex&&(1==i.selectedIndex?i.selectedIndex=2:i.selectedIndex=1),this._contentPane.parent.hidePopup(this.contentPane),null!=e.data&&(1==e.data.length?e.data(t):e.data())}},e.prototype.__addedToStage=function(t){this._list.selectedIndex=-1,this._list.resizeToFit(1e5,10)},e}();t.PopupMenu=e}(fgui||(fgui={})),function(t){var e=function(){function e(t){this._owner=t,this._defs=new Array}return Object.defineProperty(e.prototype,"owner",{get:function(){return this._owner},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(t){this._target!=t&&(this._target&&this.releaseRefTarget(this._target),this._target=t,this._target&&this.addRefTarget(this._target))},enumerable:!0,configurable:!0}),e.prototype.add=function(e,i){if(e==t.RelationType.Size)return this.add(t.RelationType.Width,i),void this.add(t.RelationType.Height,i);for(var n=this._defs.length,o=0;o=t.RelationType.LeftExt_Left&&e<=t.RelationType.RightExt_Right?0:1,this._defs.push(o),(n||e==t.RelationType.Left_Center||e==t.RelationType.Center_Center||e==t.RelationType.Right_Center||e==t.RelationType.Top_Middle||e==t.RelationType.Middle_Middle||e==t.RelationType.Bottom_Middle)&&(this._owner.pixelSnapping=!0)},e.prototype.remove=function(e){if(void 0===e&&(e=0),e==t.RelationType.Size)return this.remove(t.RelationType.Width),void this.remove(t.RelationType.Height);for(var i=this._defs.length,n=0;n0)for(a=0;a0)for(s=0;s0)for(s=0;s.5*this._pageSize.x&&t++,t},set:function(t){this.setCurrentPageX(t,!1)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"currentPageY",{get:function(){if(!this._pageMode)return 0;var t=Math.floor(this._yPos/this._pageSize.y);return this._yPos-t*this._pageSize.y>.5*this._pageSize.y&&t++,t},set:function(t){this.setCurrentPageY(t,!1)},enumerable:!0,configurable:!0}),c.prototype.setCurrentPageX=function(t,e){this._pageMode&&(this._owner.ensureBoundsCorrect(),this._overlapSize.x>0&&this.setPosX(t*this._pageSize.x,e))},c.prototype.setCurrentPageY=function(t,e){this._pageMode&&(this._owner.ensureBoundsCorrect(),this._overlapSize.y>0&&this.setPosY(t*this._pageSize.y,e))},Object.defineProperty(c.prototype,"isBottomMost",{get:function(){return this._yPos==this._overlapSize.y||0==this._overlapSize.y},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"isRightMost",{get:function(){return this._xPos==this._overlapSize.x||0==this._overlapSize.x},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"pageController",{get:function(){return this._pageController},set:function(t){this._pageController=t},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scrollingPosX",{get:function(){return t.ToolSet.clamp(-this._container.x,0,this._overlapSize.x)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scrollingPosY",{get:function(){return t.ToolSet.clamp(-this._container.y,0,this._overlapSize.y)},enumerable:!0,configurable:!0}),c.prototype.scrollTop=function(t){this.setPercY(0,t)},c.prototype.scrollBottom=function(t){this.setPercY(1,t)},c.prototype.scrollUp=function(t,e){t=t||1,this._pageMode?this.setPosY(this._yPos-this._pageSize.y*t,e):this.setPosY(this._yPos-this._scrollStep*t,e)},c.prototype.scrollDown=function(t,e){t=t||1,this._pageMode?this.setPosY(this._yPos+this._pageSize.y*t,e):this.setPosY(this._yPos+this._scrollStep*t,e)},c.prototype.scrollLeft=function(t,e){t=t||1,this._pageMode?this.setPosX(this._xPos-this._pageSize.x*t,e):this.setPosX(this._xPos-this._scrollStep*t,e)},c.prototype.scrollRight=function(t,e){t=t||1,this._pageMode?this.setPosX(this._xPos+this._pageSize.x*t,e):this.setPosX(this._xPos+this._scrollStep*t,e)},c.prototype.scrollToView=function(e,i,n){var o;if(this._owner.ensureBoundsCorrect(),this._needRefresh&&this.refresh(),e instanceof t.GObject?e.parent!=this._owner?(e.parent.localToGlobalRect(e.x,e.y,e.width,e.height,a),o=this._owner.globalToLocalRect(a.x,a.y,a.width,a.height,a)):(o=a).setTo(e.x,e.y,e.width,e.height):o=e,this._overlapSize.y>0){var r=this._yPos+this._viewSize.y;n||o.y<=this._yPos||o.height>=this._viewSize.y?this._pageMode?this.setPosY(Math.floor(o.y/this._pageSize.y)*this._pageSize.y,i):this.setPosY(o.y,i):o.y+o.height>r&&(this._pageMode?this.setPosY(Math.floor(o.y/this._pageSize.y)*this._pageSize.y,i):o.height<=this._viewSize.y/2?this.setPosY(o.y+2*o.height-this._viewSize.y,i):this.setPosY(o.y+o.height-this._viewSize.y,i))}if(this._overlapSize.x>0){var s=this._xPos+this._viewSize.x;n||o.x<=this._xPos||o.width>=this._viewSize.x?this._pageMode?this.setPosX(Math.floor(o.x/this._pageSize.x)*this._pageSize.x,i):this.setPosX(o.x,i):o.x+o.width>s&&(this._pageMode?this.setPosX(Math.floor(o.x/this._pageSize.x)*this._pageSize.x,i):o.width<=this._viewSize.x/2?this.setPosX(o.x+2*o.width-this._viewSize.x,i):this.setPosX(o.x+o.width-this._viewSize.x,i))}!i&&this._needRefresh&&this.refresh()},c.prototype.isChildInView=function(t){if(this._overlapSize.y>0){var e=t.y+this._container.y;if(e<-t.height||e>this._viewSize.y)return!1}return!(this._overlapSize.x>0&&((e=t.x+this._container.x)<-t.width||e>this._viewSize.x))},c.prototype.cancelDragging=function(){this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.__touchMove,this),this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_END,this.__touchEnd,this),this._owner.displayObject.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.__touchTap,this),c.draggingPane==this&&(c.draggingPane=null),i=0,this._dragged=!1,this._maskContainer.touchChildren=!0},c.prototype.lockHeader=function(t){this._headerLockedSize!=t&&(this._headerLockedSize=t,!this._refreshEventDispatching&&this._container[this._refreshBarAxis]>=0&&(this._tweenStart.setTo(this._container.x,this._container.y),this._tweenChange.setTo(0,0),this._tweenChange[this._refreshBarAxis]=this._headerLockedSize-this._tweenStart[this._refreshBarAxis],this._tweenDuration.setTo(o,o),this.startTween(2)))},c.prototype.lockFooter=function(t){if(this._footerLockedSize!=t&&(this._footerLockedSize=t,!this._refreshEventDispatching&&this._container[this._refreshBarAxis]<=-this._overlapSize[this._refreshBarAxis])){this._tweenStart.setTo(this._container.x,this._container.y),this._tweenChange.setTo(0,0);var e=this._overlapSize[this._refreshBarAxis];0==e?e=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0):e+=this._footerLockedSize,this._tweenChange[this._refreshBarAxis]=-e-this._tweenStart[this._refreshBarAxis],this._tweenDuration.setTo(o,o),this.startTween(2)}},c.prototype.onOwnerSizeChanged=function(){this.setSize(this._owner.width,this._owner.height),this.posChanged(!1)},c.prototype.handleControllerChanged=function(e){this._pageController==e&&(this._scrollType==t.ScrollType.Horizontal?this.setCurrentPageX(e.selectedIndex,!0):this.setCurrentPageY(e.selectedIndex,!0))},c.prototype.updatePageController=function(){var e;if(this._pageController&&!this._pageController.changing&&(e=this._scrollType==t.ScrollType.Horizontal?this.currentPageX:this.currentPageY)0?t=-Math.floor(this._xPos):(0!=this._container.x&&(this._container.x=0),t=0),this._overlapSize.y>0?e=-Math.floor(this._yPos):(0!=this._container.y&&(this._container.y=0),e=0),t!=this._container.x||e!=this._container.y?(this._tweenDuration.setTo(n,n),this._tweenStart.setTo(this._container.x,this._container.y),this._tweenChange.setTo(t-this._tweenStart.x,e-this._tweenStart.y),this.startTween(1)):0!=this._tweening&&this.killTween());this._pageMode&&this.updatePageController()},c.prototype.__touchBegin=function(t){if(this._touchEffect){0!=this._tweening?(this.killTween(),this._dragged=!0):this._dragged=!1;var e=this._owner.globalToLocal(t.stageX,t.stageY,s);this._containerPos.setTo(this._container.x,this._container.y),this._beginTouchPos.setTo(e.x,e.y),this._lastTouchPos.setTo(e.x,e.y),this._lastTouchGlobalPos.setTo(t.stageX,t.stageY),this._isHoldAreaDone=!1,this._velocity.setTo(0,0),this._velocityScale=1,this._lastMoveTime=egret.getTimer()/1e3,this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.__touchMove,this),this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.__touchEnd,this),this._owner.displayObject.stage.addEventListener(egret.TouchEvent.TOUCH_TAP,this.__touchTap,this)}},c.prototype.__touchMove=function(e){if(null!=this._owner.displayObject.stage&&this._touchEffect&&!(c.draggingPane&&c.draggingPane!=this||t.GObject.draggingObject)){var n,o,a,h=this._owner.globalToLocal(e.stageX,e.stageY,s),l=t.UIConfig.touchScrollSensitivity;if(this._scrollType==t.ScrollType.Vertical){if(!this._isHoldAreaDone){if(i|=1,(n=Math.abs(this._beginTouchPos.y-h.y))0?this._bouncebackEffect?this._header&&0!=this._header.maxHeight?this._container.y=Math.floor(Math.min(.5*_,this._header.maxHeight)):this._container.y=Math.floor(Math.min(.5*_,this._viewSize.y*r)):this._container.y=0:_<-this._overlapSize.y?this._bouncebackEffect?this._footer&&this._footer.maxHeight>0?this._container.y=Math.floor(Math.max(.5*(_+this._overlapSize.y),-this._footer.maxHeight)-this._overlapSize.y):this._container.y=Math.floor(Math.max(.5*(_+this._overlapSize.y),-this._viewSize.y*r)-this._overlapSize.y):this._container.y=-this._overlapSize.y:this._container.y=_),a&&(u>0?this._bouncebackEffect?this._header&&0!=this._header.maxWidth?this._container.x=Math.floor(Math.min(.5*u,this._header.maxWidth)):this._container.x=Math.floor(Math.min(.5*u,this._viewSize.x*r)):this._container.x=0:u<0-this._overlapSize.x?this._bouncebackEffect?this._footer&&this._footer.maxWidth>0?this._container.x=Math.floor(Math.max(.5*(u+this._overlapSize.x),-this._footer.maxWidth)-this._overlapSize.x):this._container.x=Math.floor(Math.max(.5*(u+this._overlapSize.x),-this._viewSize.x*r)-this._overlapSize.x):this._container.x=-this._overlapSize.x:this._container.x=u);var p=egret.getTimer()/1e3,d=Math.max(p-this._lastMoveTime,1/60),g=h.x-this._lastTouchPos.x,f=h.y-this._lastTouchPos.y;if(a||(g=0),o||(f=0),0!=d){var y=this._owner.displayObject.stage.frameRate,m=d*y-1;if(m>1){var b=Math.pow(.833,m);this._velocity.x=this._velocity.x*b,this._velocity.y=this._velocity.y*b}this._velocity.x=t.ToolSet.lerp(this._velocity.x,60*g/y/d,10*d),this._velocity.y=t.ToolSet.lerp(this._velocity.y,60*f/y/d,10*d)}var v=this._lastTouchGlobalPos.x-e.stageX,w=this._lastTouchGlobalPos.y-e.stageY;0!=g?this._velocityScale=Math.abs(v/g):0!=f&&(this._velocityScale=Math.abs(w/f)),this._lastTouchPos.setTo(h.x,h.y),this._lastTouchGlobalPos.setTo(e.stageX,e.stageY),this._lastMoveTime=p,this._overlapSize.x>0&&(this._xPos=t.ToolSet.clamp(-this._container.x,0,this._overlapSize.x)),this._overlapSize.y>0&&(this._yPos=t.ToolSet.clamp(-this._container.y,0,this._overlapSize.y)),0!=this._loop&&(u=this._container.x,_=this._container.y,this.loopCheckingCurrent()&&(this._containerPos.x+=this._container.x-u,this._containerPos.y+=this._container.y-_)),c.draggingPane=this,this._isHoldAreaDone=!0,this._dragged=!0,this._maskContainer.touchChildren=!1,this.updateScrollBarPos(),this.updateScrollBarVisible(),this._pageMode&&this.updatePageController(),this.dispatchEventWith(c.SCROLL)}},c.prototype.__touchEnd=function(e){if(e.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.__touchMove,this),e.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END,this.__touchEnd,this),e.currentTarget.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.__touchTap,this),c.draggingPane==this&&(c.draggingPane=null),i=0,!this._dragged||!this._touchEffect||null==this._owner.displayObject.stage)return this._dragged=!1,void(this._maskContainer.touchChildren=!0);this._dragged=!1,this._maskContainer.touchChildren=!0,this._tweenStart.setTo(this._container.x,this._container.y),h.setTo(this._tweenStart.x,this._tweenStart.y);var n=!1;if(this._container.x>0?(h.x=0,n=!0):this._container.x<-this._overlapSize.x&&(h.x=-this._overlapSize.x,n=!0),this._container.y>0?(h.y=0,n=!0):this._container.y<-this._overlapSize.y&&(h.y=-this._overlapSize.y,n=!0),n){if(this._tweenChange.setTo(h.x-this._tweenStart.x,h.y-this._tweenStart.y),this._tweenChange.x<-t.UIConfig.touchDragSensitivity||this._tweenChange.y<-t.UIConfig.touchDragSensitivity?(this._refreshEventDispatching=!0,this.dispatchEventWith(c.PULL_DOWN_RELEASE),this._refreshEventDispatching=!1):(this._tweenChange.x>t.UIConfig.touchDragSensitivity||this._tweenChange.y>t.UIConfig.touchDragSensitivity)&&(this._refreshEventDispatching=!0,this.dispatchEventWith(c.PULL_UP_RELEASE),this._refreshEventDispatching=!1),this._headerLockedSize>0&&0==h[this._refreshBarAxis])h[this._refreshBarAxis]=this._headerLockedSize,this._tweenChange.x=h.x-this._tweenStart.x,this._tweenChange.y=h.y-this._tweenStart.y;else if(this._footerLockedSize>0&&h[this._refreshBarAxis]==-this._overlapSize[this._refreshBarAxis]){var r=this._overlapSize[this._refreshBarAxis];0==r?r=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0):r+=this._footerLockedSize,h[this._refreshBarAxis]=-r,this._tweenChange.x=h.x-this._tweenStart.x,this._tweenChange.y=h.y-this._tweenStart.y}this._tweenDuration.setTo(o,o)}else{if(this._inertiaDisabled)this._tweenDuration.setTo(o,o);else{var s=this._owner.displayObject.stage.frameRate,a=(egret.getTimer()/1e3-this._lastMoveTime)*s-1;if(a>1){var u=Math.pow(.833,a);this._velocity.x=this._velocity.x*u,this._velocity.y=this._velocity.y*u}this.updateTargetAndDuration(this._tweenStart,h)}if(l.setTo(h.x-this._tweenStart.x,h.y-this._tweenStart.y),this.loopCheckingTarget(h),(this._pageMode||this._snapToItem)&&this.alignPosition(h,!0),this._tweenChange.x=h.x-this._tweenStart.x,this._tweenChange.y=h.y-this._tweenStart.y,0==this._tweenChange.x&&0==this._tweenChange.y)return void this.updateScrollBarVisible();(this._pageMode||this._snapToItem)&&(this.fixDuration("x",l.x),this.fixDuration("y",l.y))}this.startTween(2)},c.prototype.__touchTap=function(t){this._dragged=!1},c.prototype.updateScrollBarPos=function(){this._vtScrollBar&&this._vtScrollBar.setScrollPerc(0==this._overlapSize.y?0:t.ToolSet.clamp(-this._container.y,0,this._overlapSize.y)/this._overlapSize.y),this._hzScrollBar&&this._hzScrollBar.setScrollPerc(0==this._overlapSize.x?0:t.ToolSet.clamp(-this._container.x,0,this._overlapSize.x)/this._overlapSize.x),this.checkRefreshBar()},c.prototype.updateScrollBarVisible=function(){this._vtScrollBar&&(this._viewSize.y<=this._vtScrollBar.minSize||this._vScrollNone?this._vtScrollBar.displayObject.visible=!1:this.updateScrollBarVisible2(this._vtScrollBar)),this._hzScrollBar&&(this._viewSize.x<=this._hzScrollBar.minSize||this._hScrollNone?this._hzScrollBar.displayObject.visible=!1:this.updateScrollBarVisible2(this._hzScrollBar))},c.prototype.updateScrollBarVisible2=function(e){this._scrollBarDisplayAuto&&t.GTween.kill(e,!1,"alpha"),!this._scrollBarDisplayAuto||0!=this._tweening||this._dragged||e.gripDragging?(e.alpha=1,e.displayObject.visible=!0):e.displayObject.visible&&t.GTween.to(1,0,.5).setDelay(.5).onComplete(this.__barTweenComplete,this).setTarget(e,"alpha")},c.prototype.__barTweenComplete=function(t){var e=t.target;e.alpha=1,e.displayObject.visible=!1},c.prototype.getLoopPartSize=function(t,e){return(this._contentSize[e]+("x"==e?this._owner.columnGap:this._owner.lineGap))/t},c.prototype.loopCheckingCurrent=function(){var t=!1;return 1==this._loop&&this._overlapSize.x>0?this._xPos<.001?(this._xPos+=this.getLoopPartSize(2,"x"),t=!0):this._xPos>=this._overlapSize.x&&(this._xPos-=this.getLoopPartSize(2,"x"),t=!0):2==this._loop&&this._overlapSize.y>0&&(this._yPos<.001?(this._yPos+=this.getLoopPartSize(2,"y"),t=!0):this._yPos>=this._overlapSize.y&&(this._yPos-=this.getLoopPartSize(2,"y"),t=!0)),t&&(this._container.x=Math.floor(-this._xPos),this._container.y=Math.floor(-this._yPos)),t},c.prototype.loopCheckingTarget=function(t){1==this._loop&&this.loopCheckingTarget2(t,"x"),2==this._loop&&this.loopCheckingTarget2(t,"y")},c.prototype.loopCheckingTarget2=function(t,e){var i,n;t[e]>0?(i=this.getLoopPartSize(2,e),(n=this._tweenStart[e]-i)<=0&&n>=-this._overlapSize[e]&&(t[e]-=i,this._tweenStart[e]=n)):t[e]<-this._overlapSize[e]&&(i=this.getLoopPartSize(2,e),(n=this._tweenStart[e]+i)<=0&&n>=-this._overlapSize[e]&&(t[e]+=i,this._tweenStart[e]=n))},c.prototype.loopCheckingNewPos=function(e,i){if(0==this._overlapSize[i])return e;var n,o="x"==i?this._xPos:this._yPos,r=!1;return e<.001?(e+=this.getLoopPartSize(2,i))>o&&(n=this.getLoopPartSize(6,i),n=Math.ceil((e-o)/n)*n,o=t.ToolSet.clamp(o+n,0,this._overlapSize[i]),r=!0):e>=this._overlapSize[i]&&(e-=this.getLoopPartSize(2,i))-this._overlapSize.x&&(t.x=-i.x),t.y<0&&t.y>-this._overlapSize.y&&(t.y=-i.y)}},c.prototype.alignByPage=function(t,e,i){var n;if(t>0)n=0;else if(t<-this._overlapSize[e])n=Math.ceil(this._contentSize[e]/this._pageSize[e])-1;else{n=Math.floor(-t/this._pageSize[e]);var o=i?t-this._containerPos[e]:t-this._container[e],r=Math.min(this._pageSize[e],this._contentSize[e]-(n+1)*this._pageSize[e]),s=-t-n*this._pageSize[e];Math.abs(o)>this._pageSize[e]?s>.5*r&&n++:s>r*(o<0?.3:.7)&&n++,(t=-n*this._pageSize[e])<-this._overlapSize[e]&&(t=-this._overlapSize[e])}if(i){var a,h=this._tweenStart[e];a=h>0?0:h<-this._overlapSize[e]?Math.ceil(this._contentSize[e]/this._pageSize[e])-1:Math.floor(-h/this._pageSize[e]);var l=Math.floor(-this._containerPos[e]/this._pageSize[e]);Math.abs(n-l)>1&&Math.abs(a-l)<=1&&(t=-(n=n>l?l+1:l-1)*this._pageSize[e])}return t},c.prototype.updateTargetAndDuration=function(t,e){e.x=this.updateTargetAndDuration2(t.x,"x"),e.y=this.updateTargetAndDuration2(t.y,"y")},c.prototype.updateTargetAndDuration2=function(t,e){var i=this._velocity[e],n=0;if(t>0)t=0;else if(t<-this._overlapSize[e])t=-this._overlapSize[e];else{var r=egret.Capabilities.isMobile,s=Math.abs(i)*this._velocityScale;r&&(s*=1136/Math.max(this._owner.displayObject.stage.stageWidth,this._owner.displayObject.stage.stageHeight));var a=0;if(this._pageMode||!r?s>500&&(a=Math.pow((s-500)/500,2)):s>1e3&&(a=Math.pow((s-1e3)/1e3,2)),0!=a)a>1&&(a=1),s*=a,i*=a,this._velocity[e]=i,n=Math.log(60/s)/Math.log(this._decelerationRate)/60,t+=Math.floor(i*n*.4)}return n=Math.abs(e))){var i=Math.abs(this._tweenChange[t]/e)*this._tweenDuration[t];i0){null==this._header.displayObject.parent&&this._maskContainer.addChildAt(this._header.displayObject,0);var e=s;e.setTo(this._header.width,this._header.height),e[this._refreshBarAxis]=t,this._header.setSize(e.x,e.y)}else this._header.displayObject.parent&&this._maskContainer.removeChild(this._header.displayObject);if(this._footer){var i=this._overlapSize[this._refreshBarAxis];t<-i||0==i&&this._footerLockedSize>0?(null==this._footer.displayObject.parent&&this._maskContainer.addChildAt(this._footer.displayObject,0),(e=s).setTo(this._footer.x,this._footer.y),e[this._refreshBarAxis]=i>0?t+this._contentSize[this._refreshBarAxis]:Math.max(Math.min(t+this._viewSize[this._refreshBarAxis],this._viewSize[this._refreshBarAxis]-this._footerLockedSize),this._viewSize[this._refreshBarAxis]-this._contentSize[this._refreshBarAxis]),this._footer.setXY(e.x,e.y),e.setTo(this._footer.width,this._footer.height),e[this._refreshBarAxis]=i>0?-i-t:this._viewSize[this._refreshBarAxis]-this._footer[this._refreshBarAxis],this._footer.setSize(e.x,e.y)):this._footer.displayObject.parent&&this._maskContainer.removeChild(this._footer.displayObject)}}},c.prototype.tweenUpdate=function(e){var i=this.runTween("x"),n=this.runTween("y");return this._container.x=i,this._container.y=n,2==this._tweening&&(this._overlapSize.x>0&&(this._xPos=t.ToolSet.clamp(-i,0,this._overlapSize.x)),this._overlapSize.y>0&&(this._yPos=t.ToolSet.clamp(-n,0,this._overlapSize.y)),this._pageMode&&this.updatePageController()),0==this._tweenChange.x&&0==this._tweenChange.y?(this._tweening=0,t.GTimers.inst.remove(this.tweenUpdate,this),this.loopCheckingCurrent(),this.updateScrollBarPos(),this.updateScrollBarVisible(),this.dispatchEventWith(c.SCROLL),this.dispatchEventWith(c.SCROLL_END)):(this.updateScrollBarPos(),this.dispatchEventWith(c.SCROLL)),!0},c.prototype.runTween=function(e){var i,n,r;if(0!=this._tweenChange[e]){if(this._tweenTime[e]+=t.GTimers.deltaTime/1e3,this._tweenTime[e]>=this._tweenDuration[e])i=this._tweenStart[e]+this._tweenChange[e],this._tweenChange[e]=0;else{var s=(n=this._tweenTime[e],r=this._tweenDuration[e],(n=n/r-1)*n*n+1);i=this._tweenStart[e]+Math.floor(this._tweenChange[e]*s)}var a=0,h=-this._overlapSize[e];if(this._headerLockedSize>0&&this._refreshBarAxis==e&&(a=this._headerLockedSize),this._footerLockedSize>0&&this._refreshBarAxis==e){var l=this._overlapSize[this._refreshBarAxis];0==l?l=Math.max(this._contentSize[this._refreshBarAxis]+this._footerLockedSize-this._viewSize[this._refreshBarAxis],0):l+=this._footerLockedSize,h=-l}2==this._tweening&&this._bouncebackEffect?i>20+a&&this._tweenChange[e]>0||i>a&&0==this._tweenChange[e]?(this._tweenTime[e]=0,this._tweenDuration[e]=o,this._tweenChange[e]=-i+a,this._tweenStart[e]=i):(ia?(i=a,this._tweenChange[e]=0):i=0;d--){var g=this._items[d];if(g.type==r.Transition&&g.value.trans==p){g.value.stopTime=_.time-g.time;break}}d<0?_.value.stopTime=0:p=null}else _.value.stopTime=-1;_.value.trans=p}}0==s?this.onDelayedPlay():t.GTween.delayedCall(s).onComplete(this.onDelayedPlay,this)},e.prototype.stop=function(e,i){if(null==e&&(e=!0),this._playing){this._playing=!1,this._totalTasks=0,this._totalTimes=0;var n=this._onComplete,o=this._onCompleteParam,r=this._onCompleteCaller;this._onComplete=null,this._onCompleteParam=null,this._onCompleteCaller=null,t.GTween.kill(this);var s=this._items.length;if(this._reversed)for(var a=s-1;a>=0;a--){var h=this._items[a];h.target&&this.stopItem(h,e)}else for(a=0;a1&&(n.playing=e[1]);break;case r.Visible:n.visible=e[0];break;case r.Sound:n.sound=e[0],e.length>1&&(n.volume=parseFloat(e[1]));break;case r.Transition:n.transName=e[0],e.length>1&&(n.playTimes=parseInt(e[1]));break;case r.Shake:n.amplitude=parseFloat(e[0]),e.length>1&&(n.duration=parseFloat(e[1]));break;case r.ColorFilter:n.f1=parseFloat(e[0]),n.f2=parseFloat(e[1]),n.f3=parseFloat(e[2]),n.f4=parseFloat(e[3]);break;case r.Text:case r.Icon:n.text=e[0]}}},e.prototype.setHook=function(t,e,i){for(var n=this._items.length,o=0;o0?o.target=this._owner.getChildById(o.targetId):o.target=this._owner:o.target=null)}},e.prototype.setDuration=function(t,e){for(var i=this._items.length,n=0;n0,this._playing){if(0!=(this._options&i))for(var t=this._items.length,e=0;e=0;e--)(t=this._items[e]).target&&this.playItem(t);else for(e=0;e=0&&e.tweener.setBreakpoint(this._endTime-i),this._totalTasks++}}else e.type==r.Shake?(i=this._reversed?this._totalDuration-e.time-e.value.duration:e.time,e.value.offsetX=e.value.offsetY=0,e.value.lastOffsetX=e.value.lastOffsetY=0,e.tweener=t.GTween.shake(0,0,e.value.amplitude,e.value.duration).setDelay(i).setTimeScale(this._timeScale).setTarget(e).onUpdate(this.onTweenUpdate,this).onComplete(this.onTweenComplete,this),this._endTime>=0&&e.tweener.setBreakpoint(this._endTime-e.time),this._totalTasks++):(i=this._reversed?this._totalDuration-e.time:e.time)<=this._startTime?(this.applyValue(e),this.callHook(e,!1)):(-1==this._endTime||i<=this._endTime)&&(this._totalTasks++,e.tweener=t.GTween.delayedCall(i).setTimeScale(this._timeScale).setTarget(e).onComplete(this.onDelayedPlayItem,this));null!=e.tweener&&e.tweener.seek(this._startTime)},e.prototype.skipAnimations=function(){for(var e,i,n,o,s,a,h=this._items.length,l=0;lthis._startTime||(o=a.value).flag)){e=(s=a.target).getProp(t.ObjectPropID.Frame),i=s.getProp(t.ObjectPropID.Playing)?0:-1,n=0;for(var c=l;cthis._startTime||((o=a.value).flag=!0,-1!=o.frame?(e=o.frame,i=o.playing?a.time:-1,n=0):o.playing?i<0&&(i=a.time):(i>=0&&(n+=a.time-i),i=-1),this.callHook(a,!1));i>=0&&(n+=this._startTime-i),s.setProp(t.ObjectPropID.Playing,i>=0),s.setProp(t.ObjectPropID.Frame,e),n>0&&s.setProp(t.ObjectPropID.DeltaTime,1e3*n)}},e.prototype.onDelayedPlayItem=function(t){var e=t.target;e.tweener=null,this._totalTasks--,this.applyValue(e),this.callHook(e,!1),this.checkAllComplete()},e.prototype.onTweenStart=function(t){var e,i,n=t.target;n.type!=r.XY&&n.type!=r.Size||(this._reversed?(e=n.tweenConfig.endValue,i=n.tweenConfig.startValue):(e=n.tweenConfig.startValue,i=n.tweenConfig.endValue),n.type==r.XY?n.target!=this._owner?(e.b1?e.b3&&(t.startValue.x=e.f1*this._owner.width):t.startValue.x=n.target.x,e.b2?e.b3&&(t.startValue.y=e.f2*this._owner.height):t.startValue.y=n.target.y,i.b1?i.b3&&(t.endValue.x=i.f1*this._owner.width):t.endValue.x=t.startValue.x,i.b2?i.b3&&(t.endValue.y=i.f2*this._owner.height):t.endValue.y=t.startValue.y):(e.b1||(t.startValue.x=n.target.x-this._ownerBaseX),e.b2||(t.startValue.y=n.target.y-this._ownerBaseY),i.b1||(t.endValue.x=t.startValue.x),i.b2||(t.endValue.y=t.startValue.y)):(e.b1||(t.startValue.x=n.target.width),e.b2||(t.startValue.y=n.target.height),i.b1||(t.endValue.x=t.startValue.x),i.b2||(t.endValue.y=t.startValue.y)),n.tweenConfig.path&&(n.value.b1=n.value.b2=!0,t.setPath(n.tweenConfig.path)));this.callHook(n,!1)},e.prototype.onTweenUpdate=function(t){var e=t.target;switch(e.type){case r.XY:case r.Size:case r.Scale:case r.Skew:e.value.f1=t.value.x,e.value.f2=t.value.y,e.tweenConfig.path&&(e.value.f1+=t.startValue.x,e.value.f2+=t.startValue.y);break;case r.Alpha:case r.Rotation:e.value.f1=t.value.x;break;case r.Color:e.value.f1=t.value.color;break;case r.ColorFilter:e.value.f1=t.value.x,e.value.f2=t.value.y,e.value.f3=t.value.z,e.value.f4=t.value.w;break;case r.Shake:e.value.offsetX=t.deltaValue.x,e.value.offsetY=t.deltaValue.y}this.applyValue(e)},e.prototype.onTweenComplete=function(t){var e=t.target;e.tweener=null,this._totalTasks--,t.allCompleted&&this.callHook(e,!0),this.checkAllComplete()},e.prototype.onPlayTransCompleted=function(t){this._totalTasks--,this.checkAllComplete()},e.prototype.callHook=function(t,e){e?t.tweenConfig&&t.tweenConfig.endHook&&t.tweenConfig.endHook.call(t.tweenConfig.endHookCaller):t.time>=this._startTime&&null!=t.hook&&t.hook.call(t.hookCaller)},e.prototype.checkAllComplete=function(){if(this._playing&&0==this._totalTasks)if(this._totalTimes<0)this.internalPlay();else if(this._totalTimes--,this._totalTimes>0)this.internalPlay();else{this._playing=!1;for(var t=this._items.length,e=0;e=0&&e.target.setProp(t.ObjectPropID.Frame,i.frame),e.target.setProp(t.ObjectPropID.Playing,i.playing),e.target.setProp(t.ObjectPropID.TimeScale,this._timeScale);break;case r.Visible:e.target.visible=i.visible;break;case r.Transition:if(this._playing){var n=i.trans;if(n){this._totalTasks++;var o=this._startTime>e.time?this._startTime-e.time:0,s=this._endTime>=0?this._endTime-e.time:-1;i.stopTime>=0&&(s<0||s>i.stopTime)&&(s=i.stopTime),n.timeScale=this._timeScale,n._play(this.onPlayTransCompleted,this,e,i.playTimes,0,o,s,this._reversed)}}break;case r.Sound:if(this._playing&&e.time>=this._startTime){if(!i.audioClip){var a=t.UIPackage.getItemByURL(i.sound);a&&(i.audioClip=a.owner.getItemAsset(a))}i.audioClip&&t.GRoot.inst.playOneShotSound(i.audioClip,i.volume)}break;case r.Shake:e.target.setXY(e.target.x-i.lastOffsetX+i.offsetX,e.target.y-i.lastOffsetY+i.offsetY),i.lastOffsetX=i.offsetX,i.lastOffsetY=i.offsetY;break;case r.ColorFilter:t.ToolSet.setColorFilter(e.target.displayObject,[i.f1,i.f2,i.f3,i.f4]);break;case r.Text:e.target.text=i.text;break;case r.Icon:e.target.icon=i.text}e.target._gearLocked=!1},e.prototype.setup=function(e){this.name=e.readS(),this._options=e.readInt(),this._autoPlay=e.readBool(),this._autoPlayTimes=e.readInt(),this._autoPlayDelay=e.readFloat();for(var i=e.readShort(),n=0;nthis._totalDuration&&(this._totalDuration=h.time+h.tweenConfig.duration),h.tweenConfig.easeType=e.readByte(),h.tweenConfig.repeat=e.readInt(),h.tweenConfig.yoyo=e.readBool(),h.tweenConfig.endLabel=e.readS(),e.seek(r,2),this.decodeValue(h,e,h.tweenConfig.startValue),e.seek(r,3),this.decodeValue(h,e,h.tweenConfig.endValue),e.version>=2){var c=e.readInt();if(c>0){h.tweenConfig.path=new t.GPath;for(var u=new Array,_=0;_this._totalDuration&&(this._totalDuration=h.time),e.seek(r,2),this.decodeValue(h,e,h.value);e.position=r+o}},e.prototype.decodeValue=function(t,e,i){switch(t.type){case r.XY:case r.Size:case r.Pivot:case r.Skew:i.b1=e.readBool(),i.b2=e.readBool(),i.f1=e.readFloat(),i.f2=e.readFloat(),e.version>=2&&t.type==r.XY&&(i.b3=e.readBool());break;case r.Alpha:case r.Rotation:i.f1=e.readFloat();break;case r.Scale:i.f1=e.readFloat(),i.f2=e.readFloat();break;case r.Color:i.f1=e.readColor();break;case r.Animation:i.playing=e.readBool(),i.frame=e.readInt();break;case r.Visible:i.visible=e.readBool();break;case r.Sound:i.sound=e.readS(),i.volume=e.readFloat();break;case r.Transition:i.transName=e.readS(),i.playTimes=e.readInt();break;case r.Shake:i.amplitude=e.readFloat(),i.duration=e.readFloat();break;case r.ColorFilter:i.f1=e.readFloat(),i.f2=e.readFloat(),i.f3=e.readFloat(),i.f4=e.readFloat();break;case r.Text:case r.Icon:i.text=e.readS()}},e}();t.Transition=e;var i=1,n=2,o=4,r=function(){function t(){}return t.XY=0,t.Size=1,t.Scale=2,t.Pivot=3,t.Alpha=4,t.Rotation=5,t.Color=6,t.Animation=7,t.Visible=8,t.Sound=9,t.Transition=10,t.Shake=11,t.ColorFilter=12,t.Skew=13,t.Text=14,t.Icon=15,t.Unknown=16,t}(),s=function(){return function(t){this.type=t,this.value={},this.displayLockToken=0}}(),a=function(){return function(){this.duration=0,this.repeat=0,this.easeType=t.EaseType.QuadOut,this.startValue={b1:!0,b2:!0},this.endValue={b1:!0,b2:!0}}}()}(fgui||(fgui={})),function(t){var e=function(){function e(){}return e.loadFromXML=function(t){var i={};e.strings=i;for(var n=egret.XML.parse(t).children,o=n.length,r=0;r0?s.children[0].text:"",l=a.indexOf("-");if(-1==l)continue;var c=a.substr(0,l),u=a.substr(l+1),_=i[c];_||(_={},i[c]=_),_[u]=h}}},e.translateComponent=function(i){if(null!=e.strings){var n=e.strings[i.owner.id+i.id];if(null!=n){var o,r,s,a,h,l,c,u,_,p=i.rawData;p.seek(0,2);var d=p.readShort();for(h=0;h=2){p.seek(u,4),p.skip(2),p.skip(4*p.readShort());for(var m=p.readShort(),b=0;b=2){p.skip(6),p.skip(4*p.readUnsignedShort());for(m=p.readUnsignedShort(),b=0;b0?[4,Promise.all(h)]:[3,3];case 2:u.sent(),u.label=3;case 3:return e._instById[o.id]=o,e._instByName[o.name]=o,e._instById[o._resKey]=o,r(o),[2]}})})})]})})},e.addPackage=function(i,n){if(!n&&!(n=RES.getRes(i)))throw"Resource '"+i+"' not found, please check default.res.json!";var o=new e;return o._resKey=i,o.loadPackage(new t.ByteBuffer(n)),e._instById[o.id]=o,e._instByName[o.name]=o,e._instById[i]=o,o},e.removePackage=function(t){var i=e._instById[t];if(i||(i=e._instByName[t]),!i)throw new Error("unknown package: "+t);i.dispose(),delete e._instById[i.id],delete e._instByName[i.name],delete e._instById[i._resKey],null!=i._customId&&delete e._instById[i._customId]},e.createObject=function(t,i,n){var o=e.getByName(t);return o?o.createObject(i,n):null},e.createObjectFromURL=function(t,i){var n=e.getItemByURL(t);return n?n.owner.internalCreateObject(n,i):null},e.getItemURL=function(t,i){var n=e.getByName(t);if(!n)return null;var o=n._itemsByName[i];return o?"ui://"+n.id+o.id:null},e.getItemByURL=function(t){var i=t.indexOf("//");if(-1==i)return null;var n=t.indexOf("/",i+2);if(-1==n){if(t.length>13){var o=t.substr(5,8),r=e.getById(o);if(null!=r){var s=t.substr(13);return r.getItemById(s)}}}else{var a=t.substr(i+2,n-i-2);if(null!=(r=e.getByName(a))){var h=t.substr(n+1);return r.getItemByName(h)}}return null},e.normalizeURL=function(t){if(null==t)return null;var i=t.indexOf("//");if(-1==i)return null;var n=t.indexOf("/",i+2);if(-1==n)return t;var o=t.substr(i+2,n-i-2),r=t.substr(n+1);return e.getItemURL(o,r)},e.setStringsSource=function(e){t.TranslationHelper.loadFromXML(e)},e.prototype.loadPackage=function(n){if(1179080009!=n.readUnsignedInt())throw"FairyGUI: old package format found in '"+this._resKey+"'";n.version=n.readInt();var o=n.readBool();if(this._id=n.readUTF(),this._name=n.readUTF(),n.skip(20),o){var r=new Uint8Array(n.buffer,n.position,n.length-n.position),s=new Zlib.RawInflate(r),a=new t.ByteBuffer(s.decompress());a.version=n.version,n=a}var h,l,c,u,_,p=n.version>=2,d=n.position;n.seek(d,4),h=n.readInt();var g,f=new Array(h);for(f.reduceRight,l=0;l0&&(this._branches=n.readSArray(h),e._branch&&(this._branchIndex=this._branches.indexOf(e._branch))),_=h>0),n.seek(d,1);var y=this._resKey,m=y.lastIndexOf("/"),b=-1==m?"":y.substr(0,m+1);for(y+="_",h=n.readShort(),l=0;l0?w:t.ObjectType.Component,g.rawData=n.readBuffer(),t.UIObjectFactory.resolvePackageItemExtension(g);break;case t.PackageItemType.Atlas:case t.PackageItemType.Sound:case t.PackageItemType.Misc:var C=g.file.lastIndexOf(".");g.file=y+(-1==C?g.file:i(g.file.substring(0,C),g.file.substring(C+1)));break;case t.PackageItemType.Spine:case t.PackageItemType.DragonBones:var S=g.file.lastIndexOf(".");g.file=b+(-1==S?g.file:g.file.substring(0,S)),g.skeletonAnchor=new egret.Point,g.skeletonAnchor.x=n.readFloat(),g.skeletonAnchor.y=n.readFloat()}if(p){(u=n.readS())&&(g.name=u+"/"+g.name);var x=n.readUnsignedByte();x>0&&(_?g.branches=n.readSArray(x):this._itemsById[n.readS()]=g);var T=n.readUnsignedByte();T>0&&(g.highResolution=n.readSArray(T))}this._items.push(g),this._itemsById[g.id]=g,null!=g.name&&(this._itemsByName[g.name]=g),n.position=c}for(n.seek(d,2),h=n.readShort(),l=0;l0){this._loading=!1;for(var t=this._uiSources.length,e=0;e=.9999)return[0,0,o,0,o,r,0,r];var c;switch(s){case t.FillMethod.Horizontal:c=function(e,i,n,o){var r=e*o;return n==t.FillOrigin.Left||n==t.FillOrigin.Top?[0,0,r,0,r,i,0,i]:[e,0,e,i,e-r,i,e-r,0]}(o,r,a,l);break;case t.FillMethod.Vertical:c=function(e,i,n,o){var r=i*o;return n==t.FillOrigin.Left||n==t.FillOrigin.Top?[0,0,0,r,e,r,e,0]:[0,i,e,i,e,i-r,0,i-r]}(o,r,a,l);break;case t.FillMethod.Radial90:c=e(o,r,a,h,l);break;case t.FillMethod.Radial180:c=n(o,r,a,h,l);break;case t.FillMethod.Radial360:c=function(e,o,r,s,a){var h;switch(r){case t.FillOrigin.Top:a<=.5?(a/=.5,h=n(e/2,o,s?t.FillOrigin.Left:t.FillOrigin.Right,s,a),s&&i(h,e/2,0)):(a=(a-.5)/.5,h=n(e/2,o,s?t.FillOrigin.Right:t.FillOrigin.Left,s,a),s?h.push(e,o,e,0,e/2,0):(i(h,e/2,0),h.push(0,o,0,0,e/2,0)));break;case t.FillOrigin.Bottom:a<=.5?(a/=.5,h=n(e/2,o,s?t.FillOrigin.Right:t.FillOrigin.Left,s,a),s||i(h,e/2,0)):(a=(a-.5)/.5,h=n(e/2,o,s?t.FillOrigin.Left:t.FillOrigin.Right,s,a),s?(i(h,e/2,0),h.push(0,0,0,o,e/2,o)):h.push(e,0,e,o,e/2,o));break;case t.FillOrigin.Left:a<=.5?(a/=.5,h=n(e,o/2,s?t.FillOrigin.Bottom:t.FillOrigin.Top,s,a),s||i(h,0,o/2)):(a=(a-.5)/.5,h=n(e,o/2,s?t.FillOrigin.Top:t.FillOrigin.Bottom,s,a),s?(i(h,0,o/2),h.push(e,0,0,0,0,o/2)):h.push(e,o,0,o,0,o/2));break;case t.FillOrigin.Right:a<=.5?(a/=.5,h=n(e,o/2,s?t.FillOrigin.Top:t.FillOrigin.Bottom,s,a),s&&i(h,0,o/2)):(a=(a-.5)/.5,h=n(e,o/2,s?t.FillOrigin.Bottom:t.FillOrigin.Top,s,a),s?h.push(0,o,e,o,e,o/2):(i(h,0,o/2),h.push(0,0,e,0,e,o/2)))}return h}(o,r,a,h,l)}return c}}(fgui||(fgui={})),function(t){var e=function(e){function i(){var t=e.call(this)||this;return t._fillMethod=0,t._fillOrigin=0,t._fillAmount=0,t._color=16777215,t}return __extends(i,e),Object.defineProperty(i.prototype,"color",{get:function(){return this._color},set:function(e){this._color!=e&&(this._color=e,null==this.tint?t.ToolSet.setColorFilter(this,e):this.tint=e)},enumerable:!0,configurable:!0}),i.prototype.$setX=function(t){return this.mask&&(this.mask.x=t),e.prototype.$setX.call(this,t)},i.prototype.$setY=function(t){return this.mask&&(this.mask.y=t),e.prototype.$setY.call(this,t)},Object.defineProperty(i.prototype,"fillMethod",{get:function(){return this._fillMethod},set:function(t){this._fillMethod!=t&&(this._fillMethod=t,0!=this._fillMethod?(this._mask||(this._mask=new egret.Shape,this._mask.touchEnabled=!1),this.mask=this._mask,this._mask.x=this.x,this._mask.y=this.y,this.addEventListener(egret.Event.RESIZE,this.markChanged,this),this.markChanged()):this.mask&&(this._mask.graphics.clear(),this.mask=null,this.removeEventListener(egret.Event.RESIZE,this.markChanged,this)))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillOrigin",{get:function(){return this._fillOrigin},set:function(t){this._fillOrigin!=t&&(this._fillOrigin=t,0!=this._fillMethod&&this.markChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillClockwise",{get:function(){return this._fillClockwise},set:function(t){this._fillClockwise!=t&&(this._fillClockwise=t,0!=this._fillMethod&&this.markChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fillAmount",{get:function(){return this._fillAmount},set:function(t){this._fillAmount!=t&&(this._fillAmount=t,0!=this._fillMethod&&this.markChanged())},enumerable:!0,configurable:!0}),i.prototype.markChanged=function(){this._maskDirtyFlag||(this._maskDirtyFlag=!0,t.GTimers.inst.callLater(this.doFill,this))},i.prototype.doFill=function(){this._maskDirtyFlag=!1,!this._mask.parent&&this.parent&&this.parent.addChild(this._mask);var e=this.width,i=this.height,n=this._mask.graphics;if(n.clear(),0!=e&&0!=i){var o=t.fillImage(e,i,this._fillMethod,this._fillOrigin,this._fillClockwise,this._fillAmount);o&&(n.beginFill(0,1),t.ToolSet.fillPath(n,o,0,0),n.endFill())}},i}(egret.Bitmap);t.Image=e}(fgui||(fgui={})),function(t){var e=function(e){function i(){var t=e.call(this)||this;return t.interval=0,t.repeatDelay=0,t.timeScale=1,t._playing=!0,t._frameCount=0,t._frame=0,t._start=0,t._end=0,t._times=0,t._endAt=0,t._status=0,t._frameElapsed=0,t._reversed=!1,t._repeatedCount=0,t.touchEnabled=!1,t.setPlaySettings(),t}return __extends(i,e),Object.defineProperty(i.prototype,"frames",{get:function(){return this._frames},set:function(t){this._frames=t,this.scale9Grid=null,this.fillMode=egret.BitmapFillMode.SCALE,this._frames?this._frameCount=this._frames.length:this._frameCount=0,(-1==this._end||this._end>this._frameCount-1)&&(this._end=this._frameCount-1),(-1==this._endAt||this._endAt>this._frameCount-1)&&(this._endAt=this._frameCount-1),(this._frame<0||this._frame>this._frameCount-1)&&(this._frame=this._frameCount-1),this.drawFrame(),this._frameElapsed=0,this._repeatedCount=0,this._reversed=!1,this.checkTimer()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frameCount",{get:function(){return this._frameCount},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frame",{get:function(){return this._frame},set:function(t){this._frame!=t&&(this._frames&&t>=this._frameCount&&(t=this._frameCount-1),this._frame=t,this._frameElapsed=0,this.drawFrame())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"playing",{get:function(){return this._playing},set:function(t){this._playing!=t&&(this._playing=t,this.checkTimer())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"smoothing",{get:function(){return this._smoothing},set:function(t){this._smoothing=t},enumerable:!0,configurable:!0}),i.prototype.rewind=function(){this._frame=0,this._frameElapsed=0,this._reversed=!1,this._repeatedCount=0,this.drawFrame()},i.prototype.syncStatus=function(t){this._frame=t._frame,this._frameElapsed=t._frameElapsed,this._reversed=t._reversed,this._repeatedCount=t._repeatedCount,this.drawFrame()},i.prototype.advance=function(t){for(var e=this._frame,i=this._reversed,n=t;;){var o=this.interval+this._frames[this._frame].addDelay;if(0==this._frame&&this._repeatedCount>0&&(o+=this.repeatDelay),tthis._frameCount-1&&(this._frame=Math.max(0,this._frameCount-2),this._repeatedCount++,this._reversed=!this._reversed)):(this._frame++,this._frame>this._frameCount-1&&(this._frame=0,this._repeatedCount++)),this._frame==e&&this._reversed==i){var r=n-t;t-=Math.floor(t/r)*r}}this.drawFrame()},i.prototype.setPlaySettings=function(t,e,i,n,o,r){null==t&&(t=0),null==e&&(e=-1),null==i&&(i=0),null==n&&(n=-1),this._start=t,this._end=e,(-1==this._end||this._end>this._frameCount-1)&&(this._end=this._frameCount-1),this._times=i,this._endAt=n,-1==this._endAt&&(this._endAt=this._end),this._status=0,this._callback=o,this._callbackObj=r,this.frame=t},i.prototype.update=function(){if(this._playing&&0!=this._frameCount&&3!=this._status){var e=t.GTimers.deltaTime;1!=this.timeScale&&(e*=this.timeScale),this._frameElapsed+=e;var i=this.interval+this._frames[this._frame].addDelay;if(0==this._frame&&this._repeatedCount>0&&(i+=this.repeatDelay),!(this._frameElapsedthis.interval&&(this._frameElapsed=this.interval),this.swing?this._reversed?(this._frame--,this._frame<=0&&(this._frame=0,this._repeatedCount++,this._reversed=!this._reversed)):(this._frame++,this._frame>this._frameCount-1&&(this._frame=Math.max(0,this._frameCount-2),this._repeatedCount++,this._reversed=!this._reversed)):(this._frame++,this._frame>this._frameCount-1&&(this._frame=0,this._repeatedCount++)),1==this._status)this._frame=this._start,this._frameElapsed=0,this._status=0;else if(2==this._status){if(this._frame=this._endAt,this._frameElapsed=0,this._status=3,null!=this._callback){var n=this._callback,o=this._callbackObj;this._callback=null,this._callbackObj=null,n.call(o)}}else this._frame==this._end&&(this._times>0?(this._times--,0==this._times?this._status=2:this._status=1):0!=this._start&&(this._status=1));this.drawFrame()}}},i.prototype.drawFrame=function(){if(this._frameCount>0&&this._frame0&&null!=this.stage?t.GTimers.inst.add(1,0,this.update,this):t.GTimers.inst.remove(this.update,this)},i.prototype.$onAddToStage=function(i,n){e.prototype.$onAddToStage.call(this,i,n),this._playing&&this._frameCount>0&&t.GTimers.inst.add(1,0,this.update,this)},i.prototype.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this),t.GTimers.inst.remove(this.update,this)},i}(t.Image);t.MovieClip=e}(fgui||(fgui={})),function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.touchEnabled=!0,e.touchChildren=!0,e}return __extends(e,t),e.prototype.cacheHitArea=function(t){this._cachedHitArea=t,t&&(this._cachedMatrix||(this._cachedMatrix=new egret.Matrix),this._cachedMatrix.copyFrom(this.$getInvertedConcatenatedMatrix()))},Object.defineProperty(e.prototype,"hitArea",{get:function(){return this._hitArea},set:function(t){this._hitArea=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"opaque",{get:function(){return this._opaque},set:function(t){this._opaque=t},enumerable:!0,configurable:!0}),e.prototype.$hitTest=function(e,i){if(!this.$visible)return null;if(this._hitArea){if(!this.touchEnabled)return null;if(this._hitArea.$graphics){if(!this._hitArea.$graphics.$hitTest(e,i))return null}else{var n=(s=this._cachedHitArea?this._cachedMatrix:this.$getInvertedConcatenatedMatrix()).a*e+s.c*i+s.tx,o=s.b*e+s.d*i+s.ty;if(!this._hitArea.contains(n,o))return null}return this}var r=t.prototype.$hitTest.call(this,e,i);if(r==this&&!this.touchEnabled)return null;if(null==r&&this._opaque){var s;n=(s=this._cachedHitArea?this._cachedMatrix:this.$getInvertedConcatenatedMatrix()).a*e+s.c*i+s.tx,o=s.b*e+s.d*i+s.ty;return n>=0&&o>=0&&n<=this.$explicitWidth&&o<=this.$explicitHeight?this:null}return r!=this||this._opaque?r:null},e}(egret.DisplayObjectContainer);t.UIContainer=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e,i,n,o){void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=-1);var r=t.call(this,e,!1)||this;return r.touchPointID=0,r.stageX=i,r.stageY=n,r.touchPointID=o,r}return __extends(e,t),e.prototype.preventDefault=function(){this._prevented=!0},e.prototype.isDefaultPrevented=function(){return this._prevented},e.DRAG_START="__dragStart",e.DRAG_END="__dragEnd",e.DRAG_MOVING="__dragMoving",e}(egret.Event);t.DragEvent=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e,i){var n=t.call(this,e,!1)||this;return n.source=i,n}return __extends(e,t),e.DROP="__drop",e}(egret.Event);t.DropEvent=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e,i,n,o){void 0===i&&(i=null),void 0===n&&(n=0),void 0===o&&(o=0);var r=t.call(this,e,!1)||this;return r.itemObject=i,r.stageX=n,r.stageY=o,r}return __extends(e,t),e.CLICK="___itemClick",e}(egret.Event);t.ItemEvent=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e){return t.call(this,e,!1)||this}return __extends(e,t),e.CHANGED="___stateChanged",e}(egret.Event);t.StateChangeEvent=e}(fgui||(fgui={})),function(t){var e,i=function(){function i(t){this._owner=t}return i.create=function(i,n){return e||(e=[t.GearDisplay,t.GearXY,t.GearSize,t.GearLook,t.GearColor,t.GearAnimation,t.GearText,t.GearIcon,t.GearDisplay2,t.GearFontSize]),new e[n](i)},i.prototype.dispose=function(){this._tweenConfig&&this._tweenConfig._tweener&&(this._tweenConfig._tweener.kill(),this._tweenConfig._tweener=null)},Object.defineProperty(i.prototype,"controller",{get:function(){return this._controller},set:function(t){t!=this._controller&&(this._controller=t,this._controller&&this.init())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"tweenConfig",{get:function(){return this._tweenConfig||(this._tweenConfig=new n),this._tweenConfig},enumerable:!0,configurable:!0}),i.prototype.setup=function(e){var i,o;this._controller=this._owner.parent.getControllerAt(e.readShort()),this.init();var r=e.readShort();if(this instanceof t.GearDisplay)this.pages=e.readSArray(r);else if(this instanceof t.GearDisplay2)this.pages=e.readSArray(r);else{for(i=0;i=2)if(this instanceof t.GearXY){if(e.readBool()){for(this.positionsInPercent=!0,i=0;i0},enumerable:!0,configurable:!0}),e}(t.GearBase);t.GearDisplay=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e){var i=t.call(this,e)||this;return i._visible=0,i}return __extends(e,t),e.prototype.init=function(){this.pages=null},e.prototype.apply=function(){null==this.pages||0==this.pages.length||-1!=this.pages.indexOf(this._controller.selectedPageId)?this._visible=1:this._visible=0},e.prototype.evaluate=function(t){var e=null==this._controller||this._visible>0;return e=0==this.condition?e&&t:e||t},e}(t.GearBase);t.GearDisplay2=e}(fgui||(fgui={})),function(t){var e=function(e){function i(t){var i=e.call(this,t)||this;return i._default=0,i}return __extends(i,e),i.prototype.init=function(){this._default=this._owner.getProp(t.ObjectPropID.FontSize),this._storage={}},i.prototype.addStatus=function(t,e){null==t?this._default=e.readInt():this._storage[t]=e.readInt()},i.prototype.apply=function(){this._owner._gearLocked=!0;var e=this._storage[this._controller.selectedPageId];null!=e?this._owner.setProp(t.ObjectPropID.FontSize,e):this._owner.setProp(t.ObjectPropID.FontSize,this._default),this._owner._gearLocked=!1},i.prototype.updateState=function(){this._storage[this._controller.selectedPageId]=this._owner.getProp(t.ObjectPropID.FontSize)},i}(t.GearBase);t.GearFontSize=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.init=function(){this._default=this._owner.icon,this._storage={}},e.prototype.addStatus=function(t,e){null==t?this._default=e.readS():this._storage[t]=e.readS()},e.prototype.apply=function(){this._owner._gearLocked=!0;var t=this._storage[this._controller.selectedPageId];this._owner.icon=void 0!==t?t:this._default,this._owner._gearLocked=!1},e.prototype.updateState=function(){this._storage[this._controller.selectedPageId]=this._owner.icon},e}(t.GearBase);t.GearIcon=e}(fgui||(fgui={})),function(t){var e=function(e){function i(t){return e.call(this,t)||this}return __extends(i,e),i.prototype.init=function(){this._default={alpha:this._owner.alpha,rotation:this._owner.rotation,grayed:this._owner.grayed,touchable:this._owner.touchable},this._storage={}},i.prototype.addStatus=function(t,e){var i;null==t?i=this._default:this._storage[t]=i={},i.alpha=e.readFloat(),i.rotation=e.readFloat(),i.grayed=e.readBool(),i.touchable=e.readBool()},i.prototype.apply=function(){var e=this._storage[this._controller.selectedPageId];if(e||(e=this._default),this._tweenConfig&&this._tweenConfig.tween&&!t.UIPackage._constructing&&!t.GearBase.disableAllTweenEffect){if(this._owner._gearLocked=!0,this._owner.grayed=e.grayed,this._owner.touchable=e.touchable,this._owner._gearLocked=!1,this._tweenConfig._tweener){if(this._tweenConfig._tweener.endValue.x==e.alpha&&this._tweenConfig._tweener.endValue.y==e.rotation)return;this._tweenConfig._tweener.kill(!0),this._tweenConfig._tweener=null}var i=e.alpha!=this._owner.alpha,n=e.rotation!=this._owner.rotation;(i||n)&&(this._owner.checkGearController(0,this._controller)&&(this._tweenConfig._displayLockToken=this._owner.addDisplayLock()),this._tweenConfig._tweener=t.GTween.to2(this._owner.alpha,this._owner.rotation,e.alpha,e.rotation,this._tweenConfig.duration).setDelay(this._tweenConfig.delay).setEase(this._tweenConfig.easeType).setUserData((i?1:0)+(n?2:0)).setTarget(this).onUpdate(this.__tweenUpdate,this).onComplete(this.__tweenComplete,this))}else this._owner._gearLocked=!0,this._owner.grayed=e.grayed,this._owner.touchable=e.touchable,this._owner.alpha=e.alpha,this._owner.rotation=e.rotation,this._owner._gearLocked=!1},i.prototype.__tweenUpdate=function(t){var e=t.userData;this._owner._gearLocked=!0,0!=(1&e)&&(this._owner.alpha=t.value.x),0!=(2&e)&&(this._owner.rotation=t.value.y),this._owner._gearLocked=!1},i.prototype.__tweenComplete=function(){0!=this._tweenConfig._displayLockToken&&(this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken),this._tweenConfig._displayLockToken=0),this._tweenConfig._tweener=null},i.prototype.updateState=function(){var t=this._storage[this._controller.selectedPageId];t||(this._storage[this._controller.selectedPageId]=t={}),t.alpha=this._owner.alpha,t.rotation=this._owner.rotation,t.grayed=this._owner.grayed,t.touchable=this._owner.touchable},i}(t.GearBase);t.GearLook=e}(fgui||(fgui={})),function(t){var e=function(e){function i(t){return e.call(this,t)||this}return __extends(i,e),i.prototype.init=function(){this._default={width:this._owner.width,height:this._owner.height,scaleX:this._owner.scaleX,scaleY:this._owner.scaleY},this._storage={}},i.prototype.addStatus=function(t,e){var i;null==t?i=this._default:this._storage[t]=i={},i.width=e.readInt(),i.height=e.readInt(),i.scaleX=e.readFloat(),i.scaleY=e.readFloat()},i.prototype.apply=function(){var e=this._storage[this._controller.selectedPageId];if(e||(e=this._default),this._tweenConfig&&this._tweenConfig.tween&&!t.UIPackage._constructing&&!t.GearBase.disableAllTweenEffect){if(this._tweenConfig._tweener){if(this._tweenConfig._tweener.endValue.x==e.width&&this._tweenConfig._tweener.endValue.y==e.height&&this._tweenConfig._tweener.endValue.z==e.scaleX&&this._tweenConfig._tweener.endValue.w==e.scaleY)return;this._tweenConfig._tweener.kill(!0),this._tweenConfig._tweener=null}var i=e.width!=this._owner.width||e.height!=this._owner.height,n=e.scaleX!=this._owner.scaleX||e.scaleY!=this._owner.scaleY;(i||n)&&(this._owner.checkGearController(0,this._controller)&&(this._tweenConfig._displayLockToken=this._owner.addDisplayLock()),this._tweenConfig._tweener=t.GTween.to4(this._owner.width,this._owner.height,this._owner.scaleX,this._owner.scaleY,e.width,e.height,e.scaleX,e.scaleY,this._tweenConfig.duration).setDelay(this._tweenConfig.delay).setEase(this._tweenConfig.easeType).setUserData((i?1:0)+(n?2:0)).setTarget(this).onUpdate(this.__tweenUpdate,this).onComplete(this.__tweenComplete,this))}else this._owner._gearLocked=!0,this._owner.setSize(e.width,e.height,this._owner.gearXY.controller==this._controller),this._owner.setScale(e.scaleX,e.scaleY),this._owner._gearLocked=!1},i.prototype.__tweenUpdate=function(t){var e=t.userData;this._owner._gearLocked=!0,0!=(1&e)&&this._owner.setSize(t.value.x,t.value.y,this._owner.checkGearController(1,this._controller)),0!=(2&e)&&this._owner.setScale(t.value.z,t.value.w),this._owner._gearLocked=!1},i.prototype.__tweenComplete=function(){0!=this._tweenConfig._displayLockToken&&(this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken),this._tweenConfig._displayLockToken=0),this._tweenConfig._tweener=null},i.prototype.updateState=function(){var t=this._storage[this._controller.selectedPageId];t||(this._storage[this._controller.selectedPageId]=t={}),t.width=this._owner.width,t.height=this._owner.height,t.scaleX=this._owner.scaleX,t.scaleY=this._owner.scaleY},i.prototype.updateFromRelations=function(t,e){if(null!=this._controller&&null!=this._storage){for(var i in this._storage){var n=this._storage[i];n.width+=t,n.height+=e}this._default.width+=t,this._default.height+=e,this.updateState()}},i}(t.GearBase);t.GearSize=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.init=function(){this._default=this._owner.text,this._storage={}},e.prototype.addStatus=function(t,e){null==t?this._default=e.readS():this._storage[t]=e.readS()},e.prototype.apply=function(){this._owner._gearLocked=!0;var t=this._storage[this._controller.selectedPageId];this._owner.text=void 0!==t?t:this._default,this._owner._gearLocked=!1},e.prototype.updateState=function(){this._storage[this._controller.selectedPageId]=this._owner.text},e}(t.GearBase);t.GearText=e}(fgui||(fgui={})),function(t){var e=function(e){function i(t){return e.call(this,t)||this}return __extends(i,e),i.prototype.init=function(){this._default={x:this._owner.x,y:this._owner.y,px:this._owner.x/this._owner.parent.width,py:this._owner.y/this._owner.parent.height},this._storage={}},i.prototype.addStatus=function(t,e){var i;null==t?i=this._default:this._storage[t]=i={},i.x=e.readInt(),i.y=e.readInt()},i.prototype.addExtStatus=function(t,e){var i;(i=null==t?this._default:this._storage[t]).px=e.readFloat(),i.py=e.readFloat()},i.prototype.apply=function(){var e,i,n=this._storage[this._controller.selectedPageId];if(n||(n=this._default),this.positionsInPercent&&this._owner.parent?(e=n.px*this._owner.parent.width,i=n.py*this._owner.parent.height):(e=n.x,i=n.y),this._tweenConfig&&this._tweenConfig.tween&&!t.UIPackage._constructing&&!t.GearBase.disableAllTweenEffect){if(this._tweenConfig._tweener){if(this._tweenConfig._tweener.endValue.x==e&&this._tweenConfig._tweener.endValue.y==i)return;this._tweenConfig._tweener.kill(!0),this._tweenConfig._tweener=null}var o=this._owner.x,r=this._owner.y;o==e&&r==i||(this._owner.checkGearController(0,this._controller)&&(this._tweenConfig._displayLockToken=this._owner.addDisplayLock()),this._tweenConfig._tweener=t.GTween.to2(o,r,e,i,this._tweenConfig.duration).setDelay(this._tweenConfig.delay).setEase(this._tweenConfig.easeType).setTarget(this).onUpdate(this.__tweenUpdate,this).onComplete(this.__tweenComplete,this))}else this._owner._gearLocked=!0,this._owner.setXY(e,i),this._owner._gearLocked=!1},i.prototype.__tweenUpdate=function(t){this._owner._gearLocked=!0,this._owner.setXY(t.value.x,t.value.y),this._owner._gearLocked=!1},i.prototype.__tweenComplete=function(){0!=this._tweenConfig._displayLockToken&&(this._owner.releaseDisplayLock(this._tweenConfig._displayLockToken),this._tweenConfig._displayLockToken=0),this._tweenConfig._tweener=null},i.prototype.updateState=function(){var t=this._storage[this._controller.selectedPageId];t||(this._storage[this._controller.selectedPageId]=t={}),t.x=this._owner.x,t.y=this._owner.y,t.px=this._owner.x/this._owner.parent.width,t.py=this._owner.y/this._owner.parent.height},i.prototype.updateFromRelations=function(t,e){if(null!=this._controller&&null!=this._storage&&!this.positionsInPercent){for(var i in this._storage){var n=this._storage[i];n.x+=t,n.y+=e}this._default.x+=t,this._default.y+=e,this.updateState()}},i}(t.GearBase);t.GearXY=e}(fgui||(fgui={})),function(t){var e=.5*Math.PI,i=2*Math.PI;function n(t,e){return 1-o(e-t,e)}function o(t,e){return(t/=e)<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}t.evaluateEase=function(r,s,a,h,l){switch(r){case t.EaseType.Linear:return s/a;case t.EaseType.SineIn:return 1-Math.cos(s/a*e);case t.EaseType.SineOut:return Math.sin(s/a*e);case t.EaseType.SineInOut:return-.5*(Math.cos(Math.PI*s/a)-1);case t.EaseType.QuadIn:return(s/=a)*s;case t.EaseType.QuadOut:return-(s/=a)*(s-2);case t.EaseType.QuadInOut:return(s/=.5*a)<1?.5*s*s:-.5*(--s*(s-2)-1);case t.EaseType.CubicIn:return(s/=a)*s*s;case t.EaseType.CubicOut:return(s=s/a-1)*s*s+1;case t.EaseType.CubicInOut:return(s/=.5*a)<1?.5*s*s*s:.5*((s-=2)*s*s+2);case t.EaseType.QuartIn:return(s/=a)*s*s*s;case t.EaseType.QuartOut:return-((s=s/a-1)*s*s*s-1);case t.EaseType.QuartInOut:return(s/=.5*a)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2);case t.EaseType.QuintIn:return(s/=a)*s*s*s*s;case t.EaseType.QuintOut:return(s=s/a-1)*s*s*s*s+1;case t.EaseType.QuintInOut:return(s/=.5*a)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2);case t.EaseType.ExpoIn:return 0==s?0:Math.pow(2,10*(s/a-1));case t.EaseType.ExpoOut:return s==a?1:1-Math.pow(2,-10*s/a);case t.EaseType.ExpoInOut:return 0==s?0:s==a?1:(s/=.5*a)<1?.5*Math.pow(2,10*(s-1)):.5*(2-Math.pow(2,-10*--s));case t.EaseType.CircIn:return-(Math.sqrt(1-(s/=a)*s)-1);case t.EaseType.CircOut:return Math.sqrt(1-(s=s/a-1)*s);case t.EaseType.CircInOut:return(s/=.5*a)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1);case t.EaseType.ElasticIn:var c;return 0==s?0:1==(s/=a)?1:(0==l&&(l=.3*a),h<1?(h=1,c=l/4):c=l/i*Math.asin(1/h),-h*Math.pow(2,10*(s-=1))*Math.sin((s*a-c)*i/l));case t.EaseType.ElasticOut:var u;return 0==s?0:1==(s/=a)?1:(0==l&&(l=.3*a),h<1?(h=1,u=l/4):u=l/i*Math.asin(1/h),h*Math.pow(2,-10*s)*Math.sin((s*a-u)*i/l)+1);case t.EaseType.ElasticInOut:var _;return 0==s?0:2==(s/=.5*a)?1:(0==l&&(l=a*(.3*1.5)),h<1?(h=1,_=l/4):_=l/i*Math.asin(1/h),s<1?h*Math.pow(2,10*(s-=1))*Math.sin((s*a-_)*i/l)*-.5:h*Math.pow(2,-10*(s-=1))*Math.sin((s*a-_)*i/l)*.5+1);case t.EaseType.BackIn:return(s/=a)*s*((h+1)*s-h);case t.EaseType.BackOut:return(s=s/a-1)*s*((h+1)*s+h)+1;case t.EaseType.BackInOut:return(s/=.5*a)<1?s*s*((1+(h*=1.525))*s-h)*.5:.5*((s-=2)*s*((1+(h*=1.525))*s+h)+2);case t.EaseType.BounceIn:return n(s,a);case t.EaseType.BounceOut:return o(s,a);case t.EaseType.BounceInOut:return function(t,e){return t<.5*e?.5*n(2*t,e):.5*o(2*t-e,e)+.5}(s,a);default:return-(s/=a)*(s-2)}}}(fgui||(fgui={})),function(t){var e=function(){function t(){}return t.Linear=0,t.SineIn=1,t.SineOut=2,t.SineInOut=3,t.QuadIn=4,t.QuadOut=5,t.QuadInOut=6,t.CubicIn=7,t.CubicOut=8,t.CubicInOut=9,t.QuartIn=10,t.QuartOut=11,t.QuartInOut=12,t.QuintIn=13,t.QuintOut=14,t.QuintInOut=15,t.ExpoIn=16,t.ExpoOut=17,t.ExpoInOut=18,t.CircIn=19,t.CircOut=20,t.CircInOut=21,t.ElasticIn=22,t.ElasticOut=23,t.ElasticInOut=24,t.BackIn=25,t.BackOut=26,t.BackInOut=27,t.BounceIn=28,t.BounceOut=29,t.BounceInOut=30,t.Custom=31,t}();t.EaseType=e}(fgui||(fgui={})),function(t){var e=function(){function e(){this._segments=new Array,this._points=new Array}return Object.defineProperty(e.prototype,"length",{get:function(){return this._fullLength},enumerable:!0,configurable:!0}),e.prototype.create=function(e,n,o,r){var s;Array.isArray(e)?s=e:((s=new Array).push(e),s.push(n),o&&s.push(o),r&&s.push(r)),this._segments.length=0,this._points.length=0,this._fullLength=0;var a=s.length;if(0!=a){var h=i;h.length=0;var l=s[0];l.curveType==t.CurveType.CRSpline&&h.push(new egret.Point(l.x,l.y));for(var c=1;c0&&(h.push(new egret.Point(u.x,u.y)),this.createSplineSegment()):h.push(new egret.Point(u.x,u.y)),l=u}h.length>1&&this.createSplineSegment()}},e.prototype.createSplineSegment=function(){var e=i,n=e.length;e.splice(0,0,e[0]),e.push(e[n]),e.push(e[n]),n+=3;var o={};o.type=t.CurveType.CRSpline,o.ptStart=this._points.length,o.ptCount=n,this._points=this._points.concat(e),o.length=0;for(var r=1;ri&&u=0?this._elapsedTime=this._delay+this._breakpoint:this._repeat>=0?this._elapsedTime=this._delay+this._duration*(this._repeat+1):this._elapsedTime=this._delay+2*this._duration,this.update()),this.callCompleteCallback()),this._killed=!0)},e.prototype._to=function(t,e,i){return this._valueSize=1,this._startValue.x=t,this._endValue.x=e,this._value.x=t,this._duration=i,this},e.prototype._to2=function(t,e,i,n,o){return this._valueSize=2,this._startValue.x=t,this._endValue.x=i,this._startValue.y=e,this._endValue.y=n,this._value.x=t,this._value.y=e,this._duration=o,this},e.prototype._to3=function(t,e,i,n,o,r,s){return this._valueSize=3,this._startValue.x=t,this._endValue.x=n,this._startValue.y=e,this._endValue.y=o,this._startValue.z=i,this._endValue.z=r,this._value.x=t,this._value.y=e,this._value.z=i,this._duration=s,this},e.prototype._to4=function(t,e,i,n,o,r,s,a,h){return this._valueSize=4,this._startValue.x=t,this._endValue.x=o,this._startValue.y=e,this._endValue.y=r,this._startValue.z=i,this._endValue.z=s,this._startValue.w=n,this._endValue.w=a,this._value.x=t,this._value.y=e,this._value.z=i,this._value.w=n,this._duration=h,this},e.prototype._toColor=function(t,e,i){return this._valueSize=4,this._startValue.color=t,this._endValue.color=e,this._value.color=t,this._duration=i,this},e.prototype._shake=function(t,e,i,n){return this._valueSize=5,this._startValue.x=t,this._startValue.y=e,this._startValue.w=i,this._duration=n,this},e.prototype._init=function(){this._delay=0,this._duration=0,this._breakpoint=-1,this._easeType=t.EaseType.QuadOut,this._timeScale=1,this._easePeriod=0,this._easeOvershootOrAmplitude=1.70158,this._snapping=!1,this._repeat=0,this._yoyo=!1,this._valueSize=0,this._started=!1,this._paused=!1,this._killed=!1,this._elapsedTime=0,this._normalizedTime=0,this._ended=0},e.prototype._reset=function(){this._target=null,this._propType=null,this._userData=null,this._path=null,this._onStart=this._onUpdate=this._onComplete=null,this._onStartCaller=this._onUpdateCaller=this._onCompleteCaller=null},e.prototype._update=function(t){if(1!=this._timeScale&&(t*=this._timeScale),0!=t){if(0!=this._ended)return this.callCompleteCallback(),void(this._killed=!0);this._elapsedTime+=t,this.update(),0!=this._ended&&(this._killed||(this.callCompleteCallback(),this._killed=!0))}},e.prototype.update=function(){if(this._ended=0,0!=this._valueSize){if(!this._started){if(this._elapsedTime=0&&n>=this._breakpoint&&(n=this._breakpoint,this._ended=2),0!=this._repeat){var o=Math.floor(n/this._duration);n-=this._duration*o,this._yoyo&&(e=o%2==1),this._repeat>0&&this._repeat-o<0&&(this._yoyo&&(e=this._repeat%2==1),n=this._duration,this._ended=1)}else n>=this._duration&&(n=this._duration,this._ended=1);if(this._normalizedTime=t.evaluateEase(this._easeType,e?this._duration-n:n,this._duration,this._easeOvershootOrAmplitude,this._easePeriod),this._value.setZero(),this._deltaValue.setZero(),5==this._valueSize)if(0==this._ended){var r=this._startValue.w*(1-this._normalizedTime),s=r*(Math.random()>.5?1:-1),a=r*(Math.random()>.5?1:-1);this._deltaValue.x=s,this._deltaValue.y=a,this._value.x=this._startValue.x+s,this._value.y=this._startValue.y+a}else this._value.x=this._startValue.x,this._value.y=this._startValue.y;else if(this._path){var h=i;this._path.getPointAt(this._normalizedTime,h),this._snapping&&(h.x=Math.round(h.x),h.y=Math.round(h.y)),this._deltaValue.x=h.x-this._value.x,this._deltaValue.y=h.y-this._value.y,this._value.x=h.x,this._value.y=h.y}else for(var l=0;l=this._delay+this._duration&&(this._ended=1)},e.prototype.callStartCallback=function(){if(null!=this._onStart)try{this._onStart.call(this._onStartCaller,this)}catch(t){console.log("FairyGUI: error in start callback > "+t)}},e.prototype.callUpdateCallback=function(){if(null!=this._onUpdate)try{this._onUpdate.call(this._onUpdateCaller,this)}catch(t){console.log("FairyGUI: error in update callback > "+t)}},e.prototype.callCompleteCallback=function(){if(null!=this._onComplete)try{this._onComplete.call(this._onCompleteCaller,this)}catch(t){console.log("FairyGUI: error in complete callback > "+t)}},e}();t.GTweener=e;var i=new egret.Point}(fgui||(fgui={})),function(t){var e=function(){function e(){}return e.createTween=function(){var a;return i||(egret.startTick(e.update,null),i=!0,s=egret.getTimer()),(a=o.length>0?o.pop():new t.GTweener)._init(),n[r++]=a,r==n.length&&(n.length=n.length+Math.ceil(.5*n.length)),a},e.isTweening=function(t,e){if(null==t)return!1;for(var i=null==e,o=0;o=0){if(r!=a){var u=a;for(a=r-a,l=0;l>16,this.y=(65280&t)>>8,this.z=255&t,this.w=(4278190080&t)>>24},enumerable:!0,configurable:!0}),t.prototype.getField=function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("Index out of bounds: "+t)}},t.prototype.setField=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("Index out of bounds: "+t)}},t.prototype.setZero=function(){this.x=this.y=this.z=this.w=0},t}();t.TweenValue=e}(fgui||(fgui={})),function(t){var e=function(t){function e(e,i){var n=t.call(this,e,i)||this;return n.version=0,n}return __extends(e,t),e.prototype.skip=function(t){this.position+=t},e.prototype.readBool=function(){return 1==this.readByte()},e.prototype.readS=function(){var t=this.readUnsignedShort();return 65534==t?null:65533==t?"":this.stringTable[t]},e.prototype.readSArray=function(t){for(var e=new Array(t),i=0;i0?(this.position=t+i,!0):(this.position=n,!1)):(this.position=n,!1)},e}(egret.ByteArray);t.ByteBuffer=e}(fgui||(fgui={})),function(t){var e=function(){function t(t,e,i,o){this.matrix=new Array(n),this.reset(),void 0===t&&void 0===e&&void 0===i&&void 0===o||this.adjustColor(t,e,i,o)}return t.prototype.reset=function(){for(var t=0;t=this.delay&&(this.counter-=this.delay,this.counter>this.delay&&(this.counter=this.delay),this.repeat>0&&(this.repeat--,0==this.repeat&&(this.end=!0)),!0)},t.prototype.reset=function(){this.callback=null,this.thisObj=null,this.param=null},t}()}(fgui||(fgui={})),function(t){var e=function(){function t(){this._readPos=0,this.smallFontSize=12,this.normalFontSize=14,this.largeFontSize=16,this.defaultImgWidth=0,this.defaultImgHeight=0,this._handlers={},this._handlers.url=this.onTag_URL,this._handlers.img=this.onTag_IMG,this._handlers.b=this.onTag_Simple,this._handlers.i=this.onTag_Simple,this._handlers.u=this.onTag_Simple,this._handlers.sup=this.onTag_Simple,this._handlers.sub=this.onTag_Simple,this._handlers.color=this.onTag_COLOR,this._handlers.font=this.onTag_FONT,this._handlers.size=this.onTag_SIZE}return t.prototype.onTag_URL=function(t,e,i){return e?"":null!=i?'':''},t.prototype.onTag_IMG=function(t,e,i){if(e)return null;var n=this.getTagText(!0);return n?this.defaultImgWidth?'':'':null},t.prototype.onTag_Simple=function(t,e,i){return e?"":"<"+t+">"},t.prototype.onTag_COLOR=function(t,e,i){return e?"":''},t.prototype.onTag_FONT=function(t,e,i){return e?"":''},t.prototype.onTag_SIZE=function(t,e,i){return e?"":("normal"==i?i=""+this.normalFontSize:"small"==i?i=""+this.smallFontSize:"large"==i?i=""+this.largeFontSize:i.length&&"+"==i.charAt(0)?i=""+(this.smallFontSize+parseInt(i.substr(1))):i.length&&"-"==i.charAt(0)&&(i=""+(this.smallFontSize-parseInt(i.substr(1)))),'')},t.prototype.getTagText=function(t){void 0===t&&(t=!1);for(var e,i=this._readPos,n="";-1!=(e=this._text.indexOf("[",i));){if(92!=this._text.charCodeAt(e-1)){n+=this._text.substring(i,e);break}n+=this._text.substring(i,e-1),n+="[",i=e+1}return-1==e?null:(t&&(this._readPos=e),n)},t.prototype.parse=function(t,e){this._text=t;for(var i,n,o,r,s,a,h,l=0,c="";-1!=(i=this._text.indexOf("[",l));)if(i>0&&92==this._text.charCodeAt(i-1))c+=this._text.substring(l,i-1),c+="[",l=i+1;else{if(c+=this._text.substring(l,i),l=i,-1==(i=this._text.indexOf("]",l)))break;o="/"==this._text.charAt(l+1),r=this._text.substring(o?l+2:l+1,i),this._readPos=i+1,s=null,a=null,-1!=(n=r.indexOf("="))&&(s=r.substring(n+1),r=r.substring(0,n)),r=r.toLowerCase(),null!=(h=this._handlers[r])?e||null!=(a=h.call(this,r,o,s))&&(c+=a):c+=this._text.substring(l,this._readPos),l=this._readPos}return l=0&&(" "==(e=t.charAt(i))||"\n"==e||"\r"==e);i--);return t.substring(0,i+1)},e.convertToHtmlColor=function(t,e){var i;i=e?(t>>24&255).toString(16):"";var n=(t>>16&255).toString(16),o=(t>>8&255).toString(16),r=(255&t).toString(16);return 1==i.length&&(i="0"+i),1==n.length&&(n="0"+n),1==o.length&&(o="0"+o),1==r.length&&(r="0"+r),"#"+i+n+o+r},e.convertFromHtmlColor=function(t,e){return t.length<1?0:("#"==t.charAt(0)&&(t=t.substr(1)),8==t.length?(parseInt(t.substr(0,2),16)<<24)+parseInt(t.substr(2),16):e?4278190080+parseInt(t,16):parseInt(t,16))},e.displayObjectToGObject=function(e){for(;e&&!(e instanceof egret.Stage);){if(e.$owner)return t.GObject.cast(e);e=e.parent}return null},e.encodeHTML=function(t){return t?t.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,"""):""},e.clamp=function(t,e,i){return ti&&(t=i),t},e.clamp01=function(t){return t>1?t=1:t<0&&(t=0),t},e.lerp=function(t,e,i){return t+i*(e-t)},e.repeat=function(t,e){return t-Math.floor(t/e)*e},e.distance=function(t,e,i,n){return Math.sqrt(Math.pow(t-i,2)+Math.pow(e-n,2))},e.fillPath=function(t,e,i,n){var o=e.length;t.moveTo(e[0]+i,e[1]+n);for(var r=2;r>16&255)/255,l[6]=(o>>8&255)/255,l[12]=(255&o)/255}a.matrix=l}else if(h&&a){var _=h.indexOf(a);-1!=_&&(h.splice(_,1),h.length>0?e.filters=h:e.filters=null)}},e}();t.ToolSet=e;var i=[.3,.6,0,0,0,.3,.6,0,0,0,.3,.6,0,0,0,0,0,0,1,0],n=new t.ColorMatrix}(fgui||(fgui={})); \ No newline at end of file diff --git a/demo/libs/framework/framework.d.ts b/demo/libs/framework/framework.d.ts deleted file mode 100644 index 5b23c9a5..00000000 --- a/demo/libs/framework/framework.d.ts +++ /dev/null @@ -1,2638 +0,0 @@ -declare interface Array { - findIndex(predicate: (c: T) => boolean): number; - any(predicate: (c: T) => boolean): boolean; - firstOrDefault(predicate: (c: T) => boolean): T; - find(predicate: (c: T) => boolean): T; - where(predicate: (c: T) => boolean): Array; - count(predicate: (c: T) => boolean): number; - findAll(predicate: (c: T) => boolean): Array; - contains(value: T): boolean; - removeAll(predicate: (c: T) => boolean): void; - remove(element: T): boolean; - removeAt(index: number): void; - removeRange(index: number, count: number): void; - select(selector: Function): Array; - orderBy(keySelector: Function, comparer: Function): Array; - orderByDescending(keySelector: Function, comparer: Function): Array; - groupBy(keySelector: Function): Array; - sum(selector: Function): number; -} -declare module es { - class PriorityQueueNode { - priority: number; - insertionIndex: number; - queueIndex: number; - } -} -declare module es { - class AStarPathfinder { - static search(graph: IAstarGraph, start: T, goal: T): T[]; - static recontructPath(cameFrom: Map, start: T, goal: T): T[]; - private static hasKey; - private static getKey; - } -} -declare module es { - class AstarGridGraph implements IAstarGraph { - dirs: Vector2[]; - walls: Vector2[]; - weightedNodes: Vector2[]; - defaultWeight: number; - weightedNodeWeight: number; - private _width; - private _height; - private _neighbors; - constructor(width: number, height: number); - isNodeInBounds(node: Vector2): boolean; - isNodePassable(node: Vector2): boolean; - search(start: Vector2, goal: Vector2): Vector2[]; - getNeighbors(node: Vector2): Vector2[]; - cost(from: Vector2, to: Vector2): number; - heuristic(node: Vector2, goal: Vector2): number; - } -} -declare module es { - interface IAstarGraph { - getNeighbors(node: T): Array; - cost(from: T, to: T): number; - heuristic(node: T, goal: T): any; - } -} -declare module es { - class PriorityQueue { - private _numNodes; - private _nodes; - private _numNodesEverEnqueued; - constructor(maxNodes: number); - readonly count: number; - readonly maxSize: number; - clear(): void; - contains(node: T): boolean; - enqueue(node: T, priority: number): void; - dequeue(): T; - remove(node: T): void; - isValidQueue(): boolean; - private onNodeUpdated; - private cascadeDown; - private cascadeUp; - private swap; - private hasHigherPriority; - } -} -declare module es { - class BreadthFirstPathfinder { - static search(graph: IUnweightedGraph, start: T, goal: T): T[]; - private static hasKey; - } -} -declare module es { - interface IUnweightedGraph { - getNeighbors(node: T): T[]; - } -} -declare module es { - class UnweightedGraph implements IUnweightedGraph { - edges: Map; - addEdgesForNode(node: T, edges: T[]): this; - getNeighbors(node: T): T[]; - } -} -declare module es { - class Vector2 implements IEquatable { - x: number; - y: number; - constructor(x?: number, y?: number); - static readonly zero: Vector2; - static readonly one: Vector2; - static readonly unitX: Vector2; - static readonly unitY: Vector2; - static add(value1: Vector2, value2: Vector2): Vector2; - static divide(value1: Vector2, value2: Vector2): Vector2; - static multiply(value1: Vector2, value2: Vector2): Vector2; - static subtract(value1: Vector2, value2: Vector2): Vector2; - static normalize(value: Vector2): Vector2; - static dot(value1: Vector2, value2: Vector2): number; - static distanceSquared(value1: Vector2, value2: Vector2): number; - static clamp(value1: Vector2, min: Vector2, max: Vector2): Vector2; - static lerp(value1: Vector2, value2: Vector2, amount: number): Vector2; - static transform(position: Vector2, matrix: Matrix2D): Vector2; - static distance(value1: Vector2, value2: Vector2): number; - static angle(from: Vector2, to: Vector2): number; - static negate(value: Vector2): Vector2; - add(value: Vector2): Vector2; - divide(value: Vector2): Vector2; - multiply(value: Vector2): Vector2; - subtract(value: Vector2): this; - normalize(): void; - length(): number; - lengthSquared(): number; - round(): Vector2; - equals(other: Vector2 | object): boolean; - } -} -declare module es { - class UnweightedGridGraph implements IUnweightedGraph { - private static readonly CARDINAL_DIRS; - private static readonly COMPASS_DIRS; - walls: Vector2[]; - private _width; - private _hegiht; - private _dirs; - private _neighbors; - constructor(width: number, height: number, allowDiagonalSearch?: boolean); - isNodeInBounds(node: Vector2): boolean; - isNodePassable(node: Vector2): boolean; - getNeighbors(node: Vector2): Vector2[]; - search(start: Vector2, goal: Vector2): Vector2[]; - } -} -declare module es { - interface IWeightedGraph { - getNeighbors(node: T): T[]; - cost(from: T, to: T): number; - } -} -declare module es { - class WeightedGridGraph implements IWeightedGraph { - static readonly CARDINAL_DIRS: Vector2[]; - private static readonly COMPASS_DIRS; - walls: Vector2[]; - weightedNodes: Vector2[]; - defaultWeight: number; - weightedNodeWeight: number; - private _width; - private _height; - private _dirs; - private _neighbors; - constructor(width: number, height: number, allowDiagonalSearch?: boolean); - isNodeInBounds(node: Vector2): boolean; - isNodePassable(node: Vector2): boolean; - search(start: Vector2, goal: Vector2): Vector2[]; - getNeighbors(node: Vector2): Vector2[]; - cost(from: Vector2, to: Vector2): number; - } -} -declare module es { - class WeightedNode extends PriorityQueueNode { - data: T; - constructor(data: T); - } - class WeightedPathfinder { - static search(graph: IWeightedGraph, start: T, goal: T): T[]; - static recontructPath(cameFrom: Map, start: T, goal: T): T[]; - private static hasKey; - private static getKey; - } -} -declare module es { - class AStarStorage { - static readonly MAX_NODES: number; - _opened: AStarNode[]; - _closed: AStarNode[]; - _numOpened: number; - _numClosed: number; - _lastFoundOpened: number; - _lastFoundClosed: number; - constructor(); - clear(): void; - findOpened(node: AStarNode): AStarNode; - findClosed(node: AStarNode): AStarNode; - hasOpened(): boolean; - removeOpened(node: AStarNode): void; - removeClosed(node: AStarNode): void; - isOpen(node: AStarNode): boolean; - isClosed(node: AStarNode): boolean; - addToOpenList(node: AStarNode): void; - addToClosedList(node: AStarNode): void; - removeCheapestOpenNode(): AStarNode; - } -} -declare module es { - class AStarNode implements IEquatable, IPoolable { - worldState: WorldState; - costSoFar: number; - heuristicCost: number; - costSoFarAndHeuristicCost: number; - action: Action; - parent: AStarNode; - parentWorldState: WorldState; - depth: number; - equals(other: AStarNode): boolean; - compareTo(other: AStarNode): number; - reset(): void; - clone(): AStarNode; - toString(): string; - } - class AStar { - static storage: AStarStorage; - static plan(ap: ActionPlanner, start: WorldState, goal: WorldState, selectedNodes?: AStarNode[]): Action[]; - static reconstructPlan(goalNode: AStarNode, selectedNodes: AStarNode[]): Action[]; - static calculateHeuristic(fr: WorldState, to: WorldState): number; - } -} -declare module es { - class Action { - name: string; - cost: number; - _preConditions: Set<[string, boolean]>; - _postConditions: Set<[string, boolean]>; - constructor(name?: string, cost?: number); - setPrecondition(conditionName: string, value: boolean): void; - setPostcondition(conditionName: string, value: boolean): void; - validate(): boolean; - toString(): string; - } -} -declare module es { - class ActionPlanner { - static readonly MAX_CONDITIONS: number; - conditionNames: string[]; - _actions: Action[]; - _viableActions: Action[]; - _preConditions: WorldState[]; - _postConditions: WorldState[]; - _numConditionNames: number; - constructor(); - createWorldState(): WorldState; - addAction(action: Action): void; - plan(startState: WorldState, goalState: WorldState, selectedNode?: any): Action[]; - getPossibleTransitions(fr: WorldState): AStarNode[]; - applyPostConditions(ap: ActionPlanner, actionnr: number, fr: WorldState): WorldState; - findConditionNameIndex(conditionName: string): any; - findActionIndex(action: Action): number; - } -} -declare module es { - abstract class Agent { - actions: Action[]; - _planner: ActionPlanner; - constructor(); - plan(debugPlan?: boolean): boolean; - hasActionPlan(): boolean; - abstract getWorldState(): WorldState; - abstract getGoalState(): WorldState; - } -} -declare module es { - class WorldState implements IEquatable { - values: number; - dontCare: number; - planner: ActionPlanner; - static create(planner: ActionPlanner): WorldState; - constructor(planner: ActionPlanner, values: number, dontcare: number); - set(conditionId: number | string, value: boolean): boolean; - equals(other: WorldState): boolean; - describe(planner: ActionPlanner): string; - } -} -declare module es { - class Core extends egret.DisplayObjectContainer { - static emitter: Emitter; - static debugRenderEndabled: boolean; - static graphicsDevice: GraphicsDevice; - static content: ContentManager; - static _instance: Core; - _nextScene: Scene; - _sceneTransition: SceneTransition; - _globalManagers: GlobalManager[]; - _coroutineManager: CoroutineManager; - _timerManager: TimerManager; - constructor(); - static readonly Instance: Core; - _frameCounterElapsedTime: number; - _frameCounter: number; - _scene: Scene; - static scene: Scene; - static startSceneTransition(sceneTransition: T): T; - static registerGlobalManager(manager: es.GlobalManager): void; - static unregisterGlobalManager(manager: es.GlobalManager): void; - static getGlobalManager(type: any): T; - static startCoroutine(enumerator: Iterator): CoroutineImpl; - static schedule(timeInSeconds: number, repeats: boolean, context: any, onTime: (timer: ITimer) => void): Timer; - onOrientationChanged(): void; - draw(): Promise; - startDebugUpdate(): void; - endDebugUpdate(): void; - startDebugDraw(elapsedGameTime: number): void; - endDebugDraw(): void; - onSceneChanged(): void; - protected onGraphicsDeviceReset(): void; - protected initialize(): void; - protected update(): Promise; - private onAddToStage; - } -} -declare module es { - class Colors { - static renderableBounds: number; - static renderableCenter: number; - static colliderBounds: number; - static colliderEdge: number; - static colliderPosition: number; - static colliderCenter: number; - } - class Size { - static readonly lineSizeMultiplier: number; - } - class Debug { - private static _debugDrawItems; - static drawHollowRect(rectanle: Rectangle, color: number, duration?: number): void; - static render(): void; - } -} -declare module es { - class DebugDefaults { - static verletParticle: number; - static verletConstraintEdge: number; - } -} -declare module es { - enum DebugDrawType { - line = 0, - hollowRectangle = 1, - pixel = 2, - text = 3 - } - class DebugDrawItem { - rectangle: Rectangle; - color: number; - duration: number; - drawType: DebugDrawType; - text: string; - start: Vector2; - end: Vector2; - x: number; - y: number; - size: number; - constructor(rectangle: Rectangle, color: number, duration: number); - draw(shape: egret.Shape): boolean; - } -} -declare module es { - abstract class Component extends egret.HashObject { - entity: Entity; - updateInterval: number; - debugDisplayObject: egret.DisplayObjectContainer; - readonly transform: Transform; - private _enabled; - enabled: boolean; - private _updateOrder; - updateOrder: number; - initialize(): void; - onAddedToEntity(): void; - onRemovedFromEntity(): void; - onEntityTransformChanged(comp: transform.Component): void; - debugRender(camera: Camera): void; - onEnabled(): void; - onDisabled(): void; - update(): void; - setEnabled(isEnabled: boolean): this; - setUpdateOrder(updateOrder: number): this; - } -} -declare module es { - enum CoreEvents { - GraphicsDeviceReset = 0, - SceneChanged = 1, - OrientationChanged = 2 - } -} -declare module es { - class Entity { - static _idGenerator: number; - scene: Scene; - name: string; - readonly id: number; - readonly transform: Transform; - readonly components: ComponentList; - updateInterval: number; - componentBits: BitSet; - constructor(name: string); - _isDestroyed: boolean; - readonly isDestroyed: boolean; - private _tag; - tag: number; - private _enabled; - enabled: boolean; - private _updateOrder; - updateOrder: number; - parent: Transform; - readonly childCount: number; - position: Vector2; - localPosition: Vector2; - rotation: number; - rotationDegrees: number; - localRotation: number; - localRotationDegrees: number; - scale: Vector2; - localScale: Vector2; - readonly worldInverseTransform: Matrix2D; - readonly localToWorldTransform: Matrix2D; - readonly worldToLocalTransform: Matrix2D; - onTransformChanged(comp: transform.Component): void; - setTag(tag: number): Entity; - setEnabled(isEnabled: boolean): this; - setUpdateOrder(updateOrder: number): this; - destroy(): void; - detachFromScene(): void; - attachToScene(newScene: Scene): void; - onAddedToScene(): void; - onRemovedFromScene(): void; - update(): void; - debugRender(camera: Camera): void; - addComponent(component: T): T; - getComponent(type: any): T; - hasComponent(type: any): boolean; - getOrCreateComponent(type: T): T; - getComponents(typeName: string | any, componentList?: any): any; - removeComponent(component: Component): void; - removeComponentForType(type: any): boolean; - removeAllComponents(): void; - compareTo(other: Entity): number; - toString(): string; - } -} -declare module es { - class Scene extends egret.DisplayObjectContainer { - camera: Camera; - readonly content: ContentManager; - enablePostProcessing: boolean; - readonly entities: EntityList; - readonly renderableComponents: RenderableComponentList; - readonly entityProcessors: EntityProcessorList; - _screenshotRequestCallback: Function; - readonly _sceneComponents: SceneComponent[]; - _renderers: Renderer[]; - readonly _postProcessors: PostProcessor[]; - _didSceneBegin: any; - dynamicBatch: boolean; - constructor(); - static createWithDefaultRenderer(): Scene; - initialize(): void; - onStart(): Promise; - unload(): void; - onActive(): void; - onDeactive(): void; - begin(): void; - end(): void; - updateResolutionScaler(): void; - update(): void; - render(): void; - dynamicInBatch(): void; - postRender(): void; - requestScreenshot(callback: Function): void; - addSceneComponent(component: T): T; - getSceneComponent(type: any): T; - getOrCreateSceneComponent(type: any): T; - removeSceneComponent(component: SceneComponent): void; - addRenderer(renderer: T): T; - getRenderer(type: any): T; - removeRenderer(renderer: Renderer): void; - addPostProcessor(postProcessor: T): T; - getPostProcessor(type: any): T; - removePostProcessor(postProcessor: PostProcessor): void; - createEntity(name: string): Entity; - addEntity(entity: Entity): Entity; - destroyAllEntities(): void; - findEntity(name: string): Entity; - findEntitiesWithTag(tag: number): Entity[]; - entitiesOfType(type: any): T[]; - findComponentOfType(type: any): T; - findComponentsOfType(type: any): T[]; - addEntityProcessor(processor: EntitySystem): EntitySystem; - removeEntityProcessor(processor: EntitySystem): void; - getEntityProcessor(): T; - } -} -declare module transform { - enum Component { - position = 0, - scale = 1, - rotation = 2 - } -} -declare module es { - import HashObject = egret.HashObject; - enum DirtyType { - clean = 0, - positionDirty = 1, - scaleDirty = 2, - rotationDirty = 3 - } - class Transform extends HashObject { - readonly entity: Entity; - hierarchyDirty: DirtyType; - _localDirty: boolean; - _localPositionDirty: boolean; - _localScaleDirty: boolean; - _localRotationDirty: boolean; - _positionDirty: boolean; - _worldToLocalDirty: boolean; - _worldInverseDirty: boolean; - _localTransform: Matrix2D; - _worldTransform: Matrix2D; - _rotationMatrix: Matrix2D; - _translationMatrix: Matrix2D; - _scaleMatrix: Matrix2D; - _children: Transform[]; - constructor(entity: Entity); - readonly childCount: number; - rotationDegrees: number; - localRotationDegrees: number; - readonly localToWorldTransform: Matrix2D; - _parent: Transform; - parent: Transform; - _worldToLocalTransform: Matrix2D; - readonly worldToLocalTransform: Matrix2D; - _worldInverseTransform: Matrix2D; - readonly worldInverseTransform: Matrix2D; - _position: Vector2; - position: Vector2; - _scale: Vector2; - scale: Vector2; - _rotation: number; - rotation: number; - _localPosition: Vector2; - localPosition: Vector2; - _localScale: Vector2; - localScale: Vector2; - _localRotation: number; - localRotation: number; - getChild(index: number): Transform; - setParent(parent: Transform): Transform; - setPosition(x: number, y: number): Transform; - setLocalPosition(localPosition: Vector2): Transform; - setRotation(radians: number): Transform; - setRotationDegrees(degrees: number): Transform; - lookAt(pos: Vector2): void; - setLocalRotation(radians: number): this; - setLocalRotationDegrees(degrees: number): Transform; - setScale(scale: Vector2): Transform; - setLocalScale(scale: Vector2): Transform; - roundPosition(): void; - updateTransform(): void; - setDirty(dirtyFlagType: DirtyType): void; - copyFrom(transform: Transform): void; - toString(): string; - equals(other: Transform): boolean; - } -} -declare module es { - interface CameraInset { - left: number; - right: number; - top: number; - bottom: number; - } - class Camera extends Component { - _inset: CameraInset; - _areMatrixedDirty: boolean; - _areBoundsDirty: boolean; - _isProjectionMatrixDirty: boolean; - constructor(); - position: Vector2; - rotation: number; - rawZoom: number; - _zoom: number; - zoom: number; - _minimumZoom: number; - minimumZoom: number; - _maximumZoom: number; - maximumZoom: number; - _bounds: Rectangle; - readonly bounds: Rectangle; - _transformMatrix: Matrix2D; - readonly transformMatrix: Matrix2D; - _inverseTransformMatrix: Matrix2D; - readonly inverseTransformMatrix: Matrix2D; - _origin: Vector2; - origin: Vector2; - setInset(left: number, right: number, top: number, bottom: number): Camera; - setPosition(position: Vector2): this; - setRotation(rotation: number): Camera; - setZoom(zoom: number): Camera; - setMinimumZoom(minZoom: number): Camera; - setMaximumZoom(maxZoom: number): Camera; - forceMatrixUpdate(): void; - onEntityTransformChanged(comp: transform.Component): void; - zoomIn(deltaZoom: number): void; - zoomOut(deltaZoom: number): void; - worldToScreenPoint(worldPosition: Vector2): Vector2; - screenToWorldPoint(screenPosition: Vector2): Vector2; - onSceneRenderTargetSizeChanged(newWidth: number, newHeight: number): void; - mouseToWorldPoint(): Vector2; - protected updateMatrixes(): void; - } -} -declare module es { - class CameraShake extends Component { - _shakeDirection: Vector2; - _shakeOffset: Vector2; - _shakeIntensity: number; - _shakeDegredation: number; - shake(shakeIntensify?: number, shakeDegredation?: number, shakeDirection?: Vector2): void; - update(): void; - } -} -declare module es { - class ComponentPool { - private _cache; - private _type; - constructor(typeClass: any); - obtain(): T; - free(component: T): void; - } -} -declare module es { - enum CameraStyle { - lockOn = 0, - cameraWindow = 1 - } - class FollowCamera extends Component { - camera: Camera; - followLerp: number; - deadzone: Rectangle; - focusOffset: Vector2; - mapLockEnabled: boolean; - mapSize: Rectangle; - _targetEntity: Entity; - _targetCollider: Collider; - _desiredPositionDelta: Vector2; - _cameraStyle: CameraStyle; - _worldSpaceDeadZone: Rectangle; - private rectShape; - constructor(targetEntity?: Entity, camera?: Camera, cameraStyle?: CameraStyle); - onAddedToEntity(): void; - onGraphicsDeviceReset(): void; - update(): void; - debugRender(camera: Camera): void; - clampToMapSize(position: Vector2): Vector2; - follow(targetEntity: Entity, cameraStyle?: CameraStyle): void; - updateFollow(): void; - setCenteredDeadzone(width: number, height: number): void; - } -} -declare module es { - interface IUpdatable { - enabled: boolean; - updateOrder: number; - update(): any; - } - class IUpdatableComparer implements IComparer { - compare(a: Component, b: Component): number; - } -} -declare module es { - abstract class PooledComponent extends Component { - abstract reset(): any; - } -} -declare module es { - class SceneComponent { - scene: Scene; - enabled: boolean; - updateOrder: number; - _enabled: boolean; - onEnabled(): void; - onDisabled(): void; - onRemovedFromScene(): void; - update(): void; - setEnabled(isEnabled: boolean): SceneComponent; - setUpdateOrder(updateOrder: number): this; - compareTo(other: SceneComponent): number; - } -} -declare module es { - interface ITriggerListener { - onTriggerEnter(other: Collider, local: Collider): any; - onTriggerExit(other: Collider, local: Collider): any; - } -} -declare module es { - class Mover extends Component { - private _triggerHelper; - onAddedToEntity(): void; - calculateMovement(motion: Vector2, collisionResult: CollisionResult): boolean; - applyMovement(motion: Vector2): void; - move(motion: Vector2, collisionResult: CollisionResult): boolean; - } -} -declare module es { - class ProjectileMover extends Component { - private _tempTriggerList; - private _collider; - onAddedToEntity(): void; - move(motion: Vector2): boolean; - private notifyTriggerListeners; - } -} -declare module es { - abstract class Collider extends Component { - shape: Shape; - isTrigger: boolean; - physicsLayer: Ref; - collidesWithLayers: Ref; - shouldColliderScaleAndRotateWithTransform: boolean; - registeredPhysicsBounds: Rectangle; - _localOffsetLength: number; - _isPositionDirty: boolean; - _isRotationDirty: boolean; - protected _colliderRequiresAutoSizing: any; - protected _isParentEntityAddedToScene: any; - protected _isColliderRegistered: any; - readonly absolutePosition: Vector2; - readonly rotation: number; - readonly bounds: Rectangle; - protected _localOffset: Vector2; - localOffset: Vector2; - setLocalOffset(offset: Vector2): Collider; - setShouldColliderScaleAndRotateWithTransform(shouldColliderScaleAndRotationWithTransform: boolean): Collider; - onAddedToEntity(): void; - onRemovedFromEntity(): void; - onEntityTransformChanged(comp: transform.Component): void; - onEnabled(): void; - onDisabled(): void; - registerColliderWithPhysicsSystem(): void; - unregisterColliderWithPhysicsSystem(): void; - overlaps(other: Collider): boolean; - collidesWith(collider: Collider, motion: Vector2, result: CollisionResult): boolean; - } -} -declare module es { - class BoxCollider extends Collider { - hollowShape: egret.Shape; - polygonShape: egret.Shape; - pixelShape1: egret.Shape; - pixelShape2: egret.Shape; - constructor(x?: number, y?: number, width?: number, height?: number); - width: number; - height: number; - setSize(width: number, height: number): this; - setWidth(width: number): BoxCollider; - setHeight(height: number): void; - debugRender(camera: Camera): void; - toString(): string; - } -} -declare module es { - class CircleCollider extends Collider { - private rectShape; - private circleShape; - private pixelShape1; - private pixelShape2; - constructor(radius?: number); - radius: number; - setRadius(radius: number): CircleCollider; - debugRender(camera: Camera): void; - toString(): string; - } -} -declare module es { - class PolygonCollider extends Collider { - constructor(points: Vector2[]); - } -} -declare module es { - abstract class RenderableComponent extends Component implements IRenderable { - displayObject: egret.DisplayObject; - hollowShape: egret.Shape; - pixelShape: egret.Shape; - color: number; - protected _areBoundsDirty: boolean; - readonly width: number; - readonly height: number; - debugRenderEnabled: boolean; - protected _localOffset: Vector2; - localOffset: Vector2; - protected _renderLayer: number; - renderLayer: number; - protected _bounds: Rectangle; - readonly bounds: Rectangle; - private _isVisible; - isVisible: boolean; - onEntityTransformChanged(comp: transform.Component): void; - abstract render(camera: Camera): any; - debugRender(camera: Camera): void; - isVisibleFromCamera(camera: Camera): boolean; - setRenderLayer(renderLayer: number): RenderableComponent; - setColor(color: number): RenderableComponent; - setLocalOffset(offset: Vector2): RenderableComponent; - sync(camera: Camera): void; - compareTo(other: RenderableComponent): number; - toString(): string; - protected onBecameVisible(): void; - protected onBecameInvisible(): void; - } -} -declare module es { - class Mesh extends RenderableComponent { - displayObject: egret.Mesh; - readonly bounds: Rectangle; - _primitiveCount: number; - _topLeftVertPosition: Vector2; - _width: number; - _height: number; - _triangles: number[]; - _verts: VertexPositionColorTexture[]; - recalculateBounds(recalculateUVs: boolean): this; - setTexture(texture: egret.Texture): Mesh; - setVertPositions(positions: Vector2[]): this; - setTriangles(triangles: number[]): this; - render(camera: es.Camera): void; - } - class VertexPositionColorTexture { - position: Vector2; - textureCoordinate: Vector2; - } -} -declare module es { - class SpriteRenderer extends RenderableComponent { - constructor(sprite?: Sprite | egret.Texture); - readonly bounds: Rectangle; - originNormalized: Vector2; - protected _origin: Vector2; - origin: Vector2; - protected _sprite: Sprite; - sprite: Sprite; - setSprite(sprite: Sprite): SpriteRenderer; - setOrigin(origin: Vector2): SpriteRenderer; - setOriginNormalized(value: Vector2): SpriteRenderer; - render(camera: Camera): void; - } -} -declare module es { - class TiledSpriteRenderer extends SpriteRenderer { - readonly bounds: Rectangle; - scrollX: number; - scrollY: number; - textureScale: Vector2; - width: number; - height: number; - gapXY: Vector2; - protected _sourceRect: Rectangle; - protected _textureScale: Vector2; - protected _inverseTexScale: Vector2; - private _gapX; - private _gapY; - constructor(sprite: Sprite); - setGapXY(value: Vector2): TiledSpriteRenderer; - render(camera: es.Camera): void; - } -} -declare module es { - class ScrollingSpriteRenderer extends TiledSpriteRenderer { - scrollSpeedX: number; - scroolSpeedY: number; - textureScale: Vector2; - scrollWidth: number; - scrollHeight: number; - private _scrollX; - private _scrollY; - private _scrollWidth; - private _scrollHeight; - constructor(sprite: Sprite); - update(): void; - } -} -declare module es { - class Sprite { - texture2D: egret.Texture; - readonly sourceRect: Rectangle; - readonly center: Vector2; - origin: Vector2; - readonly uvs: Rectangle; - constructor(texture: egret.Texture, sourceRect?: Rectangle, origin?: Vector2); - static spritesFromAtlas(texture: egret.Texture, cellWidth: number, cellHeight: number, cellOffset?: number, maxCellsToInclude?: number): Sprite[]; - } -} -declare module es { - class SpriteAnimation { - readonly sprites: Sprite[]; - readonly frameRate: number; - constructor(sprites: Sprite[], frameRate?: number); - } -} -declare module es { - enum LoopMode { - loop = 0, - once = 1, - clampForever = 2, - pingPong = 3, - pingPongOnce = 4 - } - enum State { - none = 0, - running = 1, - paused = 2, - completed = 3 - } - class SpriteAnimator extends SpriteRenderer { - onAnimationCompletedEvent: (string: any) => {}; - speed: number; - animationState: State; - currentAnimation: SpriteAnimation; - currentAnimationName: string; - currentFrame: number; - _elapsedTime: number; - _loopMode: LoopMode; - constructor(sprite?: Sprite); - readonly isRunning: boolean; - private _animations; - readonly animations: Map; - update(): void; - addAnimation(name: string, animation: SpriteAnimation): SpriteAnimator; - play(name: string, loopMode?: LoopMode): void; - isAnimationActive(name: string): boolean; - pause(): void; - unPause(): void; - stop(): void; - } -} -declare module es { - import Bitmap = egret.Bitmap; - class StaticSpriteContainerRenderer extends RenderableComponent { - displayObject: egret.DisplayObjectContainer; - private displayObjectCache; - constructor(sprite?: Sprite[] | egret.Texture[]); - readonly bounds: Rectangle; - originNormalized: Vector2; - protected _origin: Vector2; - origin: Vector2; - pushSprite(sprite: Sprite): StaticSpriteContainerRenderer; - getSprite(sprite: Sprite): Bitmap; - setOrigin(origin: Vector2): StaticSpriteContainerRenderer; - setOriginNormalized(value: Vector2): StaticSpriteContainerRenderer; - render(camera: Camera): void; - } -} -declare module es { - class EntitySystem { - private _entities; - constructor(matcher?: Matcher); - private _scene; - scene: Scene; - private _matcher; - readonly matcher: Matcher; - initialize(): void; - onChanged(entity: Entity): void; - add(entity: Entity): void; - onAdded(entity: Entity): void; - remove(entity: Entity): void; - onRemoved(entity: Entity): void; - update(): void; - lateUpdate(): void; - protected begin(): void; - protected process(entities: Entity[]): void; - protected lateProcess(entities: Entity[]): void; - protected end(): void; - } -} -declare module es { - abstract class EntityProcessingSystem extends EntitySystem { - constructor(matcher: Matcher); - abstract processEntity(entity: Entity): any; - lateProcessEntity(entity: Entity): void; - protected process(entities: Entity[]): void; - protected lateProcess(entities: Entity[]): void; - } -} -declare module es { - abstract class PassiveSystem extends EntitySystem { - onChanged(entity: Entity): void; - protected process(entities: Entity[]): void; - } -} -declare module es { - abstract class ProcessingSystem extends EntitySystem { - onChanged(entity: Entity): void; - abstract processSystem(): any; - protected process(entities: Entity[]): void; - } -} -declare module es { - class BitSet { - private static LONG_MASK; - private _bits; - constructor(nbits?: number); - and(bs: BitSet): void; - andNot(bs: BitSet): void; - cardinality(): number; - clear(pos?: number): void; - get(pos: number): boolean; - intersects(set: BitSet): boolean; - isEmpty(): boolean; - nextSetBit(from: number): number; - set(pos: number, value?: boolean): void; - private ensure; - } -} -declare module es { - class ComponentList { - static compareUpdatableOrder: IUpdatableComparer; - _entity: Entity; - _components: FastList; - _componentsToAdd: Component[]; - _componentsToRemove: Component[]; - _tempBufferList: Component[]; - _isComponentListUnsorted: boolean; - constructor(entity: Entity); - readonly count: number; - readonly buffer: Component[]; - markEntityListUnsorted(): void; - add(component: Component): void; - remove(component: Component): void; - removeAllComponents(): void; - deregisterAllComponents(): void; - registerAllComponents(): void; - updateLists(): void; - handleRemove(component: Component): void; - getComponent(type: any, onlyReturnInitializedComponents: boolean): T; - getComponents(typeName: string | any, components?: any): any; - update(): void; - onEntityTransformChanged(comp: transform.Component): void; - onEntityEnabled(): void; - onEntityDisabled(): void; - debugRender(camera: Camera): void; - } -} -declare module es { - class ComponentTypeManager { - private static _componentTypesMask; - static add(type: any): void; - static getIndexFor(type: any): number; - } -} -declare module es { - class EntityList { - scene: Scene; - _entities: Entity[]; - _entitiesToAdded: Entity[]; - _entitiesToRemove: Entity[]; - _isEntityListUnsorted: boolean; - _entityDict: Map; - _unsortedTags: Set; - _addToSceneEntityList: Entity[]; - frameAllocate: boolean; - maxAllocate: number; - constructor(scene: Scene); - readonly count: number; - readonly buffer: Entity[]; - markEntityListUnsorted(): void; - markTagUnsorted(tag: number): void; - add(entity: Entity): void; - remove(entity: Entity): void; - removeAllEntities(): void; - contains(entity: Entity): boolean; - getTagList(tag: number): Entity[]; - addToTagList(entity: Entity): void; - removeFromTagList(entity: Entity): void; - update(): void; - updateLists(): void; - private perEntityAddToScene; - findEntity(name: string): Entity; - entitiesWithTag(tag: number): Entity[]; - entitiesOfType(type: any): T[]; - findComponentOfType(type: any): T; - findComponentsOfType(type: any): T[]; - } -} -declare module es { - class EntityProcessorList { - protected _processors: EntitySystem[]; - add(processor: EntitySystem): void; - remove(processor: EntitySystem): void; - onComponentAdded(entity: Entity): void; - onComponentRemoved(entity: Entity): void; - onEntityAdded(entity: Entity): void; - onEntityRemoved(entity: Entity): void; - begin(): void; - update(): void; - lateUpdate(): void; - end(): void; - getProcessor(): T; - protected notifyEntityChanged(entity: Entity): void; - protected removeFromProcessors(entity: Entity): void; - } -} -declare module es { - class FasterDictionary { - _values: TValue[]; - _valuesInfo: FastNode[]; - _buckets: number[]; - _freeValueCellIndex: number; - _collisions: number; - constructor(size?: number); - getValuesArray(count: { - value: number; - }): TValue[]; - readonly valuesArray: TValue[]; - readonly count: number; - add(key: TKey, value: TValue): void; - addValue(key: TKey, value: TValue, indexSet: { - value: number; - }): boolean; - remove(key: TKey): boolean; - trim(): void; - clear(): void; - fastClear(): void; - containsKey(key: TKey): boolean; - tryGetValue(key: TKey): TValue; - tryFindIndex(key: TKey, findIndex: { - value: number; - }): boolean; - getDirectValue(index: number): TValue; - getIndex(key: TKey): number; - static updateLinkedList(index: number, valuesInfo: FastNode[]): void; - static hash(key: any): number; - static reduce(x: number, n: number): number; - } - class FastNode { - readonly key: any; - readonly hashcode: number; - previous: number; - next: number; - constructor(key: any, hash: number, previousNode?: number); - } -} -declare module es { - class FastList { - buffer: T[]; - length: number; - constructor(size?: number); - clear(): void; - reset(): void; - add(item: T): void; - remove(item: T): void; - removeAt(index: number): void; - contains(item: T): boolean; - ensureCapacity(additionalItemCount?: number): void; - addRange(array: T[]): void; - sort(comparer: IComparer): void; - } -} -declare module es { - class HashHelpers { - static readonly hashCollisionThreshold: number; - static readonly hashPrime: number; - static readonly primes: number[]; - static readonly maxPrimeArrayLength: number; - static isPrime(candidate: number): boolean; - static getPrime(min: number): number; - static expandPrime(oldSize: number): number; - static getHashCode(str: any): number; - } -} -declare module es { - class Matcher { - protected allSet: BitSet; - protected exclusionSet: BitSet; - protected oneSet: BitSet; - static empty(): Matcher; - getAllSet(): BitSet; - getExclusionSet(): BitSet; - getOneSet(): BitSet; - IsIntersted(e: Entity): boolean; - all(...types: any[]): Matcher; - exclude(...types: any[]): this; - one(...types: any[]): this; - } -} -declare class ObjectUtils { - static clone(p: any, c?: T): T; - static elements(p: {}): any[]; -} -declare module es { - interface IRenderable { - bounds: Rectangle; - enabled: boolean; - renderLayer: number; - isVisible: boolean; - isVisibleFromCamera(camera: Camera): any; - render(camera: Camera): any; - debugRender(camera: Camera): any; - } - class RenderableComparer { - compare(self: IRenderable, other: IRenderable): number; - } -} -declare module es { - class RenderableComponentList { - static compareUpdatableOrder: RenderableComparer; - _components: IRenderable[]; - _componentsByRenderLayer: Map; - _unsortedRenderLayers: number[]; - private _componentsNeedSort; - componentsNeedSort: boolean; - readonly count: number; - readonly buffer: IRenderable[]; - add(component: IRenderable): void; - remove(component: IRenderable): void; - updateRenderableRenderLayer(component: IRenderable, oldRenderLayer: number, newRenderLayer: number): void; - setRenderLayerNeedsComponentSort(renderLayer: number): void; - setNeedsComponentSort(): void; - addToRenderLayerList(component: IRenderable, renderLayer: number): void; - componentsWithRenderLayer(renderLayer: number): IRenderable[]; - updateList(): void; - } -} -declare class StringUtils { - private static specialSigns; - static matchChineseWord(str: string): string[]; - static lTrim(target: string): string; - static rTrim(target: string): string; - static trim(target: string): string; - static isWhiteSpace(str: string): boolean; - static replaceMatch(mainStr: string, targetStr: string, replaceStr: string, caseMark?: boolean): string; - static htmlSpecialChars(str: string, reversion?: boolean): string; - static zfill(str: string, width?: number): string; - static reverse(str: string): string; - static cutOff(str: string, start: number, len: number, order?: boolean): string; - static strReplace(str: string, rStr: string[]): string; -} -declare module es { - class TextureUtils { - static sharedCanvas: HTMLCanvasElement; - static sharedContext: CanvasRenderingContext2D; - static convertImageToCanvas(texture: egret.Texture, rect?: egret.Rectangle): HTMLCanvasElement; - static toDataURL(type: string, texture: egret.Texture, rect?: egret.Rectangle, encoderOptions?: any): string; - static eliFoTevas(type: string, texture: egret.Texture, filePath: string, rect?: egret.Rectangle, encoderOptions?: any): void; - static getPixel32(texture: egret.Texture, x: number, y: number): number[]; - static getPixels(texture: egret.Texture, x: number, y: number, width?: number, height?: number): number[]; - } -} -declare module es { - class Time { - static unscaledDeltaTime: any; - static deltaTime: number; - static timeScale: number; - static frameCount: number; - static _timeSinceSceneLoad: any; - private static _lastTime; - static update(currentTime: number): void; - static sceneChanged(): void; - static checkEvery(interval: number): boolean; - } -} -declare class TimeUtils { - static monthId(d?: Date): number; - static dateId(t?: Date): number; - static weekId(d?: Date, first?: boolean): number; - static diffDay(a: Date, b: Date, fixOne?: boolean): number; - static getFirstDayOfWeek(d?: Date): Date; - static getFirstOfDay(d?: Date): Date; - static getNextFirstOfDay(d?: Date): Date; - static formatDate(date: Date): string; - static formatDateTime(date: Date): string; - static parseDate(s: string): Date; - static secondToTime(time?: number, partition?: string, showHour?: boolean): string; - static timeToMillisecond(time: string, partition?: string): string; -} -declare module es { - class Graphics { - static Instance: Graphics; - pixelTexture: Sprite; - constructor(); - } -} -declare module es { - class GraphicsCapabilities extends egret.Capabilities { - initialize(device: GraphicsDevice): void; - private platformInitialize; - } -} -declare module es { - class GraphicsDevice { - graphicsCapabilities: GraphicsCapabilities; - constructor(); - private _viewport; - readonly viewport: Viewport; - private setup; - } -} -declare module es { - class Viewport { - private _x; - private _y; - private _minDepth; - private _maxDepth; - constructor(x: number, y: number, width: number, height: number); - private _width; - width: number; - private _height; - height: number; - readonly aspectRatio: number; - bounds: Rectangle; - } -} -declare module es { - class GaussianBlurEffect extends egret.CustomFilter { - private static blur_frag; - constructor(); - } -} -declare module es { - class PolygonLightEffect extends egret.CustomFilter { - private static vertSrc; - private static fragmentSrc; - constructor(); - } -} -declare module es { - class PostProcessor { - static default_vert: string; - enabled: boolean; - effect: egret.Filter; - scene: Scene; - shape: egret.Shape; - constructor(effect?: egret.Filter); - onAddedToScene(scene: Scene): void; - process(): void; - onSceneBackBufferSizeChanged(newWidth: number, newHeight: number): void; - unload(): void; - protected drawFullscreenQuad(): void; - } -} -declare module es { - class GaussianBlurPostProcessor extends PostProcessor { - onAddedToScene(scene: Scene): void; - } -} -declare module es { - abstract class Renderer { - camera: Camera; - readonly renderOrder: number; - renderTexture: egret.RenderTexture; - shouldDebugRender: boolean; - readonly wantsToRenderToSceneRenderTarget: boolean; - protected constructor(renderOrder: number, camera?: Camera); - onAddedToScene(scene: Scene): void; - unload(): void; - abstract render(scene: Scene): any; - onSceneBackBufferSizeChanged(newWidth: number, newHeight: number): void; - compareTo(other: Renderer): number; - protected beginRender(cam: Camera): void; - protected renderAfterStateCheck(renderable: IRenderable, cam: Camera): void; - protected debugRender(scene: Scene, cam: Camera): void; - } -} -declare module es { - class DefaultRenderer extends Renderer { - constructor(); - render(scene: Scene): void; - } -} -declare module es { - class RenderLayerExcludeRenderer extends Renderer { - excludedRenderLayers: number[]; - constructor(renderOrder: number, ...excludedRenderLayers: number[]); - render(scene: es.Scene): void; - protected debugRender(scene: es.Scene, cam: es.Camera): void; - } -} -declare module es { - class ScreenSpaceRenderer extends Renderer { - renderLayers: number[]; - constructor(renderOrder: number, ...renderLayers: number[]); - render(scene: Scene): void; - protected debugRender(scene: es.Scene, cam: es.Camera): void; - onSceneBackBufferSizeChanged(newWidth: number, newHeight: number): void; - } -} -declare module es { - class PolyLight extends RenderableComponent { - power: number; - private _lightEffect; - private _indices; - constructor(radius: number, color: number, power: number); - protected _radius: number; - radius: number; - setRadius(radius: number): void; - render(camera: Camera): void; - reset(): void; - private computeTriangleIndices; - } -} -declare module es { - class GaussianBlur { - static createBlurredTexture(image: egret.Texture, deviation?: number): void; - static createBlurredTextureData(srcData: Color[], width: number, height: number, deviation?: number): Color[]; - static gaussianConvolution(matrix: FasterDictionary<{ - x: number; - y: number; - }, number>, deviation: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static processPoint(matrix: FasterDictionary<{ - x: number; - y: number; - }, number>, x: number, y: number, kernel: FasterDictionary<{ - x: number; - y: number; - }, number>, direction: number): number; - static calculate1DSampleKernel(deviation: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static calculate1DSampleKernelOfSize(deviation: number, size: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static calculateNormalized1DSampleKernel(deviation: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static normalizeMatrix(matrix: FasterDictionary<{ - x: number; - y: number; - }, number>): FasterDictionary<{ - x: number; - y: number; - }, number>; - } -} -declare module es { - abstract class SceneTransition { - loadsNewScene: boolean; - isNewSceneLoaded: boolean; - onScreenObscured: Function; - onTransitionCompleted: Function; - protected sceneLoadAction: Function; - constructor(sceneLoadAction: Function); - private _hasPreviousSceneRender; - readonly hasPreviousSceneRender: boolean; - preRender(): void; - render(): void; - onBeginTransition(): Promise; - tickEffectProgressProperty(filter: egret.CustomFilter, duration: number, easeType: Function, reverseDirection?: boolean): Promise; - protected transitionComplete(): void; - protected loadNextScene(): Promise; - } -} -declare module es { - class FadeTransition extends SceneTransition { - fadeToColor: number; - fadeOutDuration: number; - fadeEaseType: Function; - delayBeforeFadeInDuration: number; - private _mask; - private _alpha; - constructor(sceneLoadAction: Function); - onBeginTransition(): Promise; - protected transitionComplete(): void; - render(): void; - } -} -declare module es { - class WindTransition extends SceneTransition { - duration: number; - easeType: (t: number) => number; - private _mask; - private _windEffect; - constructor(sceneLoadAction: Function); - windSegments: number; - size: number; - onBeginTransition(): Promise; - protected transitionComplete(): void; - } -} -declare module es { - class Bezier { - static getPoint(p0: Vector2, p1: Vector2, p2: Vector2, t: number): Vector2; - static getFirstDerivative(p0: Vector2, p1: Vector2, p2: Vector2, t: number): Vector2; - static getFirstDerivativeThree(start: Vector2, firstControlPoint: Vector2, secondControlPoint: Vector2, end: Vector2, t: number): Vector2; - static getPointThree(start: Vector2, firstControlPoint: Vector2, secondControlPoint: Vector2, end: Vector2, t: number): Vector2; - static getOptimizedDrawingPoints(start: Vector2, firstCtrlPoint: Vector2, secondCtrlPoint: Vector2, end: Vector2, distanceTolerance?: number): Vector2[]; - private static recursiveGetOptimizedDrawingPoints; - } -} -declare module es { - class Flags { - static isFlagSet(self: number, flag: number): boolean; - static isUnshiftedFlagSet(self: number, flag: number): boolean; - static setFlagExclusive(self: Ref, flag: number): void; - static setFlag(self: Ref, flag: number): void; - static unsetFlag(self: Ref, flag: number): void; - static invertFlags(self: Ref): void; - } -} -declare module es { - class MathHelper { - static readonly Epsilon: number; - static readonly Rad2Deg: number; - static readonly Deg2Rad: number; - static readonly PiOver2: number; - static toDegrees(radians: number): number; - static toRadians(degrees: number): number; - static map(value: number, leftMin: number, leftMax: number, rightMin: number, rightMax: number): number; - static lerp(value1: number, value2: number, amount: number): number; - static clamp(value: number, min: number, max: number): number; - static pointOnCirlce(circleCenter: Vector2, radius: number, angleInDegrees: number): Vector2; - static isEven(value: number): boolean; - static clamp01(value: number): number; - static angleBetweenVectors(from: Vector2, to: Vector2): number; - static incrementWithWrap(t: number, length: number): number; - static approach(start: number, end: number, shift: number): number; - } -} -declare module es { - var matrixPool: any[]; - class Matrix2D extends egret.Matrix { - m11: number; - m12: number; - m21: number; - m22: number; - m31: number; - m32: number; - static create(): Matrix2D; - identity(): Matrix2D; - translate(dx: number, dy: number): Matrix2D; - scale(sx: number, sy: number): Matrix2D; - rotate(angle: number): Matrix2D; - invert(): Matrix2D; - add(matrix: Matrix2D): Matrix2D; - substract(matrix: Matrix2D): Matrix2D; - divide(matrix: Matrix2D): Matrix2D; - multiply(matrix: Matrix2D): Matrix2D; - determinant(): number; - release(matrix: Matrix2D): void; - } -} -declare module es { - class Rectangle extends egret.Rectangle { - _tempMat: Matrix2D; - _transformMat: Matrix2D; - readonly max: Vector2; - readonly center: Vector2; - location: Vector2; - size: Vector2; - static fromMinMax(minX: number, minY: number, maxX: number, maxY: number): Rectangle; - static rectEncompassingPoints(points: Vector2[]): Rectangle; - intersects(value: egret.Rectangle): boolean; - rayIntersects(ray: Ray2D, distance: Ref): boolean; - containsRect(value: Rectangle): boolean; - contains(x: number, y: number): boolean; - getHalfSize(): Vector2; - getClosestPointOnRectangleBorderToPoint(point: Vector2, edgeNormal: Vector2): Vector2; - getClosestPointOnBoundsToOrigin(): Vector2; - calculateBounds(parentPosition: Vector2, position: Vector2, origin: Vector2, scale: Vector2, rotation: number, width: number, height: number): void; - } -} -declare module es { - class SubpixelFloat { - remainder: number; - update(amount: number): number; - reset(): void; - } -} -declare module es { - class SubpixelVector2 { - _x: SubpixelFloat; - _y: SubpixelFloat; - update(amount: Vector2): void; - reset(): void; - } -} -declare module es { - class Vector3 { - x: number; - y: number; - z: number; - constructor(x: number, y: number, z: number); - } -} -declare module es { - class ColliderTriggerHelper { - private _entity; - private _activeTriggerIntersections; - private _previousTriggerIntersections; - private _tempTriggerList; - constructor(entity: Entity); - update(): void; - private checkForExitedColliders; - private notifyTriggerListeners; - } -} -declare module es { - enum PointSectors { - center = 0, - top = 1, - bottom = 2, - topLeft = 9, - topRight = 5, - left = 8, - right = 4, - bottomLeft = 10, - bottomRight = 6 - } - class Collisions { - static isLineToLine(a1: Vector2, a2: Vector2, b1: Vector2, b2: Vector2): boolean; - static lineToLineIntersection(a1: Vector2, a2: Vector2, b1: Vector2, b2: Vector2): Vector2; - static closestPointOnLine(lineA: Vector2, lineB: Vector2, closestTo: Vector2): Vector2; - static circleToCircle(circleCenter1: Vector2, circleRadius1: number, circleCenter2: Vector2, circleRadius2: number): boolean; - static circleToLine(circleCenter: Vector2, radius: number, lineFrom: Vector2, lineTo: Vector2): boolean; - static circleToPoint(circleCenter: Vector2, radius: number, point: Vector2): boolean; - static rectToCircle(rect: egret.Rectangle, cPosition: Vector2, cRadius: number): boolean; - static rectToLine(rect: Rectangle, lineFrom: Vector2, lineTo: Vector2): boolean; - static rectToPoint(rX: number, rY: number, rW: number, rH: number, point: Vector2): boolean; - static getSector(rX: number, rY: number, rW: number, rH: number, point: Vector2): PointSectors; - } -} -declare module es { - class RaycastHit { - collider: Collider; - fraction: number; - distance: number; - point: Vector2; - normal: Vector2; - centroid: Vector2; - constructor(collider?: Collider, fraction?: number, distance?: number, point?: Vector2, normal?: Vector2); - setValues(collider: Collider, fraction: number, distance: number, point: Vector2): void; - setValuesNonCollider(fraction: number, distance: number, point: Vector2, normal: Vector2): void; - reset(): void; - toString(): string; - } -} -declare module es { - class Physics { - static spatialHashCellSize: number; - static readonly allLayers: number; - private static _spatialHash; - static raycastsHitTriggers: boolean; - static raycastsStartInColliders: boolean; - static _hitArray: RaycastHit[]; - static reset(): void; - static clear(): void; - static overlapCircleAll(center: Vector2, randius: number, results: any[], layerMask?: number): number; - static boxcastBroadphase(rect: Rectangle, layerMask?: number): Collider[]; - static boxcastBroadphaseExcludingSelf(collider: Collider, rect: Rectangle, layerMask?: number): Collider[]; - static addCollider(collider: Collider): void; - static removeCollider(collider: Collider): void; - static updateCollider(collider: Collider): void; - static linecast(start: Vector2, end: Vector2, layerMask?: number): RaycastHit; - static linecastAll(start: Vector2, end: Vector2, hits: RaycastHit[], layerMask?: number): number; - static debugDraw(secondsToDisplay: any): void; - } -} -declare module es { - class Ray2D { - start: Vector2; - end: Vector2; - direction: Vector2; - constructor(position: Vector2, end: Vector2); - } -} -declare module es { - class SpatialHash { - gridBounds: Rectangle; - _raycastParser: RaycastResultParser; - _cellSize: number; - _inverseCellSize: number; - _overlapTestCircle: Circle; - _cellDict: NumberDictionary; - _tempHashSet: Collider[]; - constructor(cellSize?: number); - register(collider: Collider): void; - remove(collider: Collider): void; - removeWithBruteForce(obj: Collider): void; - clear(): void; - debugDraw(secondsToDisplay: number, textScale?: number): void; - aabbBroadphase(bounds: Rectangle, excludeCollider: Collider, layerMask: number): Collider[]; - linecast(start: Vector2, end: Vector2, hits: RaycastHit[], layerMask: number): number; - overlapCircle(circleCenter: Vector2, radius: number, results: Collider[], layerMask: any): number; - private cellCoords; - private cellAtPosition; - private debugDrawCellDetails; - } - class NumberDictionary { - _store: Map; - add(x: number, y: number, list: Collider[]): void; - remove(obj: Collider): void; - tryGetValue(x: number, y: number): Collider[]; - getKey(x: number, y: number): string; - clear(): void; - } - class RaycastResultParser { - hitCounter: number; - static compareRaycastHits: (a: RaycastHit, b: RaycastHit) => number; - _hits: RaycastHit[]; - _tempHit: RaycastHit; - _checkedColliders: Collider[]; - _cellHits: RaycastHit[]; - _ray: Ray2D; - _layerMask: number; - start(ray: Ray2D, hits: RaycastHit[], layerMask: number): void; - checkRayIntersection(cellX: number, cellY: number, cell: Collider[]): boolean; - reset(): void; - } -} -declare module es { - abstract class Shape { - position: Vector2; - center: Vector2; - bounds: Rectangle; - abstract recalculateBounds(collider: Collider): any; - abstract overlaps(other: Shape): boolean; - abstract collidesWithShape(other: Shape, collisionResult: CollisionResult): boolean; - abstract collidesWithLine(start: Vector2, end: Vector2, hit: RaycastHit): boolean; - abstract containsPoint(point: Vector2): any; - abstract pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean; - } -} -declare module es { - class Polygon extends Shape { - points: Vector2[]; - _areEdgeNormalsDirty: boolean; - _originalPoints: Vector2[]; - _polygonCenter: Vector2; - isBox: boolean; - isUnrotated: boolean; - constructor(points: Vector2[], isBox?: boolean); - _edgeNormals: Vector2[]; - readonly edgeNormals: Vector2[]; - setPoints(points: Vector2[]): void; - recalculateCenterAndEdgeNormals(): void; - buildEdgeNormals(): void; - static buildSymmetricalPolygon(vertCount: number, radius: number): any[]; - static recenterPolygonVerts(points: Vector2[]): void; - static findPolygonCenter(points: Vector2[]): Vector2; - static getFarthestPointInDirection(points: Vector2[], direction: Vector2): Vector2; - static getClosestPointOnPolygonToPoint(points: Vector2[], point: Vector2, distanceSquared: Ref, edgeNormal: Vector2): Vector2; - static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints: Vector2[]): void; - recalculateBounds(collider: Collider): void; - overlaps(other: Shape): any; - collidesWithShape(other: Shape, result: CollisionResult): boolean; - collidesWithLine(start: es.Vector2, end: es.Vector2, hit: es.RaycastHit): boolean; - containsPoint(point: Vector2): boolean; - pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean; - } -} -declare module es { - class Box extends Polygon { - width: number; - height: number; - constructor(width: number, height: number); - private static buildBox; - updateBox(width: number, height: number): void; - overlaps(other: Shape): any; - collidesWithShape(other: Shape, result: CollisionResult): boolean; - containsPoint(point: Vector2): boolean; - pointCollidesWithShape(point: es.Vector2, result: es.CollisionResult): boolean; - } -} -declare module es { - class Circle extends Shape { - radius: number; - _originalRadius: number; - constructor(radius: number); - recalculateBounds(collider: es.Collider): void; - overlaps(other: Shape): any; - collidesWithShape(other: Shape, result: CollisionResult): boolean; - collidesWithLine(start: es.Vector2, end: es.Vector2, hit: es.RaycastHit): boolean; - containsPoint(point: es.Vector2): boolean; - pointCollidesWithShape(point: Vector2, result: CollisionResult): boolean; - } -} -declare module es { - class CollisionResult { - collider: Collider; - normal: Vector2; - minimumTranslationVector: Vector2; - point: Vector2; - removeHorizontal(deltaMovement: Vector2): void; - invertResult(): this; - toString(): string; - } -} -declare module es { - class RealtimeCollisions { - static intersectMovingCircleBox(s: Circle, b: Box, movement: Vector2, time: Ref): boolean; - } -} -declare module es { - class ShapeCollisions { - static polygonToPolygon(first: Polygon, second: Polygon, result: CollisionResult): boolean; - static intervalDistance(minA: number, maxA: number, minB: number, maxB: any): number; - static getInterval(axis: Vector2, polygon: Polygon, min: number, max: number): { - min: number; - max: number; - }; - static circleToPolygon(circle: Circle, polygon: Polygon, result: CollisionResult): boolean; - static circleToBox(circle: Circle, box: Box, result: CollisionResult): boolean; - static pointToCircle(point: Vector2, circle: Circle, result: CollisionResult): boolean; - static pointToBox(point: Vector2, box: Box, result: CollisionResult): boolean; - static closestPointOnLine(lineA: Vector2, lineB: Vector2, closestTo: Vector2): Vector2; - static pointToPoly(point: Vector2, poly: Polygon, result: CollisionResult): boolean; - static circleToCircle(first: Circle, second: Circle, result: CollisionResult): boolean; - static boxToBox(first: Box, second: Box, result: CollisionResult): boolean; - private static minkowskiDifference; - static lineToPoly(start: Vector2, end: Vector2, polygon: Polygon, hit: RaycastHit): boolean; - static lineToLine(a1: Vector2, a2: Vector2, b1: Vector2, b2: Vector2, intersection: Vector2): boolean; - static lineToCircle(start: Vector2, end: Vector2, s: Circle, hit: RaycastHit): boolean; - static boxToBoxCast(first: Box, second: Box, movement: Vector2, hit: RaycastHit): boolean; - } -} -declare module es { - class Particle { - position: Vector2; - lastPosition: Vector2; - mass: number; - radius: number; - collidesWithColliders: boolean; - isPinned: boolean; - acceleration: Vector2; - pinnedPosition: Vector2; - applyForce(force: Vector2): void; - } -} -declare module es { - class VerletWorld { - gravity: Vector2; - constraintIterations: number; - maximumStepIterations: number; - simulationBounds?: Rectangle; - allowDragging: boolean; - _composites: Composite[]; - static _colliders: Collider[]; - _tempCircle: Circle; - _leftOverTime: number; - _fixedDeltaTime: number; - _iterationSteps: number; - _fixedDeltaTimeSq: number; - constructor(simulationBounds?: Rectangle); - update(): void; - handleCollisions(p: Particle, collidesWithLayers: number): void; - constrainParticleToBounds(p: Particle): void; - updateTiming(): void; - addComposite(composite: T): T; - removeComposite(composite: Composite): void; - handleDragging(): void; - debugRender(camera: Camera): void; - } -} -declare module es { - class Composite { - friction: Vector2; - collidesWithLayers: number; - particles: Particle[]; - _constraints: Constraint[]; - solveConstraints(): void; - updateParticles(deltaTimeSquared: number, gravity: Vector2): void; - handleConstraintCollisions(): void; - debugRender(camera: Camera): void; - } -} -declare module es { - abstract class Constraint { - collidesWithColliders: boolean; - abstract solve(): any; - handleCollisions(collidesWithLayers: number): void; - } -} -declare class ArrayUtils { - static bubbleSort(ary: number[]): void; - static insertionSort(ary: number[]): void; - static binarySearch(ary: number[], value: number): number; - static findElementIndex(ary: any[], num: any): any; - static getMaxElementIndex(ary: number[]): number; - static getMinElementIndex(ary: number[]): number; - static getUniqueAry(ary: number[]): number[]; - static getDifferAry(aryA: number[], aryB: number[]): number[]; - static swap(array: any[], index1: number, index2: number): void; - static clearList(ary: any[]): void; - static cloneList(ary: any[]): any[]; - static equals(ary1: number[], ary2: number[]): Boolean; - static insert(ary: any[], index: number, value: any): any; -} -declare module es { - class Base64Utils { - private static _keyStr; - static readonly nativeBase64: boolean; - static decode(input: string): string; - static encode(input: string): string; - static decodeBase64AsArray(input: string, bytes: number): Uint32Array; - static decompress(data: string, decoded: any, compression: string): any; - static decodeCSV(input: string): Array; - } -} -declare module es { - class Color { - private _packedValue; - constructor(r: number, g: number, b: number, alpha: number); - b: number; - g: number; - r: number; - a: number; - packedValue: number; - equals(other: Color): boolean; - } -} -declare module es { - class ContentManager { - protected loadedAssets: Map; - loadRes(name: string, local?: boolean): Promise; - dispose(): void; - } -} -declare module es { - class DrawUtils { - static getColorMatrix(color: number): egret.ColorMatrixFilter; - } -} -declare module es { - class EdgeExt { - static oppositeEdge(self: Edge): Edge; - static isHorizontal(self: Edge): boolean; - static isVertical(self: Edge): boolean; - } -} -declare module es { - class FuncPack { - func: Function; - context: any; - constructor(func: Function, context: any); - } - class Emitter { - private _messageTable; - constructor(); - addObserver(eventType: T, handler: Function, context: any): void; - removeObserver(eventType: T, handler: Function): void; - emit(eventType: T, data?: any): void; - } -} -declare module es { - enum Edge { - top = 0, - bottom = 1, - left = 2, - right = 3 - } -} -declare module es { - class Enumerable { - static repeat(element: T, count: number): any[]; - } -} -declare module es { - class EqualityComparer implements IEqualityComparer { - static default(): EqualityComparer; - protected constructor(); - equals(x: T, y: T): boolean; - } -} -declare module es { - class GlobalManager { - _enabled: boolean; - enabled: boolean; - setEnabled(isEnabled: boolean): void; - onEnabled(): void; - onDisabled(): void; - update(): void; - } -} -declare module es { - interface IComparer { - compare(x: T, y: T): number; - } -} -declare module es { - interface IEqualityComparer { - equals(x: any, y: any): boolean; - } -} -declare module es { - interface IEquatable { - equals(other: T): boolean; - } -} -declare module es { - class ListPool { - private static readonly _objectQueue; - static warmCache(cacheCount: number): void; - static trimCache(cacheCount: any): void; - static clearCache(): void; - static obtain(): T[]; - static free(obj: Array): void; - } -} -declare module es { - class NumberExtension { - static toNumber(value: any): number; - } -} -declare module es { - class Pair implements IEquatable> { - first: T; - second: T; - constructor(first: T, second: T); - clear(): void; - equals(other: Pair): boolean; - } -} -declare module es { - class Pool { - private static _objectQueue; - static warmCache(type: any, cacheCount: number): void; - static trimCache(cacheCount: number): void; - static clearCache(): void; - static obtain(type: any): T; - static free(obj: T): void; - } - interface IPoolable { - reset(): any; - } -} -declare class RandomUtils { - static randrange(start: number, stop: number, step?: number): number; - static randint(a: number, b: number): number; - static randnum(a: number, b: number): number; - static shuffle(array: any[]): any[]; - static choice(sequence: any): any; - static sample(sequence: any[], num: number): any[]; - static random(): number; - static boolean(chance?: number): boolean; - private static _randomCompare; -} -declare module es { - class RectangleExt { - static getSide(rect: Rectangle, edge: Edge): number; - static union(first: Rectangle, point: Vector2): Rectangle; - static getHalfRect(rect: Rectangle, edge: Edge): Rectangle; - static getRectEdgePortion(rect: Rectangle, edge: Edge, size?: number): Rectangle; - static expandSide(rect: Rectangle, edge: Edge, amount: number): void; - static contract(rect: Rectangle, horizontalAmount: any, verticalAmount: any): void; - } -} -declare module es { - class Ref { - value: T; - constructor(value: T); - } -} -declare module es { - class SubpixelNumber { - remainder: number; - update(amount: number): number; - reset(): void; - } -} -declare module es { - class Triangulator { - triangleIndices: number[]; - private _triPrev; - private _triNext; - static testPointTriangle(point: Vector2, a: Vector2, b: Vector2, c: Vector2): boolean; - triangulate(points: Vector2[], arePointsCCW?: boolean): void; - private initialize; - } -} -declare module es { - class Vector2Ext { - static isTriangleCCW(a: Vector2, center: Vector2, c: Vector2): boolean; - static halfVector(): Vector2; - static cross(u: Vector2, v: Vector2): number; - static perpendicular(first: Vector2, second: Vector2): Vector2; - static normalize(vec: Vector2): void; - static transformA(sourceArray: Vector2[], sourceIndex: number, matrix: Matrix2D, destinationArray: Vector2[], destinationIndex: number, length: number): void; - static transformR(position: Vector2, matrix: Matrix2D, result: Vector2): void; - static transform(sourceArray: Vector2[], matrix: Matrix2D, destinationArray: Vector2[]): void; - static round(vec: Vector2): Vector2; - } -} -declare class WebGLUtils { - static getContext(): CanvasRenderingContext2D; -} -declare module es { - class Layout { - clientArea: Rectangle; - safeArea: Rectangle; - constructor(); - place(size: Vector2, horizontalMargin: number, verticalMargine: number, alignment: Alignment): Rectangle; - } - enum Alignment { - none = 0, - left = 1, - right = 2, - horizontalCenter = 4, - top = 8, - bottom = 16, - verticalCenter = 32, - topLeft = 9, - topRight = 10, - topCenter = 12, - bottomLeft = 17, - bottomRight = 18, - bottomCenter = 20, - centerLeft = 33, - centerRight = 34, - center = 36 - } -} -declare namespace stopwatch { - class Stopwatch { - private readonly getSystemTime; - private _startSystemTime; - private _stopSystemTime; - private _stopDuration; - private _pendingSliceStartStopwatchTime; - private _completeSlices; - constructor(getSystemTime?: GetTimeFunc); - getState(): State; - isIdle(): boolean; - isRunning(): boolean; - isStopped(): boolean; - slice(): Slice; - getCompletedSlices(): Slice[]; - getCompletedAndPendingSlices(): Slice[]; - getPendingSlice(): Slice; - getTime(): number; - reset(): void; - start(forceReset?: boolean): void; - stop(recordPendingSlice?: boolean): number; - private calculatePendingSlice; - private caculateStopwatchTime; - private getSystemTimeOfCurrentStopwatchTime; - private recordPendingSlice; - } - type GetTimeFunc = () => number; - enum State { - IDLE = "IDLE", - RUNNING = "RUNNING", - STOPPED = "STOPPED" - } - function setDefaultSystemTimeGetter(systemTimeGetter?: GetTimeFunc): void; - interface Slice { - readonly startTime: number; - readonly endTime: number; - readonly duration: number; - } -} -declare module es { - class TimeRuler { - static readonly maxBars: number; - static readonly maxSamples: number; - static readonly maxNestCall: number; - static readonly barHeight: number; - static readonly maxSampleFrames: number; - static readonly logSnapDuration: number; - static readonly barPadding: number; - static readonly autoAdjustDelay: number; - private static _instance; - targetSampleFrames: number; - width: number; - enabled: true; - showLog: boolean; - logs: FrameLog[]; - private sampleFrames; - private _position; - private prevLog; - private curLog; - private frameCount; - private markers; - private stopwacth; - private _markerNameToIdMap; - private _updateCount; - private _frameAdjust; - private _rectShape1; - private _rectShape2; - private _rectShape3; - private _rectShape4; - private _rectShape5; - private _rectShape6; - constructor(); - static readonly Instance: TimeRuler; - startFrame(): void; - beginMark(markerName: string, color: number, barIndex?: number): void; - endMark(markerName: string, barIndex?: number): void; - getAverageTime(barIndex: number, markerName: string): number; - resetLog(): void; - render(position?: Vector2, width?: number): void; - private onGraphicsDeviceReset; - } - class FrameLog { - bars: MarkerCollection[]; - constructor(); - } - class MarkerCollection { - markers: Marker[]; - markCount: number; - markerNests: number[]; - nestCount: number; - constructor(); - } - class Marker { - markerId: number; - beginTime: number; - endTime: number; - color: number; - } - class MarkerInfo { - name: string; - logs: MarkerLog[]; - constructor(name: any); - } - class MarkerLog { - snapMin: number; - snapMax: number; - snapAvg: number; - min: number; - max: number; - avg: number; - samples: number; - color: number; - initialized: boolean; - } -} -declare module es { - interface ICoroutine { - stop(): any; - setUseUnscaledDeltaTime(useUnscaledDeltaTime: any): ICoroutine; - } - class Coroutine { - static waitForSeconds(seconds: number): WaitForSeconds; - } - class WaitForSeconds { - static waiter: WaitForSeconds; - waitTime: number; - wait(seconds: number): WaitForSeconds; - } -} -declare module es { - class CoroutineImpl implements ICoroutine, IPoolable { - enumerator: Iterator; - waitTimer: number; - isDone: boolean; - waitForCoroutine: CoroutineImpl; - useUnscaledDeltaTime: boolean; - stop(): void; - setUseUnscaledDeltaTime(useUnscaledDeltaTime: any): es.ICoroutine; - prepareForuse(): void; - reset(): void; - } - class CoroutineManager extends GlobalManager { - _isInUpdate: boolean; - _unblockedCoroutines: CoroutineImpl[]; - _shouldRunNextFrame: CoroutineImpl[]; - startCoroutine(enumerator: Iterator): CoroutineImpl; - update(): void; - tickCoroutine(coroutine: CoroutineImpl): boolean; - } -} -declare module es { - class TouchState { - x: number; - y: number; - touchPoint: number; - touchDown: boolean; - readonly position: Vector2; - reset(): void; - } - class Input { - private static _init; - private static _previousTouchState; - private static _resolutionOffset; - private static _touchIndex; - private static _gameTouchs; - static readonly gameTouchs: TouchState[]; - private static _resolutionScale; - static readonly resolutionScale: Vector2; - private static _totalTouchCount; - static readonly totalTouchCount: number; - static readonly touchPosition: Vector2; - static _virtualInputs: VirtualInput[]; - static maxSupportedTouch: number; - static readonly touchPositionDelta: Vector2; - static initialize(): void; - static update(): void; - static scaledPosition(position: Vector2): Vector2; - static isKeyPressed(key: Keys): boolean; - static isKeyPressedBoth(keyA: Keys, keyB: Keys): boolean; - static isKeyDown(key: Keys): boolean; - static isKeyDownBoth(keyA: Keys, keyB: Keys): boolean; - static isKeyReleased(key: Keys): boolean; - static isKeyReleasedBoth(keyA: Keys, keyB: Keys): boolean; - private static initTouchCache; - private static touchBegin; - private static touchMove; - private static touchEnd; - private static setpreviousTouchState; - } -} -import Keys = es.Keys; -declare class KeyboardUtils { - static currentKeys: Keys[]; - static previousKeys: Keys[]; - private static keyStatusKeys; - static init(): void; - static update(): void; - static destroy(): void; - private static onKeyDownHandler; - private static onKeyUpHandler; -} -declare module es { - enum Keys { - none = 0, - back = 8, - tab = 9, - enter = 13, - capsLock = 20, - escape = 27, - space = 32, - pageUp = 33, - pageDown = 34, - end = 35, - home = 36, - left = 37, - up = 38, - right = 39, - down = 40, - select = 41, - print = 42, - execute = 43, - printScreen = 44, - insert = 45, - delete = 46, - help = 47, - d0 = 48, - d1 = 49, - d2 = 50, - d3 = 51, - d4 = 52, - d5 = 53, - d6 = 54, - d7 = 55, - d8 = 56, - d9 = 57, - a = 65, - b = 66, - c = 67, - d = 68, - e = 69, - f = 70, - g = 71, - h = 72, - i = 73, - j = 74, - k = 75, - l = 76, - m = 77, - n = 78, - o = 79, - p = 80, - q = 81, - r = 82, - s = 83, - t = 84, - u = 85, - v = 86, - w = 87, - x = 88, - y = 89, - z = 90, - leftWindows = 91, - rightWindows = 92, - apps = 93, - sleep = 95, - numPad0 = 96, - numPad1 = 97, - numPad2 = 98, - numPad3 = 99, - numPad4 = 100, - numPad5 = 101, - numPad6 = 102, - numPad7 = 103, - numPad8 = 104, - numPad9 = 105, - multiply = 106, - add = 107, - seperator = 108, - subtract = 109, - decimal = 110, - divide = 111, - f1 = 112, - f2 = 113, - f3 = 114, - f4 = 115, - f5 = 116, - f6 = 117, - f7 = 118, - f8 = 119, - f9 = 120, - f10 = 121, - f11 = 122, - f12 = 123, - f13 = 124, - f14 = 125, - f15 = 126, - f16 = 127, - f17 = 128, - f18 = 129, - f19 = 130, - f20 = 131, - f21 = 132, - f22 = 133, - f23 = 134, - f24 = 135, - numLock = 144, - scroll = 145, - leftShift = 160, - rightShift = 161, - leftControl = 162, - rightControl = 163, - leftAlt = 164, - rightAlt = 165, - browserBack = 166, - browserForward = 167 - } -} -declare module es { - enum OverlapBehavior { - cancelOut = 0, - takeOlder = 1, - takeNewer = 2 - } - abstract class VirtualInput { - protected constructor(); - deregister(): void; - abstract update(): any; - } - abstract class VirtualInputNode { - update(): void; - } -} -declare module es { - class VirtualIntegerAxis extends VirtualInput { - nodes: VirtualAxisNode[]; - readonly value: number; - constructor(...nodes: VirtualAxisNode[]); - update(): void; - addKeyboardKeys(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys): this; - } - abstract class VirtualAxisNode extends VirtualInputNode { - abstract value: number; - } -} -declare module es { - class VirtualAxis extends VirtualInput { - nodes: VirtualAxisNode[]; - readonly value: number; - constructor(...nodes: VirtualAxisNode[]); - update(): void; - } - class KeyboardKeys extends VirtualAxisNode { - overlapBehavior: OverlapBehavior; - positive: Keys; - negative: Keys; - _value: number; - _turned: boolean; - constructor(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys); - update(): void; - readonly value: number; - } -} -declare module es { - class VirtualButton extends VirtualInput { - nodes: Node[]; - bufferTime: number; - firstRepeatTime: number; - mutiRepeatTime: number; - isRepeating: boolean; - _bufferCounter: number; - _repeatCounter: number; - _willRepeat: boolean; - constructor(bufferTime?: number, ...nodes: Node[]); - setRepeat(firstRepeatTime: number, mutiRepeatTime?: number): void; - update(): void; - readonly isDown: boolean; - readonly isPressed: boolean; - readonly isReleased: boolean; - consumeBuffer(): void; - addKeyboardKey(key: Keys): VirtualButton; - } - abstract class Node extends VirtualInputNode { - abstract isDown: boolean; - abstract isPressed: boolean; - abstract isReleased: boolean; - } - class KeyboardKey extends Node { - key: Keys; - constructor(key: Keys); - readonly isDown: boolean; - readonly isPressed: boolean; - readonly isReleased: boolean; - } -} -declare module es { - class AssetPacker { - protected itemsToRaster: TextureToPack[]; - onProcessCompleted: Function; - useCache: boolean; - cacheName: string; - protected _sprites: Map; - protected allow4096Textures: boolean; - addTextureToPack(texture: egret.Texture, customID: string): void; - process(allow4096Textures?: boolean): Promise; - protected loadPack(): Promise; - protected createPack(): void; - dispose(): void; - getTexture(id: string): egret.Texture; - } -} -declare module es { - class IntegerRectangle extends Rectangle { - id: number; - } -} -declare module es { - class RectanglePacker { - private _width; - private _height; - private _padding; - private _packedWidth; - private _packedHeight; - private _insertList; - private _insertedRectangles; - private _freeAreas; - private _newFreeAreas; - private _outsideRectangle; - private _sortableSizeStack; - private _rectangleStack; - readonly rectangleCount: number; - readonly packedWidth: number; - readonly packedHeight: number; - readonly padding: number; - constructor(width: number, height: number, padding?: number); - reset(width: number, height: number, padding?: number): void; - insertRectangle(width: number, height: number, id: number): void; - packRectangles(sort?: boolean): number; - getRectangle(index: number, rectangle: IntegerRectangle): IntegerRectangle; - getRectangleId(index: number): number; - private generateNewFreeAreas; - private filterSelfSubAreas; - private generateDividedAreas; - private getFreeAreaIndex; - private allocateSize; - private freeSize; - private allocateRectangle; - private freeRectangle; - } -} -declare module es { - class SortableSize { - width: number; - height: number; - id: number; - constructor(width: number, height: number, id: number); - } -} -declare module es { - class TextureAssets { - assets: TextureAsset[]; - constructor(assets: TextureAsset[]); - } - class TextureAsset { - x: number; - y: number; - width: number; - height: number; - name: string; - } -} -declare module es { - class TextureToPack { - texture: egret.Texture; - id: string; - constructor(texture: egret.Texture, id: string); - } -} -declare module es { - interface ITimer { - context: any; - stop(): any; - reset(): any; - getContext(): T; - } -} -declare module es { - class Timer implements ITimer { - context: any; - _timeInSeconds: number; - _repeats: boolean; - _onTime: (timer: ITimer) => void; - _isDone: boolean; - _elapsedTime: number; - getContext(): T; - reset(): void; - stop(): void; - tick(): boolean; - initialize(timeInsSeconds: number, repeats: boolean, context: any, onTime: (timer: ITimer) => void): void; - unload(): void; - } -} -declare module es { - class TimerManager extends GlobalManager { - _timers: Timer[]; - update(): void; - schedule(timeInSeconds: number, repeats: boolean, context: any, onTime: (timer: ITimer) => void): Timer; - } -} diff --git a/demo/libs/framework/framework.js b/demo/libs/framework/framework.js deleted file mode 100644 index ef66adfa..00000000 --- a/demo/libs/framework/framework.js +++ /dev/null @@ -1,11788 +0,0 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Array.prototype.findIndex = function (predicate) { - function findIndex(array, predicate) { - for (var i = 0, len = array.length; i < len; i++) { - if (predicate.call(arguments[2], array[i], i, array)) { - return i; - } - } - return -1; - } - return findIndex(this, predicate); -}; -Array.prototype.any = function (predicate) { - function any(array, predicate) { - return array.findIndex(predicate) > -1; - } - return any(this, predicate); -}; -Array.prototype.firstOrDefault = function (predicate) { - function firstOrDefault(array, predicate) { - var index = array.findIndex(predicate); - return index == -1 ? null : array[index]; - } - return firstOrDefault(this, predicate); -}; -Array.prototype.find = function (predicate) { - function find(array, predicate) { - return array.firstOrDefault(predicate); - } - return find(this, predicate); -}; -Array.prototype.where = function (predicate) { - function where(array, predicate) { - if (typeof (array.reduce) === "function") { - return array.reduce(function (ret, element, index) { - if (predicate.call(arguments[2], element, index, array)) { - ret.push(element); - } - return ret; - }, []); - } - else { - var ret = []; - for (var i = 0, len = array.length; i < len; i++) { - var element = array[i]; - if (predicate.call(arguments[2], element, i, array)) { - ret.push(element); - } - } - return ret; - } - } - return where(this, predicate); -}; -Array.prototype.count = function (predicate) { - function count(array, predicate) { - return array.where(predicate).length; - } - return count(this, predicate); -}; -Array.prototype.findAll = function (predicate) { - function findAll(array, predicate) { - return array.where(predicate); - } - return findAll(this, predicate); -}; -Array.prototype.contains = function (value) { - function contains(array, value) { - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] instanceof egret.HashObject && value instanceof egret.HashObject) { - if (array[i].hashCode == value.hashCode) - return true; - } - if (array[i] == value) { - return true; - } - } - return false; - } - return contains(this, value); -}; -Array.prototype.removeAll = function (predicate) { - function removeAll(array, predicate) { - var index; - do { - index = array.findIndex(predicate); - if (index >= 0) { - array.splice(index, 1); - } - } while (index >= 0); - } - removeAll(this, predicate); -}; -Array.prototype.remove = function (element) { - function remove(array, element) { - var index = array.findIndex(function (x) { - return x === element; - }); - if (index >= 0) { - array.splice(index, 1); - return true; - } - else { - return false; - } - } - return remove(this, element); -}; -Array.prototype.removeAt = function (index) { - function removeAt(array, index) { - array.splice(index, 1); - } - return removeAt(this, index); -}; -Array.prototype.removeRange = function (index, count) { - function removeRange(array, index, count) { - array.splice(index, count); - } - return removeRange(this, index, count); -}; -Array.prototype.select = function (selector) { - function select(array, selector) { - if (typeof (array.reduce) === "function") { - return array.reduce(function (ret, element, index) { - ret.push(selector.call(arguments[2], element, index, array)); - return ret; - }, []); - } - else { - var ret = []; - for (var i = 0, len = array.length; i < len; i++) { - ret.push(selector.call(arguments[2], array[i], i, array)); - } - return ret; - } - } - return select(this, selector); -}; -Array.prototype.orderBy = function (keySelector, comparer) { - function orderBy(array, keySelector, comparer) { - array.sort(function (x, y) { - var v1 = keySelector(x); - var v2 = keySelector(y); - if (comparer) { - return comparer(v1, v2); - } - else { - return (v1 > v2) ? 1 : -1; - } - }); - return array; - } - return orderBy(this, keySelector, comparer); -}; -Array.prototype.orderByDescending = function (keySelector, comparer) { - function orderByDescending(array, keySelector, comparer) { - array.sort(function (x, y) { - var v1 = keySelector(x); - var v2 = keySelector(y); - if (comparer) { - return -comparer(v1, v2); - } - else { - return (v1 < v2) ? 1 : -1; - } - }); - return array; - } - return orderByDescending(this, keySelector, comparer); -}; -Array.prototype.groupBy = function (keySelector) { - function groupBy(array, keySelector) { - if (typeof (array.reduce) === "function") { - var keys_1 = []; - return array.reduce(function (groups, element, index) { - var key = JSON.stringify(keySelector.call(arguments[1], element, index, array)); - var index2 = keys_1.findIndex(function (x) { - return x === key; - }); - if (index2 < 0) { - index2 = keys_1.push(key) - 1; - } - if (!groups[index2]) { - groups[index2] = []; - } - groups[index2].push(element); - return groups; - }, []); - } - else { - var groups = []; - var keys = []; - var _loop_1 = function (i, len) { - var key = JSON.stringify(keySelector.call(arguments_1[1], array[i], i, array)); - var index = keys.findIndex(function (x) { - return x === key; - }); - if (index < 0) { - index = keys.push(key) - 1; - } - if (!groups[index]) { - groups[index] = []; - } - groups[index].push(array[i]); - }; - var arguments_1 = arguments; - for (var i = 0, len = array.length; i < len; i++) { - _loop_1(i, len); - } - return groups; - } - } - return groupBy(this, keySelector); -}; -Array.prototype.sum = function (selector) { - function sum(array, selector) { - var ret; - for (var i = 0, len = array.length; i < len; i++) { - if (i == 0) { - if (selector) { - ret = selector.call(arguments[2], array[i], i, array); - } - else { - ret = array[i]; - } - } - else { - if (selector) { - ret += selector.call(arguments[2], array[i], i, array); - } - else { - ret += array[i]; - } - } - } - return ret; - } - return sum(this, selector); -}; -var es; -(function (es) { - var PriorityQueueNode = (function () { - function PriorityQueueNode() { - this.priority = 0; - this.insertionIndex = 0; - this.queueIndex = 0; - } - return PriorityQueueNode; - }()); - es.PriorityQueueNode = PriorityQueueNode; -})(es || (es = {})); -var es; -(function (es) { - var AStarPathfinder = (function () { - function AStarPathfinder() { - } - AStarPathfinder.search = function (graph, start, goal) { - var _this = this; - var foundPath = false; - var cameFrom = new Map(); - cameFrom.set(start, start); - var costSoFar = new Map(); - var frontier = new es.PriorityQueue(1000); - frontier.enqueue(new AStarNode(start), 0); - costSoFar.set(start, 0); - var _loop_2 = function () { - var current = frontier.dequeue(); - if (current.data instanceof es.Vector2 && goal instanceof es.Vector2 && current.data.equals(goal)) { - foundPath = true; - return "break"; - } - else if (current.data == goal) { - foundPath = true; - return "break"; - } - graph.getNeighbors(current.data).forEach(function (next) { - var newCost = costSoFar.get(current.data) + graph.cost(current.data, next); - if (!_this.hasKey(costSoFar, next) || newCost < costSoFar.get(next)) { - costSoFar.set(next, newCost); - var priority = newCost + graph.heuristic(next, goal); - frontier.enqueue(new AStarNode(next), priority); - cameFrom.set(next, current.data); - } - }); - }; - while (frontier.count > 0) { - var state_1 = _loop_2(); - if (state_1 === "break") - break; - } - return foundPath ? this.recontructPath(cameFrom, start, goal) : null; - }; - AStarPathfinder.recontructPath = function (cameFrom, start, goal) { - var path = []; - var current = goal; - path.push(goal); - while (current != start) { - current = this.getKey(cameFrom, current); - path.push(current); - } - path.reverse(); - return path; - }; - AStarPathfinder.hasKey = function (map, compareKey) { - var iterator = map.keys(); - var r; - while (r = iterator.next(), !r.done) { - if (r.value instanceof es.Vector2 && compareKey instanceof es.Vector2 && r.value.equals(compareKey)) - return true; - else if (r.value == compareKey) - return true; - } - return false; - }; - AStarPathfinder.getKey = function (map, compareKey) { - var iterator = map.keys(); - var valueIterator = map.values(); - var r; - var v; - while (r = iterator.next(), v = valueIterator.next(), !r.done) { - if (r.value instanceof es.Vector2 && compareKey instanceof es.Vector2 && r.value.equals(compareKey)) - return v.value; - else if (r.value == compareKey) - return v.value; - } - return null; - }; - return AStarPathfinder; - }()); - es.AStarPathfinder = AStarPathfinder; - var AStarNode = (function (_super) { - __extends(AStarNode, _super); - function AStarNode(data) { - var _this = _super.call(this) || this; - _this.data = data; - return _this; - } - return AStarNode; - }(es.PriorityQueueNode)); -})(es || (es = {})); -var es; -(function (es) { - var AstarGridGraph = (function () { - function AstarGridGraph(width, height) { - this.dirs = [ - new es.Vector2(1, 0), - new es.Vector2(0, -1), - new es.Vector2(-1, 0), - new es.Vector2(0, 1) - ]; - this.walls = []; - this.weightedNodes = []; - this.defaultWeight = 1; - this.weightedNodeWeight = 5; - this._neighbors = new Array(4); - this._width = width; - this._height = height; - } - AstarGridGraph.prototype.isNodeInBounds = function (node) { - return 0 <= node.x && node.x < this._width && 0 <= node.y && node.y < this._height; - }; - AstarGridGraph.prototype.isNodePassable = function (node) { - return !this.walls.firstOrDefault(function (wall) { return wall.equals(node); }); - }; - AstarGridGraph.prototype.search = function (start, goal) { - return es.AStarPathfinder.search(this, start, goal); - }; - AstarGridGraph.prototype.getNeighbors = function (node) { - var _this = this; - this._neighbors.length = 0; - this.dirs.forEach(function (dir) { - var next = new es.Vector2(node.x + dir.x, node.y + dir.y); - if (_this.isNodeInBounds(next) && _this.isNodePassable(next)) - _this._neighbors.push(next); - }); - return this._neighbors; - }; - AstarGridGraph.prototype.cost = function (from, to) { - return this.weightedNodes.find(function (p) { return p.equals(to); }) ? this.weightedNodeWeight : this.defaultWeight; - }; - AstarGridGraph.prototype.heuristic = function (node, goal) { - return Math.abs(node.x - goal.x) + Math.abs(node.y - goal.y); - }; - return AstarGridGraph; - }()); - es.AstarGridGraph = AstarGridGraph; -})(es || (es = {})); -var es; -(function (es) { - var PriorityQueue = (function () { - function PriorityQueue(maxNodes) { - this._numNodes = 0; - this._nodes = new Array(maxNodes + 1); - this._numNodesEverEnqueued = 0; - } - Object.defineProperty(PriorityQueue.prototype, "count", { - get: function () { - return this._numNodes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(PriorityQueue.prototype, "maxSize", { - get: function () { - return this._nodes.length - 1; - }, - enumerable: true, - configurable: true - }); - PriorityQueue.prototype.clear = function () { - this._nodes.splice(1, this._numNodes); - this._numNodes = 0; - }; - PriorityQueue.prototype.contains = function (node) { - if (!node) { - console.error("node cannot be null"); - return false; - } - if (node.queueIndex < 0 || node.queueIndex >= this._nodes.length) { - console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"); - return false; - } - return (this._nodes[node.queueIndex] == node); - }; - PriorityQueue.prototype.enqueue = function (node, priority) { - node.priority = priority; - this._numNodes++; - this._nodes[this._numNodes] = node; - node.queueIndex = this._numNodes; - node.insertionIndex = this._numNodesEverEnqueued++; - this.cascadeUp(this._nodes[this._numNodes]); - }; - PriorityQueue.prototype.dequeue = function () { - var returnMe = this._nodes[1]; - this.remove(returnMe); - return returnMe; - }; - PriorityQueue.prototype.remove = function (node) { - if (node.queueIndex == this._numNodes) { - this._nodes[this._numNodes] = null; - this._numNodes--; - return; - } - var formerLastNode = this._nodes[this._numNodes]; - this.swap(node, formerLastNode); - delete this._nodes[this._numNodes]; - this._numNodes--; - this.onNodeUpdated(formerLastNode); - }; - PriorityQueue.prototype.isValidQueue = function () { - for (var i = 1; i < this._nodes.length; i++) { - if (this._nodes[i]) { - var childLeftIndex = 2 * i; - if (childLeftIndex < this._nodes.length && this._nodes[childLeftIndex] && - this.hasHigherPriority(this._nodes[childLeftIndex], this._nodes[i])) - return false; - var childRightIndex = childLeftIndex + 1; - if (childRightIndex < this._nodes.length && this._nodes[childRightIndex] && - this.hasHigherPriority(this._nodes[childRightIndex], this._nodes[i])) - return false; - } - } - return true; - }; - PriorityQueue.prototype.onNodeUpdated = function (node) { - var parentIndex = Math.floor(node.queueIndex / 2); - var parentNode = this._nodes[parentIndex]; - if (parentIndex > 0 && this.hasHigherPriority(node, parentNode)) { - this.cascadeUp(node); - } - else { - this.cascadeDown(node); - } - }; - PriorityQueue.prototype.cascadeDown = function (node) { - var newParent; - var finalQueueIndex = node.queueIndex; - while (true) { - newParent = node; - var childLeftIndex = 2 * finalQueueIndex; - if (childLeftIndex > this._numNodes) { - node.queueIndex = finalQueueIndex; - this._nodes[finalQueueIndex] = node; - break; - } - var childLeft = this._nodes[childLeftIndex]; - if (this.hasHigherPriority(childLeft, newParent)) { - newParent = childLeft; - } - var childRightIndex = childLeftIndex + 1; - if (childRightIndex <= this._numNodes) { - var childRight = this._nodes[childRightIndex]; - if (this.hasHigherPriority(childRight, newParent)) { - newParent = childRight; - } - } - if (newParent != node) { - this._nodes[finalQueueIndex] = newParent; - var temp = newParent.queueIndex; - newParent.queueIndex = finalQueueIndex; - finalQueueIndex = temp; - } - else { - node.queueIndex = finalQueueIndex; - this._nodes[finalQueueIndex] = node; - break; - } - } - }; - PriorityQueue.prototype.cascadeUp = function (node) { - var parent = Math.floor(node.queueIndex / 2); - while (parent >= 1) { - var parentNode = this._nodes[parent]; - if (this.hasHigherPriority(parentNode, node)) - break; - this.swap(node, parentNode); - parent = Math.floor(node.queueIndex / 2); - } - }; - PriorityQueue.prototype.swap = function (node1, node2) { - this._nodes[node1.queueIndex] = node2; - this._nodes[node2.queueIndex] = node1; - var temp = node1.queueIndex; - node1.queueIndex = node2.queueIndex; - node2.queueIndex = temp; - }; - PriorityQueue.prototype.hasHigherPriority = function (higher, lower) { - return (higher.priority < lower.priority || - (higher.priority == lower.priority && higher.insertionIndex < lower.insertionIndex)); - }; - return PriorityQueue; - }()); - es.PriorityQueue = PriorityQueue; -})(es || (es = {})); -var es; -(function (es) { - var BreadthFirstPathfinder = (function () { - function BreadthFirstPathfinder() { - } - BreadthFirstPathfinder.search = function (graph, start, goal) { - var _this = this; - var foundPath = false; - var frontier = []; - frontier.unshift(start); - var cameFrom = new Map(); - cameFrom.set(start, start); - var _loop_3 = function () { - var current = frontier.shift(); - if (JSON.stringify(current) == JSON.stringify(goal)) { - foundPath = true; - return "break"; - } - graph.getNeighbors(current).forEach(function (next) { - if (!_this.hasKey(cameFrom, next)) { - frontier.unshift(next); - cameFrom.set(next, current); - } - }); - }; - while (frontier.length > 0) { - var state_2 = _loop_3(); - if (state_2 === "break") - break; - } - return foundPath ? es.AStarPathfinder.recontructPath(cameFrom, start, goal) : null; - }; - BreadthFirstPathfinder.hasKey = function (map, compareKey) { - var iterator = map.keys(); - var r; - while (r = iterator.next(), !r.done) { - if (JSON.stringify(r.value) == JSON.stringify(compareKey)) - return true; - } - return false; - }; - return BreadthFirstPathfinder; - }()); - es.BreadthFirstPathfinder = BreadthFirstPathfinder; -})(es || (es = {})); -var es; -(function (es) { - var UnweightedGraph = (function () { - function UnweightedGraph() { - this.edges = new Map(); - } - UnweightedGraph.prototype.addEdgesForNode = function (node, edges) { - this.edges.set(node, edges); - return this; - }; - UnweightedGraph.prototype.getNeighbors = function (node) { - return this.edges.get(node); - }; - return UnweightedGraph; - }()); - es.UnweightedGraph = UnweightedGraph; -})(es || (es = {})); -var es; -(function (es) { - var Vector2 = (function () { - function Vector2(x, y) { - this.x = 0; - this.y = 0; - this.x = x ? x : 0; - this.y = y != undefined ? y : this.x; - } - Object.defineProperty(Vector2, "zero", { - get: function () { - return new Vector2(0, 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Vector2, "one", { - get: function () { - return new Vector2(1, 1); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Vector2, "unitX", { - get: function () { - return new Vector2(1, 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Vector2, "unitY", { - get: function () { - return new Vector2(0, 1); - }, - enumerable: true, - configurable: true - }); - Vector2.add = function (value1, value2) { - var result = new Vector2(0, 0); - result.x = value1.x + value2.x; - result.y = value1.y + value2.y; - return result; - }; - Vector2.divide = function (value1, value2) { - var result = new Vector2(0, 0); - result.x = value1.x / value2.x; - result.y = value1.y / value2.y; - return result; - }; - Vector2.multiply = function (value1, value2) { - var result = new Vector2(0, 0); - result.x = value1.x * value2.x; - result.y = value1.y * value2.y; - return result; - }; - Vector2.subtract = function (value1, value2) { - var result = new Vector2(0, 0); - result.x = value1.x - value2.x; - result.y = value1.y - value2.y; - return result; - }; - Vector2.normalize = function (value) { - var nValue = new Vector2(value.x, value.y); - var val = 1 / Math.sqrt((nValue.x * nValue.x) + (nValue.y * nValue.y)); - nValue.x *= val; - nValue.y *= val; - return nValue; - }; - Vector2.dot = function (value1, value2) { - return (value1.x * value2.x) + (value1.y * value2.y); - }; - Vector2.distanceSquared = function (value1, value2) { - var v1 = value1.x - value2.x, v2 = value1.y - value2.y; - return (v1 * v1) + (v2 * v2); - }; - Vector2.clamp = function (value1, min, max) { - return new Vector2(es.MathHelper.clamp(value1.x, min.x, max.x), es.MathHelper.clamp(value1.y, min.y, max.y)); - }; - Vector2.lerp = function (value1, value2, amount) { - return new Vector2(es.MathHelper.lerp(value1.x, value2.x, amount), es.MathHelper.lerp(value1.y, value2.y, amount)); - }; - Vector2.transform = function (position, matrix) { - return new Vector2((position.x * matrix.m11) + (position.y * matrix.m21) + matrix.m31, (position.x * matrix.m12) + (position.y * matrix.m22) + matrix.m32); - }; - Vector2.distance = function (value1, value2) { - var v1 = value1.x - value2.x, v2 = value1.y - value2.y; - return Math.sqrt((v1 * v1) + (v2 * v2)); - }; - Vector2.angle = function (from, to) { - from = Vector2.normalize(from); - to = Vector2.normalize(to); - return Math.acos(es.MathHelper.clamp(Vector2.dot(from, to), -1, 1)) * es.MathHelper.Rad2Deg; - }; - Vector2.negate = function (value) { - value.x = -value.x; - value.y = -value.y; - return value; - }; - Vector2.prototype.add = function (value) { - this.x += value.x; - this.y += value.y; - return this; - }; - Vector2.prototype.divide = function (value) { - this.x /= value.x; - this.y /= value.y; - return this; - }; - Vector2.prototype.multiply = function (value) { - this.x *= value.x; - this.y *= value.y; - return this; - }; - Vector2.prototype.subtract = function (value) { - this.x -= value.x; - this.y -= value.y; - return this; - }; - Vector2.prototype.normalize = function () { - var val = 1 / Math.sqrt((this.x * this.x) + (this.y * this.y)); - this.x *= val; - this.y *= val; - }; - Vector2.prototype.length = function () { - return Math.sqrt((this.x * this.x) + (this.y * this.y)); - }; - Vector2.prototype.lengthSquared = function () { - return (this.x * this.x) + (this.y * this.y); - }; - Vector2.prototype.round = function () { - return new Vector2(Math.round(this.x), Math.round(this.y)); - }; - Vector2.prototype.equals = function (other) { - if (other instanceof Vector2) { - return other.x == this.x && other.y == this.y; - } - return false; - }; - return Vector2; - }()); - es.Vector2 = Vector2; -})(es || (es = {})); -var es; -(function (es) { - var UnweightedGridGraph = (function () { - function UnweightedGridGraph(width, height, allowDiagonalSearch) { - if (allowDiagonalSearch === void 0) { allowDiagonalSearch = false; } - this.walls = []; - this._neighbors = new Array(4); - this._width = width; - this._hegiht = height; - this._dirs = allowDiagonalSearch ? UnweightedGridGraph.COMPASS_DIRS : UnweightedGridGraph.CARDINAL_DIRS; - } - UnweightedGridGraph.prototype.isNodeInBounds = function (node) { - return 0 <= node.x && node.x < this._width && 0 <= node.y && node.y < this._hegiht; - }; - UnweightedGridGraph.prototype.isNodePassable = function (node) { - return !this.walls.firstOrDefault(function (wall) { return JSON.stringify(wall) == JSON.stringify(node); }); - }; - UnweightedGridGraph.prototype.getNeighbors = function (node) { - var _this = this; - this._neighbors.length = 0; - this._dirs.forEach(function (dir) { - var next = new es.Vector2(node.x + dir.x, node.y + dir.y); - if (_this.isNodeInBounds(next) && _this.isNodePassable(next)) - _this._neighbors.push(next); - }); - return this._neighbors; - }; - UnweightedGridGraph.prototype.search = function (start, goal) { - return es.BreadthFirstPathfinder.search(this, start, goal); - }; - UnweightedGridGraph.CARDINAL_DIRS = [ - new es.Vector2(1, 0), - new es.Vector2(0, -1), - new es.Vector2(-1, 0), - new es.Vector2(0, -1) - ]; - UnweightedGridGraph.COMPASS_DIRS = [ - new es.Vector2(1, 0), - new es.Vector2(1, -1), - new es.Vector2(0, -1), - new es.Vector2(-1, -1), - new es.Vector2(-1, 0), - new es.Vector2(-1, 1), - new es.Vector2(0, 1), - new es.Vector2(1, 1), - ]; - return UnweightedGridGraph; - }()); - es.UnweightedGridGraph = UnweightedGridGraph; -})(es || (es = {})); -var es; -(function (es) { - var WeightedGridGraph = (function () { - function WeightedGridGraph(width, height, allowDiagonalSearch) { - if (allowDiagonalSearch === void 0) { allowDiagonalSearch = false; } - this.walls = []; - this.weightedNodes = []; - this.defaultWeight = 1; - this.weightedNodeWeight = 5; - this._neighbors = new Array(4); - this._width = width; - this._height = height; - this._dirs = allowDiagonalSearch ? WeightedGridGraph.COMPASS_DIRS : WeightedGridGraph.CARDINAL_DIRS; - } - WeightedGridGraph.prototype.isNodeInBounds = function (node) { - return 0 <= node.x && node.x < this._width && 0 <= node.y && node.y < this._height; - }; - WeightedGridGraph.prototype.isNodePassable = function (node) { - return !this.walls.firstOrDefault(function (wall) { return JSON.stringify(wall) == JSON.stringify(node); }); - }; - WeightedGridGraph.prototype.search = function (start, goal) { - return es.WeightedPathfinder.search(this, start, goal); - }; - WeightedGridGraph.prototype.getNeighbors = function (node) { - var _this = this; - this._neighbors.length = 0; - this._dirs.forEach(function (dir) { - var next = new es.Vector2(node.x + dir.x, node.y + dir.y); - if (_this.isNodeInBounds(next) && _this.isNodePassable(next)) - _this._neighbors.push(next); - }); - return this._neighbors; - }; - WeightedGridGraph.prototype.cost = function (from, to) { - return this.weightedNodes.find(function (t) { return JSON.stringify(t) == JSON.stringify(to); }) ? this.weightedNodeWeight : this.defaultWeight; - }; - WeightedGridGraph.CARDINAL_DIRS = [ - new es.Vector2(1, 0), - new es.Vector2(0, -1), - new es.Vector2(-1, 0), - new es.Vector2(0, 1) - ]; - WeightedGridGraph.COMPASS_DIRS = [ - new es.Vector2(1, 0), - new es.Vector2(1, -1), - new es.Vector2(0, -1), - new es.Vector2(-1, -1), - new es.Vector2(-1, 0), - new es.Vector2(-1, 1), - new es.Vector2(0, 1), - new es.Vector2(1, 1), - ]; - return WeightedGridGraph; - }()); - es.WeightedGridGraph = WeightedGridGraph; -})(es || (es = {})); -var es; -(function (es) { - var WeightedNode = (function (_super) { - __extends(WeightedNode, _super); - function WeightedNode(data) { - var _this = _super.call(this) || this; - _this.data = data; - return _this; - } - return WeightedNode; - }(es.PriorityQueueNode)); - es.WeightedNode = WeightedNode; - var WeightedPathfinder = (function () { - function WeightedPathfinder() { - } - WeightedPathfinder.search = function (graph, start, goal) { - var _this = this; - var foundPath = false; - var cameFrom = new Map(); - cameFrom.set(start, start); - var costSoFar = new Map(); - var frontier = new es.PriorityQueue(1000); - frontier.enqueue(new WeightedNode(start), 0); - costSoFar.set(start, 0); - var _loop_4 = function () { - var current = frontier.dequeue(); - if (JSON.stringify(current.data) == JSON.stringify(goal)) { - foundPath = true; - return "break"; - } - graph.getNeighbors(current.data).forEach(function (next) { - var newCost = costSoFar.get(current.data) + graph.cost(current.data, next); - if (!_this.hasKey(costSoFar, next) || newCost < costSoFar.get(next)) { - costSoFar.set(next, newCost); - var priprity = newCost; - frontier.enqueue(new WeightedNode(next), priprity); - cameFrom.set(next, current.data); - } - }); - }; - while (frontier.count > 0) { - var state_3 = _loop_4(); - if (state_3 === "break") - break; - } - return foundPath ? this.recontructPath(cameFrom, start, goal) : null; - }; - WeightedPathfinder.recontructPath = function (cameFrom, start, goal) { - var path = []; - var current = goal; - path.push(goal); - while (current != start) { - current = this.getKey(cameFrom, current); - path.push(current); - } - path.reverse(); - return path; - }; - WeightedPathfinder.hasKey = function (map, compareKey) { - var iterator = map.keys(); - var r; - while (r = iterator.next(), !r.done) { - if (JSON.stringify(r.value) == JSON.stringify(compareKey)) - return true; - } - return false; - }; - WeightedPathfinder.getKey = function (map, compareKey) { - var iterator = map.keys(); - var valueIterator = map.values(); - var r; - var v; - while (r = iterator.next(), v = valueIterator.next(), !r.done) { - if (JSON.stringify(r.value) == JSON.stringify(compareKey)) - return v.value; - } - return null; - }; - return WeightedPathfinder; - }()); - es.WeightedPathfinder = WeightedPathfinder; -})(es || (es = {})); -var es; -(function (es) { - var AStarStorage = (function () { - function AStarStorage() { - this._opened = new Array(AStarStorage.MAX_NODES); - this._closed = new Array(AStarStorage.MAX_NODES); - } - AStarStorage.prototype.clear = function () { - for (var i = 0; i < this._numOpened; i++) { - es.Pool.free(this._opened[i]); - this._opened[i] = null; - } - for (var i = 0; i < this._numClosed; i++) { - es.Pool.free(this._closed[i]); - this._closed[i] = null; - } - this._numOpened = this._numClosed = 0; - this._lastFoundClosed = this._lastFoundOpened = 0; - }; - AStarStorage.prototype.findOpened = function (node) { - for (var i = 0; i < this._numOpened; i++) { - var care = node.worldState.dontCare ^ -1; - if ((node.worldState.values & care) == (this._opened[i].worldState.values & care)) { - this._lastFoundClosed = i; - return this._closed[i]; - } - } - return null; - }; - AStarStorage.prototype.findClosed = function (node) { - for (var i = 0; i < this._numClosed; i++) { - var care = node.worldState.dontCare ^ -1; - if ((node.worldState.values & care) == (this._closed[i].worldState.values & care)) { - this._lastFoundClosed = i; - return this._closed[i]; - } - } - return null; - }; - AStarStorage.prototype.hasOpened = function () { - return this._numOpened > 0; - }; - AStarStorage.prototype.removeOpened = function (node) { - if (this._numOpened > 0) - this._opened[this._lastFoundOpened] = this._opened[this._numOpened - 1]; - this._numOpened--; - }; - AStarStorage.prototype.removeClosed = function (node) { - if (this._numClosed > 0) - this._closed[this._lastFoundClosed] = this._closed[this._numClosed - 1]; - this._numClosed--; - }; - AStarStorage.prototype.isOpen = function (node) { - return this._opened.indexOf(node) > -1; - }; - AStarStorage.prototype.isClosed = function (node) { - return this._closed.indexOf(node) > -1; - }; - AStarStorage.prototype.addToOpenList = function (node) { - this._opened[this._numOpened++] = node; - }; - AStarStorage.prototype.addToClosedList = function (node) { - this._closed[this._numClosed++] = node; - }; - AStarStorage.prototype.removeCheapestOpenNode = function () { - var lowestVal = Number.MAX_VALUE; - this._lastFoundOpened = -1; - for (var i = 0; i < this._numOpened; i++) { - if (this._opened[i].costSoFarAndHeuristicCost < lowestVal) { - lowestVal = this._opened[i].costSoFarAndHeuristicCost; - this._lastFoundOpened = i; - } - } - var val = this._opened[this._lastFoundOpened]; - this.removeOpened(val); - return val; - }; - AStarStorage.MAX_NODES = 128; - return AStarStorage; - }()); - es.AStarStorage = AStarStorage; -})(es || (es = {})); -var es; -(function (es) { - var AStarNode = (function () { - function AStarNode() { - } - AStarNode.prototype.equals = function (other) { - var care = this.worldState.dontCare ^ -1; - return (this.worldState.values & care) == (other.worldState.values & care); - }; - AStarNode.prototype.compareTo = function (other) { - return this.costSoFarAndHeuristicCost - other.costSoFarAndHeuristicCost; - }; - AStarNode.prototype.reset = function () { - this.action = null; - this.parent = null; - }; - AStarNode.prototype.clone = function () { - var node = new AStarNode(); - node.action = this.action; - node.costSoFar = this.costSoFar; - node.depth = this.depth; - node.parent = this.parent; - node.parentWorldState = this.parentWorldState; - node.heuristicCost = this.heuristicCost; - node.worldState = this.worldState; - return node; - }; - AStarNode.prototype.toString = function () { - return "[cost: " + this.costSoFar + " | heuristic: " + this.heuristicCost + "]: " + this.action; - }; - return AStarNode; - }()); - es.AStarNode = AStarNode; - var AStar = (function () { - function AStar() { - } - AStar.plan = function (ap, start, goal, selectedNodes) { - if (selectedNodes === void 0) { selectedNodes = null; } - this.storage.clear(); - var currentNode = es.Pool.obtain(AStarNode); - currentNode.worldState = start; - currentNode.parentWorldState = start; - currentNode.costSoFar = 0; - currentNode.heuristicCost = this.calculateHeuristic(start, goal); - currentNode.costSoFarAndHeuristicCost = currentNode.costSoFar + currentNode.heuristicCost; - currentNode.depth = 1; - this.storage.addToOpenList(currentNode); - while (true) { - if (!this.storage.hasOpened()) { - this.storage.clear(); - return null; - } - currentNode = this.storage.removeCheapestOpenNode(); - this.storage.addToClosedList(currentNode); - if (goal.equals(currentNode.worldState)) { - var plan = this.reconstructPlan(currentNode, selectedNodes); - this.storage.clear(); - return plan; - } - var neighbors = ap.getPossibleTransitions(currentNode.worldState); - for (var i = 0; i < neighbors.length; i++) { - var cur = neighbors[i]; - var opened = this.storage.findOpened(cur); - var closed_1 = this.storage.findClosed(cur); - var cost = currentNode.costSoFar + cur.costSoFar; - if (opened != null && cost < opened.costSoFar) { - this.storage.removeOpened(opened); - opened = null; - } - if (closed_1 != null && cost < closed_1.costSoFar) { - this.storage.removeClosed(closed_1); - } - if (opened == null && closed_1 == null) { - var nb = es.Pool.obtain(AStarNode); - nb.worldState = cur.worldState; - nb.costSoFar = cost; - nb.heuristicCost = this.calculateHeuristic(cur.worldState, goal); - nb.costSoFarAndHeuristicCost = nb.costSoFar + nb.heuristicCost; - nb.action = cur.action; - nb.parentWorldState = currentNode.worldState; - nb.parent = currentNode; - nb.depth = currentNode.depth + 1; - this.storage.addToOpenList(nb); - } - } - es.ListPool.free(neighbors); - } - }; - AStar.reconstructPlan = function (goalNode, selectedNodes) { - var totalActionsInPlan = goalNode.depth - 1; - var plan = new Array(totalActionsInPlan); - var curnode = goalNode; - for (var i = 0; i <= totalActionsInPlan - 1; i++) { - if (selectedNodes != null) - selectedNodes.push(curnode.clone()); - plan.push(curnode.action); - curnode = curnode.parent; - } - if (selectedNodes != null) - selectedNodes.reverse(); - return plan; - }; - AStar.calculateHeuristic = function (fr, to) { - var care = (to.dontCare ^ -1); - var diff = (fr.values & care) ^ (to.values & care); - var dist = 0; - for (var i = 0; i < es.ActionPlanner.MAX_CONDITIONS; ++i) - if ((diff & (1 << i)) != 0) - dist++; - return dist; - }; - AStar.storage = new es.AStarStorage(); - return AStar; - }()); - es.AStar = AStar; -})(es || (es = {})); -var es; -(function (es) { - var Action = (function () { - function Action(name, cost) { - if (cost === void 0) { cost = 1; } - this.cost = 1; - this._preConditions = new Set(); - this._postConditions = new Set(); - this.name = name; - this.cost = cost; - } - Action.prototype.setPrecondition = function (conditionName, value) { - this._preConditions.add([conditionName, value]); - }; - Action.prototype.setPostcondition = function (conditionName, value) { - this._preConditions.add([conditionName, value]); - }; - Action.prototype.validate = function () { - return true; - }; - Action.prototype.toString = function () { - return "[Action] " + this.name + " - cost: " + this.cost; - }; - return Action; - }()); - es.Action = Action; -})(es || (es = {})); -var es; -(function (es) { - var ActionPlanner = (function () { - function ActionPlanner() { - this.conditionNames = new Array(ActionPlanner.MAX_CONDITIONS); - this._actions = []; - this._viableActions = []; - this._preConditions = new Array(ActionPlanner.MAX_CONDITIONS); - this._postConditions = new Array(ActionPlanner.MAX_CONDITIONS); - this._numConditionNames = 0; - for (var i = 0; i < ActionPlanner.MAX_CONDITIONS; ++i) { - this.conditionNames[i] = null; - this._preConditions[i] = es.WorldState.create(this); - this._postConditions[i] = es.WorldState.create(this); - } - } - ActionPlanner.prototype.createWorldState = function () { - return es.WorldState.create(this); - }; - ActionPlanner.prototype.addAction = function (action) { - var _this = this; - var actionId = this.findActionIndex(action); - if (actionId == -1) - throw new Error("无法找到或创建行动"); - action._preConditions.forEach(function (preCondition) { - var conditionId = _this.findConditionNameIndex(preCondition[0]); - if (conditionId == -1) - throw new Error("无法找到或创建条件名称"); - _this._preConditions[actionId].set(conditionId, preCondition[1]); - }); - action._postConditions.forEach(function (postCondition) { - var conditionId = _this.findConditionNameIndex(postCondition[0]); - if (conditionId == -1) - throw new Error("找不到条件名称"); - _this._postConditions[actionId].set(conditionId, postCondition[1]); - }); - }; - ActionPlanner.prototype.plan = function (startState, goalState, selectedNode) { - if (selectedNode === void 0) { selectedNode = null; } - this._viableActions.length = 0; - for (var i = 0; i < this._actions.length; i++) { - if (this._actions[i].validate()) - this._viableActions.push(this._actions[i]); - } - return es.AStar.plan(this, startState, goalState, selectedNode); - }; - ActionPlanner.prototype.getPossibleTransitions = function (fr) { - var result = es.ListPool.obtain(); - for (var i = 0; i < this._viableActions.length; ++i) { - var pre = this._preConditions[i]; - var care = (pre.dontCare ^ -1); - var met = ((pre.values & care) == (fr.values & care)); - if (met) { - var node = es.Pool.obtain(es.AStarNode); - node.action = this._viableActions[i]; - node.costSoFar = this._viableActions[i].cost; - node.worldState = this.applyPostConditions(this, i, fr); - result.push(node); - } - } - return result; - }; - ActionPlanner.prototype.applyPostConditions = function (ap, actionnr, fr) { - var pst = ap._postConditions[actionnr]; - var unaffected = pst.dontCare; - var affected = (unaffected ^ -1); - fr.values = (fr.values & unaffected) | (pst.values & affected); - fr.dontCare &= pst.dontCare; - return fr; - }; - ActionPlanner.prototype.findConditionNameIndex = function (conditionName) { - var idx; - for (idx = 0; idx < this._numConditionNames; ++idx) { - if (this.conditionNames[idx] == conditionName) - return idx; - } - if (idx < ActionPlanner.MAX_CONDITIONS - 1) { - this.conditionNames[idx] = conditionName; - this._numConditionNames++; - return idx; - } - return -1; - }; - ActionPlanner.prototype.findActionIndex = function (action) { - var idx = this._actions.indexOf(action); - if (idx > -1) - return idx; - this._actions.push(action); - return this._actions.length - 1; - }; - ActionPlanner.MAX_CONDITIONS = 64; - return ActionPlanner; - }()); - es.ActionPlanner = ActionPlanner; -})(es || (es = {})); -var es; -(function (es) { - var Agent = (function () { - function Agent() { - this._planner = new es.ActionPlanner(); - } - Agent.prototype.plan = function (debugPlan) { - if (debugPlan === void 0) { debugPlan = false; } - var nodes = null; - if (debugPlan) - nodes = []; - this.actions = this._planner.plan(this.getWorldState(), this.getGoalState(), nodes); - if (nodes != null && nodes.length > 0) { - console.log("---- ActionPlanner plan ----"); - console.log("plan cost = " + nodes[nodes.length - 1].costSoFar); - console.log(" start" + "\t" + this.getWorldState().describe(this._planner)); - for (var i = 0; i < nodes.length; i++) { - console.log(i + ": " + nodes[i].action.name + "\t" + nodes[i].worldState.describe(this._planner)); - es.Pool.free(nodes[i]); - } - } - return this.hasActionPlan(); - }; - Agent.prototype.hasActionPlan = function () { - return this.actions != null && this.actions.length > 0; - }; - return Agent; - }()); - es.Agent = Agent; -})(es || (es = {})); -var es; -(function (es) { - var WorldState = (function () { - function WorldState(planner, values, dontcare) { - this.planner = planner; - this.values = values; - this.dontCare = dontcare; - } - WorldState.create = function (planner) { - return new WorldState(planner, 0, -1); - }; - WorldState.prototype.set = function (conditionId, value) { - if (typeof conditionId == "string") { - return this.set(this.planner.findConditionNameIndex(conditionId), value); - } - this.values = value ? (this.values | (1 << conditionId)) : (this.values & ~(1 << conditionId)); - this.dontCare ^= (1 << conditionId); - return true; - }; - WorldState.prototype.equals = function (other) { - var care = this.dontCare ^ -1; - return (this.values & care) == (other.values & care); - }; - WorldState.prototype.describe = function (planner) { - var s = ""; - for (var i = 0; i < es.ActionPlanner.MAX_CONDITIONS; i++) { - if ((this.dontCare & (1 << i)) == 0) { - var val = planner.conditionNames[i]; - if (val == null) - continue; - var set = ((this.values & (1 << i)) != 0); - if (s.length > 0) - s += ", "; - s += (set ? val.toUpperCase() : val); - } - } - return s; - }; - return WorldState; - }()); - es.WorldState = WorldState; -})(es || (es = {})); -var es; -(function (es) { - var Core = (function (_super) { - __extends(Core, _super); - function Core() { - var _this = _super.call(this) || this; - _this._globalManagers = []; - _this._coroutineManager = new es.CoroutineManager(); - _this._timerManager = new es.TimerManager(); - _this._frameCounterElapsedTime = 0; - _this._frameCounter = 0; - Core._instance = _this; - Core.emitter = new es.Emitter(); - Core.content = new es.ContentManager(); - _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this); - Core.registerGlobalManager(_this._coroutineManager); - Core.registerGlobalManager(_this._timerManager); - return _this; - } - Object.defineProperty(Core, "Instance", { - get: function () { - return this._instance; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Core, "scene", { - get: function () { - if (!this._instance) - return null; - return this._instance._scene; - }, - set: function (value) { - if (!value) { - console.error("场景不能为空"); - return; - } - if (this._instance._scene == null) { - this._instance.addChild(value); - this._instance._scene = value; - this._instance._scene.begin(); - Core.Instance.onSceneChanged(); - } - else { - this._instance._nextScene = value; - } - }, - enumerable: true, - configurable: true - }); - Core.startSceneTransition = function (sceneTransition) { - if (this._instance._sceneTransition) { - console.warn("在前一个场景完成之前,不能开始一个新的场景转换。"); - return; - } - this._instance._sceneTransition = sceneTransition; - return sceneTransition; - }; - Core.registerGlobalManager = function (manager) { - this._instance._globalManagers.push(manager); - manager.enabled = true; - }; - Core.unregisterGlobalManager = function (manager) { - this._instance._globalManagers.remove(manager); - manager.enabled = false; - }; - Core.getGlobalManager = function (type) { - for (var i = 0; i < this._instance._globalManagers.length; i++) { - if (this._instance._globalManagers[i] instanceof type) - return this._instance._globalManagers[i]; - } - return null; - }; - Core.startCoroutine = function (enumerator) { - return this._instance._coroutineManager.startCoroutine(enumerator); - }; - Core.schedule = function (timeInSeconds, repeats, context, onTime) { - if (repeats === void 0) { repeats = false; } - if (context === void 0) { context = null; } - return this._instance._timerManager.schedule(timeInSeconds, repeats, context, onTime); - }; - Core.prototype.onOrientationChanged = function () { - Core.emitter.emit(es.CoreEvents.OrientationChanged); - }; - Core.prototype.draw = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (!this._sceneTransition) return [3, 4]; - this._sceneTransition.preRender(); - if (!(this._scene && !this._sceneTransition.hasPreviousSceneRender)) return [3, 2]; - this._scene.render(); - this._scene.postRender(); - return [4, this._sceneTransition.onBeginTransition()]; - case 1: - _a.sent(); - return [3, 3]; - case 2: - if (this._sceneTransition) { - if (this._scene && this._sceneTransition.isNewSceneLoaded) { - this._scene.render(); - this._scene.postRender(); - } - this._sceneTransition.render(); - } - _a.label = 3; - case 3: return [3, 5]; - case 4: - if (this._scene) { - this._scene.render(); - es.Debug.render(); - this._scene.postRender(); - } - _a.label = 5; - case 5: return [2]; - } - }); - }); - }; - Core.prototype.startDebugUpdate = function () { - es.TimeRuler.Instance.startFrame(); - es.TimeRuler.Instance.beginMark("update", 0x00FF00); - }; - Core.prototype.endDebugUpdate = function () { - es.TimeRuler.Instance.endMark("update"); - }; - Core.prototype.startDebugDraw = function (elapsedGameTime) { - es.TimeRuler.Instance.beginMark("draw", 0xFFD700); - this._frameCounter++; - this._frameCounterElapsedTime += elapsedGameTime; - if (this._frameCounterElapsedTime >= 1) { - this._frameCounter = 0; - this._frameCounterElapsedTime -= 1; - } - }; - Core.prototype.endDebugDraw = function () { - es.TimeRuler.Instance.endMark("draw"); - es.TimeRuler.Instance.render(); - }; - Core.prototype.onSceneChanged = function () { - Core.emitter.emit(es.CoreEvents.SceneChanged); - es.Time.sceneChanged(); - }; - Core.prototype.onGraphicsDeviceReset = function () { - Core.emitter.emit(es.CoreEvents.GraphicsDeviceReset); - }; - Core.prototype.initialize = function () { - es.Graphics.Instance = new es.Graphics(); - }; - Core.prototype.update = function () { - return __awaiter(this, void 0, void 0, function () { - var i; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - es.Time.update(egret.getTimer()); - es.Input.update(); - if (!this._scene) return [3, 2]; - for (i = this._globalManagers.length - 1; i >= 0; i--) { - if (this._globalManagers[i].enabled) - this._globalManagers[i].update(); - } - if (!this._sceneTransition || - (this._sceneTransition && (!this._sceneTransition.loadsNewScene || this._sceneTransition.isNewSceneLoaded))) { - this._scene.update(); - } - if (!this._nextScene) return [3, 2]; - if (this._scene.parent) - this._scene.parent.removeChild(this._scene); - this._scene.end(); - this._scene = this._nextScene; - this._nextScene = null; - this.onSceneChanged(); - return [4, this._scene.begin()]; - case 1: - _a.sent(); - this.addChild(this._scene); - _a.label = 2; - case 2: return [4, this.draw()]; - case 3: - _a.sent(); - return [2]; - } - }); - }); - }; - Core.prototype.onAddToStage = function () { - Core.graphicsDevice = new es.GraphicsDevice(); - this.addEventListener(egret.Event.RESIZE, this.onGraphicsDeviceReset, this); - this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE, this.onOrientationChanged, this); - this.addEventListener(egret.Event.ENTER_FRAME, this.update, this); - es.Input.initialize(); - KeyboardUtils.init(); - this.initialize(); - }; - Core.debugRenderEndabled = false; - return Core; - }(egret.DisplayObjectContainer)); - es.Core = Core; -})(es || (es = {})); -var es; -(function (es) { - var Colors = (function () { - function Colors() { - } - Colors.renderableBounds = 0xffff00; - Colors.renderableCenter = 0x9932CC; - Colors.colliderBounds = 0x555555; - Colors.colliderEdge = 0x8B0000; - Colors.colliderPosition = 0xFFFF00; - Colors.colliderCenter = 0xFF0000; - return Colors; - }()); - es.Colors = Colors; - var Size = (function () { - function Size() { - } - Object.defineProperty(Size, "lineSizeMultiplier", { - get: function () { - return Math.max(Math.ceil(es.Core.scene.x / es.Core.scene.width), 1); - }, - enumerable: true, - configurable: true - }); - return Size; - }()); - es.Size = Size; - var Debug = (function () { - function Debug() { - } - Debug.drawHollowRect = function (rectanle, color, duration) { - if (duration === void 0) { duration = 0; } - this._debugDrawItems.push(new es.DebugDrawItem(rectanle, color, duration)); - }; - Debug.render = function () { - if (this._debugDrawItems.length > 0) { - var debugShape = new egret.Shape(); - if (es.Core.scene) { - es.Core.scene.addChild(debugShape); - } - for (var i = this._debugDrawItems.length - 1; i >= 0; i--) { - var item = this._debugDrawItems[i]; - if (item.draw(debugShape)) - this._debugDrawItems.removeAt(i); - } - } - }; - Debug._debugDrawItems = []; - return Debug; - }()); - es.Debug = Debug; -})(es || (es = {})); -var es; -(function (es) { - var DebugDefaults = (function () { - function DebugDefaults() { - } - DebugDefaults.verletParticle = 0xDC345E; - DebugDefaults.verletConstraintEdge = 0x433E36; - return DebugDefaults; - }()); - es.DebugDefaults = DebugDefaults; -})(es || (es = {})); -var es; -(function (es) { - var DebugDrawType; - (function (DebugDrawType) { - DebugDrawType[DebugDrawType["line"] = 0] = "line"; - DebugDrawType[DebugDrawType["hollowRectangle"] = 1] = "hollowRectangle"; - DebugDrawType[DebugDrawType["pixel"] = 2] = "pixel"; - DebugDrawType[DebugDrawType["text"] = 3] = "text"; - })(DebugDrawType = es.DebugDrawType || (es.DebugDrawType = {})); - var DebugDrawItem = (function () { - function DebugDrawItem(rectangle, color, duration) { - this.rectangle = rectangle; - this.color = color; - this.duration = duration; - this.drawType = DebugDrawType.hollowRectangle; - } - DebugDrawItem.prototype.draw = function (shape) { - switch (this.drawType) { - case DebugDrawType.line: - break; - case DebugDrawType.hollowRectangle: - break; - case DebugDrawType.pixel: - break; - case DebugDrawType.text: - break; - } - this.duration -= es.Time.deltaTime; - return this.duration < 0; - }; - return DebugDrawItem; - }()); - es.DebugDrawItem = DebugDrawItem; -})(es || (es = {})); -var es; -(function (es) { - var Component = (function (_super) { - __extends(Component, _super); - function Component() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.updateInterval = 1; - _this.debugDisplayObject = new egret.DisplayObjectContainer(); - _this._enabled = true; - _this._updateOrder = 0; - return _this; - } - Object.defineProperty(Component.prototype, "transform", { - get: function () { - return this.entity.transform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Component.prototype, "enabled", { - get: function () { - return this.entity ? this.entity.enabled && this._enabled : this._enabled; - }, - set: function (value) { - this.setEnabled(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Component.prototype, "updateOrder", { - get: function () { - return this._updateOrder; - }, - set: function (value) { - this.setUpdateOrder(value); - }, - enumerable: true, - configurable: true - }); - Component.prototype.initialize = function () { - }; - Component.prototype.onAddedToEntity = function () { - }; - Component.prototype.onRemovedFromEntity = function () { - }; - Component.prototype.onEntityTransformChanged = function (comp) { - }; - Component.prototype.debugRender = function (camera) { - }; - Component.prototype.onEnabled = function () { - }; - Component.prototype.onDisabled = function () { - }; - Component.prototype.update = function () { - }; - Component.prototype.setEnabled = function (isEnabled) { - if (this._enabled != isEnabled) { - this._enabled = isEnabled; - if (this._enabled) { - this.onEnabled(); - } - else { - this.onDisabled(); - } - } - return this; - }; - Component.prototype.setUpdateOrder = function (updateOrder) { - if (this._updateOrder != updateOrder) { - this._updateOrder = updateOrder; - } - return this; - }; - return Component; - }(egret.HashObject)); - es.Component = Component; -})(es || (es = {})); -var es; -(function (es) { - var CoreEvents; - (function (CoreEvents) { - CoreEvents[CoreEvents["GraphicsDeviceReset"] = 0] = "GraphicsDeviceReset"; - CoreEvents[CoreEvents["SceneChanged"] = 1] = "SceneChanged"; - CoreEvents[CoreEvents["OrientationChanged"] = 2] = "OrientationChanged"; - })(CoreEvents = es.CoreEvents || (es.CoreEvents = {})); -})(es || (es = {})); -var es; -(function (es) { - var Entity = (function () { - function Entity(name) { - this.updateInterval = 1; - this._tag = 0; - this._enabled = true; - this._updateOrder = 0; - this.components = new es.ComponentList(this); - this.transform = new es.Transform(this); - this.name = name; - this.id = Entity._idGenerator++; - this.componentBits = new es.BitSet(); - } - Object.defineProperty(Entity.prototype, "isDestroyed", { - get: function () { - return this._isDestroyed; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "tag", { - get: function () { - return this._tag; - }, - set: function (value) { - this.setTag(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "enabled", { - get: function () { - return this._enabled; - }, - set: function (value) { - this.setEnabled(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "updateOrder", { - get: function () { - return this._updateOrder; - }, - set: function (value) { - this.setUpdateOrder(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "parent", { - get: function () { - return this.transform.parent; - }, - set: function (value) { - this.transform.setParent(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "childCount", { - get: function () { - return this.transform.childCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "position", { - get: function () { - return this.transform.position; - }, - set: function (value) { - this.transform.setPosition(value.x, value.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "localPosition", { - get: function () { - return this.transform.localPosition; - }, - set: function (value) { - this.transform.setLocalPosition(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "rotation", { - get: function () { - return this.transform.rotation; - }, - set: function (value) { - this.transform.setRotation(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "rotationDegrees", { - get: function () { - return this.transform.rotationDegrees; - }, - set: function (value) { - this.transform.setRotationDegrees(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "localRotation", { - get: function () { - return this.transform.localRotation; - }, - set: function (value) { - this.transform.setLocalRotation(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "localRotationDegrees", { - get: function () { - return this.transform.localRotationDegrees; - }, - set: function (value) { - this.transform.setLocalRotationDegrees(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "scale", { - get: function () { - return this.transform.scale; - }, - set: function (value) { - this.transform.setScale(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "localScale", { - get: function () { - return this.transform.localScale; - }, - set: function (value) { - this.transform.setLocalScale(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "worldInverseTransform", { - get: function () { - return this.transform.worldInverseTransform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "localToWorldTransform", { - get: function () { - return this.transform.localToWorldTransform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Entity.prototype, "worldToLocalTransform", { - get: function () { - return this.transform.worldToLocalTransform; - }, - enumerable: true, - configurable: true - }); - Entity.prototype.onTransformChanged = function (comp) { - this.components.onEntityTransformChanged(comp); - }; - Entity.prototype.setTag = function (tag) { - if (this._tag != tag) { - if (this.scene) - this.scene.entities.removeFromTagList(this); - this._tag = tag; - if (this.scene) - this.scene.entities.addToTagList(this); - } - return this; - }; - Entity.prototype.setEnabled = function (isEnabled) { - if (this._enabled != isEnabled) { - this._enabled = isEnabled; - if (this._enabled) - this.components.onEntityEnabled(); - else - this.components.onEntityDisabled(); - } - return this; - }; - Entity.prototype.setUpdateOrder = function (updateOrder) { - if (this._updateOrder != updateOrder) { - this._updateOrder = updateOrder; - if (this.scene) { - this.scene.entities.markEntityListUnsorted(); - this.scene.entities.markTagUnsorted(this.tag); - } - return this; - } - }; - Entity.prototype.destroy = function () { - this._isDestroyed = true; - this.scene.entities.remove(this); - this.transform.parent = null; - for (var i = this.transform.childCount - 1; i >= 0; i--) { - var child = this.transform.getChild(i); - child.entity.destroy(); - } - }; - Entity.prototype.detachFromScene = function () { - this.scene.entities.remove(this); - this.components.deregisterAllComponents(); - for (var i = 0; i < this.transform.childCount; i++) - this.transform.getChild(i).entity.detachFromScene(); - }; - Entity.prototype.attachToScene = function (newScene) { - this.scene = newScene; - newScene.entities.add(this); - this.components.registerAllComponents(); - for (var i = 0; i < this.transform.childCount; i++) { - this.transform.getChild(i).entity.attachToScene(newScene); - } - }; - Entity.prototype.onAddedToScene = function () { - }; - Entity.prototype.onRemovedFromScene = function () { - if (this._isDestroyed) - this.components.removeAllComponents(); - }; - Entity.prototype.update = function () { - this.components.update(); - }; - Entity.prototype.debugRender = function (camera) { - this.components.debugRender(camera); - }; - Entity.prototype.addComponent = function (component) { - component.entity = this; - this.components.add(component); - component.initialize(); - return component; - }; - Entity.prototype.getComponent = function (type) { - return this.components.getComponent(type, false); - }; - Entity.prototype.hasComponent = function (type) { - return this.components.getComponent(type, false) != null; - }; - Entity.prototype.getOrCreateComponent = function (type) { - var comp = this.components.getComponent(type, true); - if (!comp) { - comp = this.addComponent(type); - } - return comp; - }; - Entity.prototype.getComponents = function (typeName, componentList) { - return this.components.getComponents(typeName, componentList); - }; - Entity.prototype.removeComponent = function (component) { - this.components.remove(component); - }; - Entity.prototype.removeComponentForType = function (type) { - var comp = this.getComponent(type); - if (comp) { - this.removeComponent(comp); - return true; - } - return false; - }; - Entity.prototype.removeAllComponents = function () { - for (var i = 0; i < this.components.count; i++) { - this.removeComponent(this.components.buffer[i]); - } - }; - Entity.prototype.compareTo = function (other) { - var compare = this._updateOrder - other._updateOrder; - if (compare == 0) - compare = this.id - other.id; - return compare; - }; - Entity.prototype.toString = function () { - return "[Entity: name: " + this.name + ", tag: " + this.tag + ", enabled: " + this.enabled + ", depth: " + this.updateOrder + "]"; - }; - Entity._idGenerator = 0; - return Entity; - }()); - es.Entity = Entity; -})(es || (es = {})); -var es; -(function (es) { - var Scene = (function (_super) { - __extends(Scene, _super); - function Scene() { - var _this = _super.call(this) || this; - _this.enablePostProcessing = true; - _this._sceneComponents = []; - _this._renderers = []; - _this._postProcessors = []; - _this.dynamicBatch = false; - _this.entities = new es.EntityList(_this); - _this.renderableComponents = new es.RenderableComponentList(); - _this.content = new es.ContentManager(); - _this.entityProcessors = new es.EntityProcessorList(); - _this.initialize(); - return _this; - } - Scene.createWithDefaultRenderer = function () { - var scene = new Scene(); - scene.addRenderer(new es.DefaultRenderer()); - return scene; - }; - Scene.prototype.initialize = function () { - }; - Scene.prototype.onStart = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2]; - }); - }); - }; - Scene.prototype.unload = function () { - }; - Scene.prototype.onActive = function () { - }; - Scene.prototype.onDeactive = function () { - }; - Scene.prototype.begin = function () { - if (this._renderers.length == 0) { - this.addRenderer(new es.DefaultRenderer()); - console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染"); - } - var cameraEntity = this.findEntity("camera"); - if (!cameraEntity) - cameraEntity = this.createEntity("camera"); - this.camera = cameraEntity.getOrCreateComponent(new es.Camera()); - es.Physics.reset(); - this.updateResolutionScaler(); - if (this.entityProcessors) - this.entityProcessors.begin(); - es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.updateResolutionScaler, this); - es.Core.emitter.addObserver(es.CoreEvents.OrientationChanged, this.updateResolutionScaler, this); - this.addEventListener(egret.Event.ACTIVATE, this.onActive, this); - this.addEventListener(egret.Event.DEACTIVATE, this.onDeactive, this); - this._didSceneBegin = true; - this.onStart(); - }; - Scene.prototype.end = function () { - this._didSceneBegin = false; - es.Core.emitter.removeObserver(es.CoreEvents.GraphicsDeviceReset, this.updateResolutionScaler); - es.Core.emitter.removeObserver(es.CoreEvents.OrientationChanged, this.updateResolutionScaler); - this.removeEventListener(egret.Event.DEACTIVATE, this.onDeactive, this); - this.removeEventListener(egret.Event.ACTIVATE, this.onActive, this); - for (var i = 0; i < this._renderers.length; i++) { - this._renderers[i].unload(); - } - for (var i = 0; i < this._postProcessors.length; i++) { - this._postProcessors[i].unload(); - } - this.entities.removeAllEntities(); - this.removeChildren(); - for (var i = 0; i < this._sceneComponents.length; i++) { - this._sceneComponents[i].onRemovedFromScene(); - } - this._sceneComponents.length = 0; - this.camera = null; - this.content.dispose(); - if (this.entityProcessors) - this.entityProcessors.end(); - if (this.parent) - this.parent.removeChild(this); - this.unload(); - }; - Scene.prototype.updateResolutionScaler = function () { - this.camera.onSceneRenderTargetSizeChanged(es.Core.Instance.stage.stageWidth, es.Core.Instance.stage.stageHeight); - }; - Scene.prototype.update = function () { - this.entities.updateLists(); - for (var i = this._sceneComponents.length - 1; i >= 0; i--) { - if (this._sceneComponents[i].enabled) - this._sceneComponents[i].update(); - } - if (this.entityProcessors) - this.entityProcessors.update(); - this.entities.update(); - if (this.entityProcessors) - this.entityProcessors.lateUpdate(); - this.renderableComponents.updateList(); - }; - Scene.prototype.render = function () { - if (this._renderers.length == 0) { - console.error("场景中没有渲染器!"); - return; - } - for (var i = 0; i < this._renderers.length; i++) { - this.camera.forceMatrixUpdate(); - this._renderers[i].render(this); - } - }; - Scene.prototype.dynamicInBatch = function () { - this.removeChildren(); - var batching = false; - var displayContainer; - for (var _i = 0, _a = this.renderableComponents.buffer; _i < _a.length; _i++) { - var component = _a[_i]; - if (component instanceof es.SpriteAnimator) { - this.addChild(component.displayObject); - this.addChild(component.debugDisplayObject); - batching = false; - displayContainer = null; - } - else if (component instanceof es.RenderableComponent) { - if (!batching) { - batching = true; - displayContainer = new egret.DisplayObjectContainer(); - displayContainer.cacheAsBitmap = true; - displayContainer.touchEnabled = false; - displayContainer.touchChildren = false; - this.addChild(displayContainer); - } - displayContainer.addChild(component.displayObject); - displayContainer.addChild(component.debugDisplayObject); - } - } - }; - Scene.prototype.postRender = function () { - if (this.enablePostProcessing) { - for (var i = 0; i < this._postProcessors.length; i++) { - if (this._postProcessors[i].enabled) { - this._postProcessors[i].process(); - } - } - } - if (this._screenshotRequestCallback) { - var tex = new egret.RenderTexture(); - tex.drawToTexture(this, new es.Rectangle(0, 0, this.stage.stageWidth, this.stage.stageHeight)); - this._screenshotRequestCallback(tex); - this._screenshotRequestCallback = null; - } - }; - Scene.prototype.requestScreenshot = function (callback) { - this._screenshotRequestCallback = callback; - }; - Scene.prototype.addSceneComponent = function (component) { - component.scene = this; - component.onEnabled(); - this._sceneComponents.push(component); - this._sceneComponents.sort(component.compareTo); - return component; - }; - Scene.prototype.getSceneComponent = function (type) { - for (var i = 0; i < this._sceneComponents.length; i++) { - var component = this._sceneComponents[i]; - if (component instanceof type) - return component; - } - return null; - }; - Scene.prototype.getOrCreateSceneComponent = function (type) { - var comp = this.getSceneComponent(type); - if (comp == null) - comp = this.addSceneComponent(new type()); - return comp; - }; - Scene.prototype.removeSceneComponent = function (component) { - if (!this._sceneComponents.contains(component)) { - console.warn("SceneComponent" + component + "\u4E0D\u5728SceneComponents\u5217\u8868\u4E2D!"); - return; - } - this._sceneComponents.remove(component); - component.onRemovedFromScene(); - }; - Scene.prototype.addRenderer = function (renderer) { - this._renderers.push(renderer); - this._renderers.sort(); - renderer.onAddedToScene(this); - return renderer; - }; - Scene.prototype.getRenderer = function (type) { - for (var i = 0; i < this._renderers.length; i++) { - if (this._renderers[i] instanceof type) - return this._renderers[i]; - } - return null; - }; - Scene.prototype.removeRenderer = function (renderer) { - if (!this._renderers.contains(renderer)) - return; - this._renderers.remove(renderer); - renderer.unload(); - }; - Scene.prototype.addPostProcessor = function (postProcessor) { - this._postProcessors.push(postProcessor); - this._postProcessors.sort(); - postProcessor.onAddedToScene(this); - if (this._didSceneBegin) { - postProcessor.onSceneBackBufferSizeChanged(this.stage.stageWidth, this.stage.stageHeight); - } - return postProcessor; - }; - Scene.prototype.getPostProcessor = function (type) { - for (var i = 0; i < this._postProcessors.length; i++) { - if (this._postProcessors[i] instanceof type) - return this._postProcessors[i]; - } - return null; - }; - Scene.prototype.removePostProcessor = function (postProcessor) { - if (!this._postProcessors.contains(postProcessor)) - return; - this._postProcessors.remove(postProcessor); - postProcessor.unload(); - }; - Scene.prototype.createEntity = function (name) { - var entity = new es.Entity(name); - return this.addEntity(entity); - }; - Scene.prototype.addEntity = function (entity) { - if (this.entities.buffer.contains(entity)) - console.warn("\u60A8\u8BD5\u56FE\u5C06\u540C\u4E00\u5B9E\u4F53\u6DFB\u52A0\u5230\u573A\u666F\u4E24\u6B21: " + entity); - this.entities.add(entity); - entity.scene = this; - for (var i = 0; i < entity.transform.childCount; i++) - this.addEntity(entity.transform.getChild(i).entity); - return entity; - }; - Scene.prototype.destroyAllEntities = function () { - for (var i = 0; i < this.entities.count; i++) { - this.entities.buffer[i].destroy(); - } - }; - Scene.prototype.findEntity = function (name) { - return this.entities.findEntity(name); - }; - Scene.prototype.findEntitiesWithTag = function (tag) { - return this.entities.entitiesWithTag(tag); - }; - Scene.prototype.entitiesOfType = function (type) { - return this.entities.entitiesOfType(type); - }; - Scene.prototype.findComponentOfType = function (type) { - return this.entities.findComponentOfType(type); - }; - Scene.prototype.findComponentsOfType = function (type) { - return this.entities.findComponentsOfType(type); - }; - Scene.prototype.addEntityProcessor = function (processor) { - processor.scene = this; - this.entityProcessors.add(processor); - return processor; - }; - Scene.prototype.removeEntityProcessor = function (processor) { - this.entityProcessors.remove(processor); - }; - Scene.prototype.getEntityProcessor = function () { - return this.entityProcessors.getProcessor(); - }; - return Scene; - }(egret.DisplayObjectContainer)); - es.Scene = Scene; -})(es || (es = {})); -var transform; -(function (transform) { - var Component; - (function (Component) { - Component[Component["position"] = 0] = "position"; - Component[Component["scale"] = 1] = "scale"; - Component[Component["rotation"] = 2] = "rotation"; - })(Component = transform.Component || (transform.Component = {})); -})(transform || (transform = {})); -var es; -(function (es) { - var HashObject = egret.HashObject; - var DirtyType; - (function (DirtyType) { - DirtyType[DirtyType["clean"] = 0] = "clean"; - DirtyType[DirtyType["positionDirty"] = 1] = "positionDirty"; - DirtyType[DirtyType["scaleDirty"] = 2] = "scaleDirty"; - DirtyType[DirtyType["rotationDirty"] = 3] = "rotationDirty"; - })(DirtyType = es.DirtyType || (es.DirtyType = {})); - var Transform = (function (_super) { - __extends(Transform, _super); - function Transform(entity) { - var _this = _super.call(this) || this; - _this._localTransform = es.Matrix2D.create(); - _this._worldTransform = es.Matrix2D.create().identity(); - _this._rotationMatrix = es.Matrix2D.create().identity(); - _this._translationMatrix = es.Matrix2D.create().identity(); - _this._scaleMatrix = es.Matrix2D.create().identity(); - _this._worldToLocalTransform = es.Matrix2D.create().identity(); - _this._worldInverseTransform = es.Matrix2D.create().identity(); - _this._position = es.Vector2.zero; - _this._scale = es.Vector2.one; - _this._rotation = 0; - _this._localPosition = es.Vector2.zero; - _this._localScale = es.Vector2.one; - _this._localRotation = 0; - _this.entity = entity; - _this.scale = _this._localScale = es.Vector2.one; - _this._children = []; - return _this; - } - Object.defineProperty(Transform.prototype, "childCount", { - get: function () { - return this._children.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "rotationDegrees", { - get: function () { - return es.MathHelper.toDegrees(this._rotation); - }, - set: function (value) { - this.setRotation(es.MathHelper.toRadians(value)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "localRotationDegrees", { - get: function () { - return es.MathHelper.toDegrees(this._localRotation); - }, - set: function (value) { - this.localRotation = es.MathHelper.toRadians(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "localToWorldTransform", { - get: function () { - this.updateTransform(); - return this._worldTransform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "parent", { - get: function () { - return this._parent; - }, - set: function (value) { - this.setParent(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "worldToLocalTransform", { - get: function () { - if (this._worldToLocalDirty) { - if (!this.parent) { - this._worldToLocalTransform = es.Matrix2D.create().identity(); - } - else { - this.parent.updateTransform(); - this._worldToLocalTransform = this.parent._worldTransform.invert(); - } - this._worldToLocalDirty = false; - } - return this._worldToLocalTransform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "worldInverseTransform", { - get: function () { - this.updateTransform(); - if (this._worldInverseDirty) { - this._worldInverseTransform = this._worldTransform.invert(); - this._worldInverseDirty = false; - } - return this._worldInverseTransform; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "position", { - get: function () { - this.updateTransform(); - if (this._positionDirty) { - if (!this.parent) { - this._position = this._localPosition; - } - else { - this.parent.updateTransform(); - es.Vector2Ext.transformR(this._localPosition, this.parent._worldTransform, this._position); - } - this._positionDirty = false; - } - return this._position; - }, - set: function (value) { - this.setPosition(value.x, value.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "scale", { - get: function () { - this.updateTransform(); - return this._scale; - }, - set: function (value) { - this.setScale(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "rotation", { - get: function () { - this.updateTransform(); - return this._rotation; - }, - set: function (value) { - this.setRotation(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "localPosition", { - get: function () { - this.updateTransform(); - return this._localPosition; - }, - set: function (value) { - this.setLocalPosition(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "localScale", { - get: function () { - this.updateTransform(); - return this._localScale; - }, - set: function (value) { - this.setLocalScale(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "localRotation", { - get: function () { - this.updateTransform(); - return this._localRotation; - }, - set: function (value) { - this.setLocalRotation(value); - }, - enumerable: true, - configurable: true - }); - Transform.prototype.getChild = function (index) { - return this._children[index]; - }; - Transform.prototype.setParent = function (parent) { - if (this._parent.equals(parent)) - return this; - if (!this._parent) { - this._parent._children.remove(this); - this._parent._children.push(this); - } - this._parent = parent; - this.setDirty(DirtyType.positionDirty); - return this; - }; - Transform.prototype.setPosition = function (x, y) { - var position = new es.Vector2(x, y); - if (position.equals(this._position)) - return this; - this._position = position; - if (this.parent) { - this.localPosition = es.Vector2.transform(this._position, this._worldToLocalTransform); - } - else { - this.localPosition = position; - } - this._positionDirty = false; - return this; - }; - Transform.prototype.setLocalPosition = function (localPosition) { - if (localPosition.equals(this._localPosition)) - return this; - this._localPosition = localPosition; - this._localDirty = this._positionDirty = this._localPositionDirty = this._localRotationDirty = this._localScaleDirty = true; - this.setDirty(DirtyType.positionDirty); - return this; - }; - Transform.prototype.setRotation = function (radians) { - this._rotation = radians; - if (this.parent) { - this.localRotation = this.parent.rotation + radians; - } - else { - this.localRotation = radians; - } - return this; - }; - Transform.prototype.setRotationDegrees = function (degrees) { - return this.setRotation(es.MathHelper.toRadians(degrees)); - }; - Transform.prototype.lookAt = function (pos) { - var sign = this.position.x > pos.x ? -1 : 1; - var vectorToAlignTo = es.Vector2.normalize(es.Vector2.subtract(this.position, pos)); - this.rotation = sign * Math.acos(es.Vector2.dot(vectorToAlignTo, es.Vector2.unitY)); - }; - Transform.prototype.setLocalRotation = function (radians) { - this._localRotation = radians; - this._localDirty = this._positionDirty = this._localPositionDirty = this._localRotationDirty = this._localScaleDirty = true; - this.setDirty(DirtyType.rotationDirty); - return this; - }; - Transform.prototype.setLocalRotationDegrees = function (degrees) { - return this.setLocalRotation(es.MathHelper.toRadians(degrees)); - }; - Transform.prototype.setScale = function (scale) { - this._scale = scale; - if (this.parent) { - this.localScale = es.Vector2.divide(scale, this.parent._scale); - } - else { - this.localScale = scale; - } - return this; - }; - Transform.prototype.setLocalScale = function (scale) { - this._localScale = scale; - this._localDirty = this._positionDirty = this._localScaleDirty = true; - this.setDirty(DirtyType.scaleDirty); - return this; - }; - Transform.prototype.roundPosition = function () { - this.position = this._position.round(); - }; - Transform.prototype.updateTransform = function () { - if (this.hierarchyDirty != DirtyType.clean) { - if (this.parent) - this.parent.updateTransform(); - if (this._localDirty) { - if (this._localPositionDirty) { - this._translationMatrix = es.Matrix2D.create().translate(this._localPosition.x, this._localPosition.y); - this._localPositionDirty = false; - } - if (this._localRotationDirty) { - this._rotationMatrix = es.Matrix2D.create().rotate(this._localRotation); - this._localRotationDirty = false; - } - if (this._localScaleDirty) { - this._scaleMatrix = es.Matrix2D.create().scale(this._localScale.x, this._localScale.y); - this._localScaleDirty = false; - } - this._localTransform = this._scaleMatrix.multiply(this._rotationMatrix); - this._localTransform = this._localTransform.multiply(this._translationMatrix); - if (!this.parent) { - this._worldTransform = this._localTransform; - this._rotation = this._localRotation; - this._scale = this._localScale; - this._worldInverseDirty = true; - } - this._localDirty = false; - } - if (this.parent) { - this._worldTransform = this._localTransform.multiply(this.parent._worldTransform); - this._rotation = this._localRotation + this.parent._rotation; - this._scale = es.Vector2.multiply(this.parent._scale, this._localScale); - this._worldInverseDirty = true; - } - this._worldToLocalDirty = true; - this._positionDirty = true; - this.hierarchyDirty = DirtyType.clean; - } - }; - Transform.prototype.setDirty = function (dirtyFlagType) { - if ((this.hierarchyDirty & dirtyFlagType) == 0) { - this.hierarchyDirty |= dirtyFlagType; - switch (dirtyFlagType) { - case es.DirtyType.positionDirty: - this.entity.onTransformChanged(transform.Component.position); - break; - case es.DirtyType.rotationDirty: - this.entity.onTransformChanged(transform.Component.rotation); - break; - case es.DirtyType.scaleDirty: - this.entity.onTransformChanged(transform.Component.scale); - break; - } - if (!this._children) - this._children = []; - for (var i = 0; i < this._children.length; i++) - this._children[i].setDirty(dirtyFlagType); - } - }; - Transform.prototype.copyFrom = function (transform) { - this._position = transform.position; - this._localPosition = transform._localPosition; - this._rotation = transform._rotation; - this._localRotation = transform._localRotation; - this._scale = transform._scale; - this._localScale = transform._localScale; - this.setDirty(DirtyType.positionDirty); - this.setDirty(DirtyType.rotationDirty); - this.setDirty(DirtyType.scaleDirty); - }; - Transform.prototype.toString = function () { - return "[Transform: parent: " + this.parent + ", position: " + this.position + ", rotation: " + this.rotation + ",\n scale: " + this.scale + ", localPosition: " + this._localPosition + ", localRotation: " + this._localRotation + ",\n localScale: " + this._localScale + "]"; - }; - Transform.prototype.equals = function (other) { - return other.hashCode == this.hashCode; - }; - return Transform; - }(HashObject)); - es.Transform = Transform; -})(es || (es = {})); -var es; -(function (es) { - var Camera = (function (_super) { - __extends(Camera, _super); - function Camera() { - var _this = _super.call(this) || this; - _this._inset = { left: 0, right: 0, top: 0, bottom: 0 }; - _this._areMatrixedDirty = true; - _this._areBoundsDirty = true; - _this._isProjectionMatrixDirty = true; - _this._zoom = 0; - _this._minimumZoom = 0.3; - _this._maximumZoom = 3; - _this._bounds = new es.Rectangle(); - _this._transformMatrix = new es.Matrix2D().identity(); - _this._inverseTransformMatrix = new es.Matrix2D().identity(); - _this._origin = es.Vector2.zero; - _this.setZoom(0); - return _this; - } - Object.defineProperty(Camera.prototype, "position", { - get: function () { - return this.entity.transform.position; - }, - set: function (value) { - this.entity.transform.position = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "rotation", { - get: function () { - return this.entity.transform.rotation; - }, - set: function (value) { - this.entity.transform.rotation = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "rawZoom", { - get: function () { - return this._zoom; - }, - set: function (value) { - if (value != this._zoom) { - this._zoom = value; - this._areMatrixedDirty = true; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "zoom", { - get: function () { - if (this._zoom == 0) - return 1; - if (this._zoom < 1) - return es.MathHelper.map(this._zoom, this._minimumZoom, 1, -1, 0); - return es.MathHelper.map(this._zoom, 1, this._maximumZoom, 0, 1); - }, - set: function (value) { - this.setZoom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "minimumZoom", { - get: function () { - return this._minimumZoom; - }, - set: function (value) { - this.setMinimumZoom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "maximumZoom", { - get: function () { - return this._maximumZoom; - }, - set: function (value) { - this.setMaximumZoom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "bounds", { - get: function () { - if (this._areMatrixedDirty) - this.updateMatrixes(); - if (this._areBoundsDirty) { - var topLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, this._inset.top)); - var bottomRight = this.screenToWorldPoint(new es.Vector2(es.Core.graphicsDevice.viewport.width - this._inset.right, es.Core.graphicsDevice.viewport.height - this._inset.bottom)); - if (this.entity.transform.rotation != 0) { - var topRight = this.screenToWorldPoint(new es.Vector2(es.Core.graphicsDevice.viewport.width - this._inset.right, this._inset.top)); - var bottomLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, es.Core.graphicsDevice.viewport.height - this._inset.bottom)); - var minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - var maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - var minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - var maxY = Math.max(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - this._bounds.location = new es.Vector2(minX, minY); - this._bounds.width = maxX - minX; - this._bounds.height = maxY - minY; - } - else { - this._bounds.location = topLeft; - this._bounds.width = bottomRight.x - topLeft.x; - this._bounds.height = bottomRight.y - topLeft.y; - } - this._areBoundsDirty = false; - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "transformMatrix", { - get: function () { - if (this._areMatrixedDirty) - this.updateMatrixes(); - return this._transformMatrix; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "inverseTransformMatrix", { - get: function () { - if (this._areMatrixedDirty) - this.updateMatrixes(); - return this._inverseTransformMatrix; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "origin", { - get: function () { - return this._origin; - }, - set: function (value) { - if (this._origin != value) { - this._origin = value; - this._areMatrixedDirty = true; - } - }, - enumerable: true, - configurable: true - }); - Camera.prototype.setInset = function (left, right, top, bottom) { - this._inset = { left: left, right: right, top: top, bottom: bottom }; - this._areBoundsDirty = true; - return this; - }; - Camera.prototype.setPosition = function (position) { - this.entity.transform.setPosition(position.x, position.y); - return this; - }; - Camera.prototype.setRotation = function (rotation) { - this.entity.transform.setRotation(rotation); - return this; - }; - Camera.prototype.setZoom = function (zoom) { - var newZoom = es.MathHelper.clamp(zoom, -1, 1); - if (newZoom == 0) { - this._zoom = 1; - } - else if (newZoom < 0) { - this._zoom = es.MathHelper.map(newZoom, -1, 0, this._minimumZoom, 1); - } - else { - this._zoom = es.MathHelper.map(newZoom, 0, 1, 1, this._maximumZoom); - } - this._areMatrixedDirty = true; - return this; - }; - Camera.prototype.setMinimumZoom = function (minZoom) { - if (minZoom <= 0) { - console.error("minimumZoom must be greater than zero"); - return; - } - if (this._zoom < minZoom) - this._zoom = this.minimumZoom; - this._minimumZoom = minZoom; - return this; - }; - Camera.prototype.setMaximumZoom = function (maxZoom) { - if (maxZoom <= 0) { - console.error("maximumZoom must be greater than zero"); - return; - } - if (this._zoom > maxZoom) - this._zoom = maxZoom; - this._maximumZoom = maxZoom; - return this; - }; - Camera.prototype.forceMatrixUpdate = function () { - this._areMatrixedDirty = true; - }; - Camera.prototype.onEntityTransformChanged = function (comp) { - this._areMatrixedDirty = true; - }; - Camera.prototype.zoomIn = function (deltaZoom) { - this.zoom += deltaZoom; - }; - Camera.prototype.zoomOut = function (deltaZoom) { - this.zoom -= deltaZoom; - }; - Camera.prototype.worldToScreenPoint = function (worldPosition) { - this.updateMatrixes(); - es.Vector2Ext.transformR(worldPosition, this._transformMatrix, worldPosition); - return worldPosition; - }; - Camera.prototype.screenToWorldPoint = function (screenPosition) { - this.updateMatrixes(); - es.Vector2Ext.transformR(screenPosition, this._inverseTransformMatrix, screenPosition); - return screenPosition; - }; - Camera.prototype.onSceneRenderTargetSizeChanged = function (newWidth, newHeight) { - this._isProjectionMatrixDirty = true; - var oldOrigin = this._origin; - this.origin = new es.Vector2(newWidth / 2, newHeight / 2); - this.entity.transform.position.add(es.Vector2.subtract(this._origin, oldOrigin)); - }; - Camera.prototype.mouseToWorldPoint = function () { - return this.screenToWorldPoint(es.Input.touchPosition); - }; - Camera.prototype.updateMatrixes = function () { - if (!this._areMatrixedDirty) - return; - var tempMat; - this._transformMatrix = es.Matrix2D.create().translate(-this.entity.transform.position.x, -this.entity.transform.position.y); - if (this._zoom != 1) { - tempMat = es.Matrix2D.create().scale(this._zoom, this._zoom); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - } - if (this.entity.transform.rotation != 0) { - tempMat = es.Matrix2D.create().rotate(this.entity.transform.rotation); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - } - tempMat = es.Matrix2D.create().translate(Math.floor(this._origin.x), Math.floor(this._origin.y)); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - this._inverseTransformMatrix = this._transformMatrix.invert(); - this._areBoundsDirty = true; - this._areMatrixedDirty = false; - }; - return Camera; - }(es.Component)); - es.Camera = Camera; -})(es || (es = {})); -var es; -(function (es) { - var CameraShake = (function (_super) { - __extends(CameraShake, _super); - function CameraShake() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._shakeDirection = es.Vector2.zero; - _this._shakeOffset = es.Vector2.zero; - _this._shakeIntensity = 0; - _this._shakeDegredation = 0.95; - return _this; - } - CameraShake.prototype.shake = function (shakeIntensify, shakeDegredation, shakeDirection) { - if (shakeIntensify === void 0) { shakeIntensify = 15; } - if (shakeDegredation === void 0) { shakeDegredation = 0.9; } - if (shakeDirection === void 0) { shakeDirection = es.Vector2.zero; } - this.enabled = true; - if (this._shakeIntensity < shakeIntensify) { - this._shakeDirection = shakeDirection; - this._shakeIntensity = shakeIntensify; - if (shakeDegredation < 0 || shakeDegredation >= 1) { - shakeDegredation = 0.95; - } - this._shakeDegredation = shakeDegredation; - } - }; - CameraShake.prototype.update = function () { - if (Math.abs(this._shakeIntensity) > 0) { - this._shakeOffset = this._shakeDirection; - if (this._shakeOffset.x != 0 || this._shakeOffset.y != 0) { - this._shakeOffset.normalize(); - } - else { - this._shakeOffset.x = this._shakeOffset.x + Math.random() - 0.5; - this._shakeOffset.y = this._shakeOffset.y + Math.random() - 0.5; - } - this._shakeOffset.multiply(new es.Vector2(this._shakeIntensity)); - this._shakeIntensity *= -this._shakeDegredation; - if (Math.abs(this._shakeIntensity) <= 0.01) { - this._shakeIntensity = 0; - this.enabled = false; - } - } - this.entity.scene.camera.position.add(this._shakeOffset); - }; - return CameraShake; - }(es.Component)); - es.CameraShake = CameraShake; -})(es || (es = {})); -var es; -(function (es) { - var ComponentPool = (function () { - function ComponentPool(typeClass) { - this._type = typeClass; - this._cache = []; - } - ComponentPool.prototype.obtain = function () { - try { - return this._cache.length > 0 ? this._cache.shift() : new this._type(); - } - catch (err) { - throw new Error(this._type + err); - } - }; - ComponentPool.prototype.free = function (component) { - component.reset(); - this._cache.push(component); - }; - return ComponentPool; - }()); - es.ComponentPool = ComponentPool; -})(es || (es = {})); -var es; -(function (es) { - var CameraStyle; - (function (CameraStyle) { - CameraStyle[CameraStyle["lockOn"] = 0] = "lockOn"; - CameraStyle[CameraStyle["cameraWindow"] = 1] = "cameraWindow"; - })(CameraStyle = es.CameraStyle || (es.CameraStyle = {})); - var FollowCamera = (function (_super) { - __extends(FollowCamera, _super); - function FollowCamera(targetEntity, camera, cameraStyle) { - if (targetEntity === void 0) { targetEntity = null; } - if (camera === void 0) { camera = null; } - if (cameraStyle === void 0) { cameraStyle = CameraStyle.lockOn; } - var _this = _super.call(this) || this; - _this.followLerp = 0.1; - _this.deadzone = new es.Rectangle(); - _this.focusOffset = es.Vector2.zero; - _this.mapLockEnabled = false; - _this.mapSize = new es.Rectangle(); - _this._desiredPositionDelta = new es.Vector2(); - _this._worldSpaceDeadZone = new es.Rectangle(); - _this.rectShape = new egret.Shape(); - _this._targetEntity = targetEntity; - _this._cameraStyle = cameraStyle; - _this.camera = camera; - return _this; - } - FollowCamera.prototype.onAddedToEntity = function () { - if (!this.camera) - this.camera = this.entity.scene.camera; - this.follow(this._targetEntity, this._cameraStyle); - es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); - }; - FollowCamera.prototype.onGraphicsDeviceReset = function () { - es.Core.schedule(0, false, this, function (t) { - var self = t.context; - self.follow(self._targetEntity, self._cameraStyle); - }); - }; - FollowCamera.prototype.update = function () { - var halfScreen = es.Vector2.multiply(this.camera.bounds.size, new es.Vector2(0.5)); - this._worldSpaceDeadZone.x = this.camera.position.x - halfScreen.x * es.Core.scene.scaleX + this.deadzone.x + this.focusOffset.x; - this._worldSpaceDeadZone.y = this.camera.position.y - halfScreen.y * es.Core.scene.scaleY + this.deadzone.y + this.focusOffset.y; - this._worldSpaceDeadZone.width = this.deadzone.width; - this._worldSpaceDeadZone.height = this.deadzone.height; - if (this._targetEntity) - this.updateFollow(); - this.camera.position = es.Vector2.lerp(this.camera.position, es.Vector2.add(this.camera.position, this._desiredPositionDelta), this.followLerp); - this.entity.transform.roundPosition(); - if (this.mapLockEnabled) { - this.camera.position = this.clampToMapSize(this.camera.position); - this.entity.transform.roundPosition(); - } - }; - FollowCamera.prototype.debugRender = function (camera) { - if (!this.rectShape) - this.debugDisplayObject.addChild(this.rectShape); - this.rectShape.graphics.clear(); - if (this._cameraStyle == CameraStyle.lockOn) { - this.rectShape.graphics.beginFill(0x8B0000, 0); - this.rectShape.graphics.lineStyle(1, 0x8B0000); - this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x - 5 - camera.bounds.x, this._worldSpaceDeadZone.y - 5 - camera.bounds.y, this._worldSpaceDeadZone.width, this._worldSpaceDeadZone.height); - this.rectShape.graphics.endFill(); - } - else { - this.rectShape.graphics.beginFill(0x8B0000, 0); - this.rectShape.graphics.lineStyle(1, 0x8B0000); - this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x - camera.bounds.x, this._worldSpaceDeadZone.y - camera.bounds.y, this._worldSpaceDeadZone.width, this._worldSpaceDeadZone.height); - this.rectShape.graphics.endFill(); - } - }; - FollowCamera.prototype.clampToMapSize = function (position) { - var halfScreen = es.Vector2.multiply(this.camera.bounds.size, new es.Vector2(0.5)).add(new es.Vector2(this.mapSize.x, this.mapSize.y)); - var cameraMax = new es.Vector2(this.mapSize.width - halfScreen.x, this.mapSize.height - halfScreen.y); - return es.Vector2.clamp(position, halfScreen, cameraMax); - }; - FollowCamera.prototype.follow = function (targetEntity, cameraStyle) { - if (cameraStyle === void 0) { cameraStyle = CameraStyle.cameraWindow; } - this._targetEntity = targetEntity; - this._cameraStyle = cameraStyle; - var cameraBounds = this.camera.bounds; - switch (this._cameraStyle) { - case CameraStyle.cameraWindow: - var w = cameraBounds.width / 6; - var h = cameraBounds.height / 3; - this.deadzone = new es.Rectangle((cameraBounds.width - w) / 2, (cameraBounds.height - h) / 2, w, h); - break; - case CameraStyle.lockOn: - this.deadzone = new es.Rectangle(cameraBounds.width / 2, cameraBounds.height / 2, 10, 10); - break; - } - }; - FollowCamera.prototype.updateFollow = function () { - this._desiredPositionDelta.x = this._desiredPositionDelta.y = 0; - if (this._cameraStyle == CameraStyle.lockOn) { - var targetX = this._targetEntity.transform.position.x; - var targetY = this._targetEntity.transform.position.y; - if (this._worldSpaceDeadZone.x > targetX) - this._desiredPositionDelta.x = targetX - this._worldSpaceDeadZone.x; - else if (this._worldSpaceDeadZone.x < targetX) - this._desiredPositionDelta.x = targetX - this._worldSpaceDeadZone.x; - if (this._worldSpaceDeadZone.y < targetY) - this._desiredPositionDelta.y = targetY - this._worldSpaceDeadZone.y; - else if (this._worldSpaceDeadZone.y > targetY) - this._desiredPositionDelta.y = targetY - this._worldSpaceDeadZone.y; - } - else { - if (!this._targetCollider) { - this._targetCollider = this._targetEntity.getComponent(es.Collider); - if (!this._targetCollider) - return; - } - var targetBounds = this._targetEntity.getComponent(es.Collider).bounds; - if (!this._worldSpaceDeadZone.containsRect(targetBounds)) { - if (this._worldSpaceDeadZone.left > targetBounds.left) - this._desiredPositionDelta.x = targetBounds.left - this._worldSpaceDeadZone.left; - else if (this._worldSpaceDeadZone.right < targetBounds.right) - this._desiredPositionDelta.x = targetBounds.right - this._worldSpaceDeadZone.right; - if (this._worldSpaceDeadZone.bottom < targetBounds.bottom) - this._desiredPositionDelta.y = targetBounds.bottom - this._worldSpaceDeadZone.bottom; - else if (this._worldSpaceDeadZone.top > targetBounds.top) - this._desiredPositionDelta.y = targetBounds.top - this._worldSpaceDeadZone.top; - } - } - }; - FollowCamera.prototype.setCenteredDeadzone = function (width, height) { - if (!this.camera) { - console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后"); - return; - } - var cameraBounds = this.camera.bounds; - this.deadzone = new es.Rectangle((cameraBounds.width - width) / 2, (cameraBounds.height - height) / 2, width, height); - }; - return FollowCamera; - }(es.Component)); - es.FollowCamera = FollowCamera; -})(es || (es = {})); -var es; -(function (es) { - var IUpdatableComparer = (function () { - function IUpdatableComparer() { - } - IUpdatableComparer.prototype.compare = function (a, b) { - return a.updateOrder - b.updateOrder; - }; - return IUpdatableComparer; - }()); - es.IUpdatableComparer = IUpdatableComparer; -})(es || (es = {})); -var es; -(function (es) { - var PooledComponent = (function (_super) { - __extends(PooledComponent, _super); - function PooledComponent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return PooledComponent; - }(es.Component)); - es.PooledComponent = PooledComponent; -})(es || (es = {})); -var es; -(function (es) { - var SceneComponent = (function () { - function SceneComponent() { - this.updateOrder = 0; - this._enabled = true; - } - Object.defineProperty(SceneComponent.prototype, "enabled", { - get: function () { - return this._enabled; - }, - set: function (value) { - this.setEnabled(value); - }, - enumerable: true, - configurable: true - }); - SceneComponent.prototype.onEnabled = function () { - }; - SceneComponent.prototype.onDisabled = function () { - }; - SceneComponent.prototype.onRemovedFromScene = function () { - }; - SceneComponent.prototype.update = function () { - }; - SceneComponent.prototype.setEnabled = function (isEnabled) { - if (this._enabled != isEnabled) { - this._enabled = isEnabled; - if (this._enabled) { - } - else { - } - } - return this; - }; - SceneComponent.prototype.setUpdateOrder = function (updateOrder) { - if (this.updateOrder != updateOrder) { - this.updateOrder = updateOrder; - es.Core.scene._sceneComponents.sort(this.compareTo); - } - return this; - }; - SceneComponent.prototype.compareTo = function (other) { - return this.updateOrder - other.updateOrder; - }; - return SceneComponent; - }()); - es.SceneComponent = SceneComponent; -})(es || (es = {})); -var es; -(function (es) { - var Mover = (function (_super) { - __extends(Mover, _super); - function Mover() { - return _super !== null && _super.apply(this, arguments) || this; - } - Mover.prototype.onAddedToEntity = function () { - this._triggerHelper = new es.ColliderTriggerHelper(this.entity); - }; - Mover.prototype.calculateMovement = function (motion, collisionResult) { - if (!this.entity.getComponent(es.Collider) || !this._triggerHelper) { - return false; - } - var colliders = this.entity.getComponents(es.Collider); - for (var i = 0; i < colliders.length; i++) { - var collider = colliders[i]; - if (collider.isTrigger) - continue; - var bounds = collider.bounds; - bounds.x += motion.x; - bounds.y += motion.y; - var neighbors = es.Physics.boxcastBroadphaseExcludingSelf(collider, bounds, collider.collidesWithLayers.value); - for (var j = 0; j < neighbors.length; j++) { - var neighbor = neighbors[j]; - if (neighbor.isTrigger) - continue; - var _internalcollisionResult = new es.CollisionResult(); - if (collider.collidesWith(neighbor, motion, _internalcollisionResult)) { - motion = motion.subtract(_internalcollisionResult.minimumTranslationVector); - if (_internalcollisionResult.collider != null) { - collisionResult = _internalcollisionResult; - } - } - } - } - es.ListPool.free(colliders); - return collisionResult.collider != null; - }; - Mover.prototype.applyMovement = function (motion) { - this.entity.position = es.Vector2.add(this.entity.position, motion); - if (this._triggerHelper) - this._triggerHelper.update(); - }; - Mover.prototype.move = function (motion, collisionResult) { - this.calculateMovement(motion, collisionResult); - this.applyMovement(motion); - return collisionResult.collider != null; - }; - return Mover; - }(es.Component)); - es.Mover = Mover; -})(es || (es = {})); -var es; -(function (es) { - var ProjectileMover = (function (_super) { - __extends(ProjectileMover, _super); - function ProjectileMover() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._tempTriggerList = []; - return _this; - } - ProjectileMover.prototype.onAddedToEntity = function () { - this._collider = this.entity.getComponent(es.Collider); - if (!this._collider) - console.warn("ProjectileMover has no Collider. ProjectilMover requires a Collider!"); - }; - ProjectileMover.prototype.move = function (motion) { - if (!this._collider) - return false; - var didCollide = false; - this.entity.position.add(motion); - var neighbors = es.Physics.boxcastBroadphase(this._collider.bounds, this._collider.collidesWithLayers.value); - for (var _i = 0, neighbors_1 = neighbors; _i < neighbors_1.length; _i++) { - var neighbor = neighbors_1[_i]; - if (this._collider.overlaps(neighbor) && neighbor.enabled) { - didCollide = true; - this.notifyTriggerListeners(this._collider, neighbor); - } - } - return didCollide; - }; - ProjectileMover.prototype.notifyTriggerListeners = function (self, other) { - other.entity.getComponents("ITriggerListener", this._tempTriggerList); - for (var i = 0; i < this._tempTriggerList.length; i++) { - this._tempTriggerList[i].onTriggerEnter(self, other); - } - this._tempTriggerList.length = 0; - this.entity.getComponents("ITriggerListener", this._tempTriggerList); - for (var i = 0; i < this._tempTriggerList.length; i++) { - this._tempTriggerList[i].onTriggerEnter(other, self); - } - this._tempTriggerList.length = 0; - }; - return ProjectileMover; - }(es.Component)); - es.ProjectileMover = ProjectileMover; -})(es || (es = {})); -var es; -(function (es) { - var Collider = (function (_super) { - __extends(Collider, _super); - function Collider() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.physicsLayer = new es.Ref(1 << 0); - _this.collidesWithLayers = new es.Ref(es.Physics.allLayers); - _this.shouldColliderScaleAndRotateWithTransform = true; - _this.registeredPhysicsBounds = new es.Rectangle(); - _this._isPositionDirty = true; - _this._isRotationDirty = true; - _this._localOffset = es.Vector2.zero; - return _this; - } - Object.defineProperty(Collider.prototype, "absolutePosition", { - get: function () { - return es.Vector2.add(this.entity.transform.position, this._localOffset); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Collider.prototype, "rotation", { - get: function () { - if (this.shouldColliderScaleAndRotateWithTransform && this.entity) - return this.entity.transform.rotation; - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Collider.prototype, "bounds", { - get: function () { - if (this._isPositionDirty || this._isRotationDirty) { - this.shape.recalculateBounds(this); - this._isPositionDirty = this._isRotationDirty = false; - } - return this.shape.bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Collider.prototype, "localOffset", { - get: function () { - return this._localOffset; - }, - set: function (value) { - this.setLocalOffset(value); - }, - enumerable: true, - configurable: true - }); - Collider.prototype.setLocalOffset = function (offset) { - if (this._localOffset != offset) { - this.unregisterColliderWithPhysicsSystem(); - this._localOffset = offset; - this._localOffsetLength = this._localOffset.length(); - this._isPositionDirty = true; - this.registerColliderWithPhysicsSystem(); - } - return this; - }; - Collider.prototype.setShouldColliderScaleAndRotateWithTransform = function (shouldColliderScaleAndRotationWithTransform) { - this.shouldColliderScaleAndRotateWithTransform = shouldColliderScaleAndRotationWithTransform; - this._isPositionDirty = this._isRotationDirty = true; - return this; - }; - Collider.prototype.onAddedToEntity = function () { - if (this._colliderRequiresAutoSizing) { - if (!(this instanceof es.BoxCollider || this instanceof es.CircleCollider)) { - console.error("Only box and circle colliders can be created automatically"); - return; - } - var renderable = this.entity.getComponent(es.RenderableComponent); - if (renderable) { - var renderableBounds = renderable.bounds; - var width = renderableBounds.width / this.entity.transform.scale.x; - var height = renderableBounds.height / this.entity.transform.scale.y; - if (this instanceof es.CircleCollider) { - this.radius = Math.max(width, height) * 0.5; - } - else { - this.width = width; - this.height = height; - } - this.localOffset = es.Vector2.subtract(renderableBounds.center, this.entity.transform.position); - } - else { - console.warn("碰撞器没有形状和RenderableComponent。不知道如何调整大小."); - } - } - this._isParentEntityAddedToScene = true; - this.registerColliderWithPhysicsSystem(); - }; - Collider.prototype.onRemovedFromEntity = function () { - this.unregisterColliderWithPhysicsSystem(); - this._isParentEntityAddedToScene = false; - }; - Collider.prototype.onEntityTransformChanged = function (comp) { - switch (comp) { - case transform.Component.position: - this._isPositionDirty = true; - break; - case transform.Component.scale: - this._isPositionDirty = true; - break; - case transform.Component.rotation: - this._isRotationDirty = true; - break; - } - if (this._isColliderRegistered) - es.Physics.updateCollider(this); - }; - Collider.prototype.onEnabled = function () { - this.registerColliderWithPhysicsSystem(); - this._isPositionDirty = this._isRotationDirty = true; - }; - Collider.prototype.onDisabled = function () { - this.unregisterColliderWithPhysicsSystem(); - }; - Collider.prototype.registerColliderWithPhysicsSystem = function () { - if (this._isParentEntityAddedToScene && !this._isColliderRegistered) { - es.Physics.addCollider(this); - this._isColliderRegistered = true; - } - }; - Collider.prototype.unregisterColliderWithPhysicsSystem = function () { - if (this._isParentEntityAddedToScene && this._isColliderRegistered) { - es.Physics.removeCollider(this); - } - this._isColliderRegistered = false; - }; - Collider.prototype.overlaps = function (other) { - return this.shape.overlaps(other.shape); - }; - Collider.prototype.collidesWith = function (collider, motion, result) { - var oldPosition = this.entity.position; - this.entity.position.add(motion); - var didCollide = this.shape.collidesWithShape(collider.shape, result); - if (didCollide) - result.collider = collider; - this.entity.position = oldPosition; - return didCollide; - }; - return Collider; - }(es.Component)); - es.Collider = Collider; -})(es || (es = {})); -var es; -(function (es) { - var BoxCollider = (function (_super) { - __extends(BoxCollider, _super); - function BoxCollider(x, y, width, height) { - var _this = _super.call(this) || this; - _this.hollowShape = new egret.Shape(); - _this.polygonShape = new egret.Shape(); - _this.pixelShape1 = new egret.Shape(); - _this.pixelShape2 = new egret.Shape(); - if (x == undefined && y == undefined) { - if (width == undefined && height == undefined) { - _this.shape = new es.Box(1, 1); - _this._colliderRequiresAutoSizing = true; - } - else if (width != undefined && height != undefined) { - x = -width / 2; - y = -height / 2; - _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); - _this.shape = new es.Box(width, height); - } - } - else if (x != undefined && y != undefined && width != undefined && height != undefined) { - _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); - _this.shape = new es.Box(width, height); - } - return _this; - } - Object.defineProperty(BoxCollider.prototype, "width", { - get: function () { - return this.shape.width; - }, - set: function (value) { - this.setWidth(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BoxCollider.prototype, "height", { - get: function () { - return this.shape.height; - }, - set: function (value) { - this.setHeight(value); - }, - enumerable: true, - configurable: true - }); - BoxCollider.prototype.setSize = function (width, height) { - this._colliderRequiresAutoSizing = false; - var box = this.shape; - if (width != box.width || height != box.height) { - box.updateBox(width, height); - if (this.entity && this._isParentEntityAddedToScene) - es.Physics.updateCollider(this); - } - return this; - }; - BoxCollider.prototype.setWidth = function (width) { - this._colliderRequiresAutoSizing = false; - var box = this.shape; - if (width != box.width) { - box.updateBox(width, box.height); - if (this.entity && this._isParentEntityAddedToScene) - es.Physics.updateCollider(this); - } - return this; - }; - BoxCollider.prototype.setHeight = function (height) { - this._colliderRequiresAutoSizing = false; - var box = this.shape; - if (height != box.height) { - box.updateBox(box.width, height); - if (this.entity && this._isParentEntityAddedToScene) - es.Physics.updateCollider(this); - } - }; - BoxCollider.prototype.debugRender = function (camera) { - var poly = this.shape; - if (!this.hollowShape.parent) - this.debugDisplayObject.addChild(this.hollowShape); - if (!this.polygonShape.parent) - this.debugDisplayObject.addChild(this.polygonShape); - if (!this.pixelShape1.parent) - this.debugDisplayObject.addChild(this.pixelShape1); - if (!this.pixelShape2.parent) - this.debugDisplayObject.addChild(this.pixelShape2); - this.hollowShape.graphics.clear(); - this.hollowShape.graphics.beginFill(es.Colors.colliderBounds, 0); - this.hollowShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderBounds); - this.hollowShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.hollowShape.graphics.endFill(); - this.polygonShape.graphics.clear(); - if (poly.points.length >= 2) { - this.polygonShape.graphics.beginFill(es.Colors.colliderEdge, 0); - this.polygonShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderEdge); - for (var i = 0; i < poly.points.length; i++) { - if (i == 0) { - this.polygonShape.graphics.moveTo(poly.position.x + poly.points[i].x - camera.bounds.x, poly.position.y + poly.points[i].y - camera.bounds.y); - } - else { - this.polygonShape.graphics.lineTo(poly.position.x + poly.points[i].x - camera.bounds.x, poly.position.y + poly.points[i].y - camera.bounds.y); - } - } - this.polygonShape.graphics.lineTo(poly.position.x + poly.points[poly.points.length - 1].x - camera.bounds.x, poly.position.y + poly.points[0].y - camera.bounds.y); - this.polygonShape.graphics.endFill(); - } - this.pixelShape1.graphics.clear(); - this.pixelShape1.graphics.beginFill(es.Colors.colliderPosition, 0); - this.pixelShape1.graphics.lineStyle(4 * es.Size.lineSizeMultiplier, es.Colors.colliderPosition); - this.pixelShape1.graphics.moveTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.lineTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.endFill(); - this.pixelShape2.graphics.clear(); - this.pixelShape2.graphics.beginFill(es.Colors.colliderCenter, 0); - this.pixelShape2.graphics.lineStyle(2 * es.Size.lineSizeMultiplier, es.Colors.colliderCenter); - this.pixelShape2.graphics.moveTo(this.entity.transform.position.x + this.shape.center.x - camera.bounds.x, this.entity.transform.position.y + this.shape.center.y - camera.bounds.y); - this.pixelShape2.graphics.lineTo(this.entity.transform.position.x + this.shape.center.x - camera.bounds.x, this.entity.transform.position.y + this.shape.center.y - camera.bounds.y); - this.pixelShape2.graphics.endFill(); - }; - BoxCollider.prototype.toString = function () { - return "[BoxCollider: bounds: " + this.bounds + "]"; - }; - return BoxCollider; - }(es.Collider)); - es.BoxCollider = BoxCollider; -})(es || (es = {})); -var es; -(function (es) { - var CircleCollider = (function (_super) { - __extends(CircleCollider, _super); - function CircleCollider(radius) { - var _this = _super.call(this) || this; - _this.rectShape = new egret.Shape(); - _this.circleShape = new egret.Shape(); - _this.pixelShape1 = new egret.Shape(); - _this.pixelShape2 = new egret.Shape(); - if (radius == undefined) { - _this.shape = new es.Circle(1); - _this._colliderRequiresAutoSizing = true; - } - else { - _this.shape = new es.Circle(radius); - } - return _this; - } - Object.defineProperty(CircleCollider.prototype, "radius", { - get: function () { - return this.shape.radius; - }, - set: function (value) { - this.setRadius(value); - }, - enumerable: true, - configurable: true - }); - CircleCollider.prototype.setRadius = function (radius) { - this._colliderRequiresAutoSizing = false; - var circle = this.shape; - if (radius != circle.radius) { - circle.radius = radius; - circle._originalRadius = radius; - if (this.entity && this._isParentEntityAddedToScene) - es.Physics.updateCollider(this); - } - return this; - }; - CircleCollider.prototype.debugRender = function (camera) { - if (!this.rectShape.parent) - this.debugDisplayObject.addChild(this.rectShape); - if (!this.circleShape.parent) - this.debugDisplayObject.addChild(this.circleShape); - if (!this.pixelShape1.parent) - this.debugDisplayObject.addChild(this.pixelShape1); - if (!this.pixelShape2.parent) - this.debugDisplayObject.addChild(this.pixelShape2); - this.rectShape.graphics.clear(); - this.rectShape.graphics.beginFill(es.Colors.colliderBounds, 0); - this.rectShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderBounds); - this.rectShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.rectShape.graphics.endFill(); - this.circleShape.graphics.clear(); - this.circleShape.graphics.beginFill(es.Colors.colliderEdge, 0); - this.circleShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderEdge); - this.circleShape.graphics.drawCircle(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y, this.shape.radius); - this.circleShape.graphics.endFill(); - this.pixelShape1.graphics.clear(); - this.pixelShape1.graphics.beginFill(es.Colors.colliderPosition, 0); - this.pixelShape1.graphics.lineStyle(4 * es.Size.lineSizeMultiplier, es.Colors.colliderPosition); - this.pixelShape1.graphics.moveTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.lineTo(this.entity.transform.position.x - camera.bounds.y, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.endFill(); - this.pixelShape2.graphics.clear(); - this.pixelShape2.graphics.beginFill(es.Colors.colliderCenter, 0); - this.pixelShape2.graphics.lineStyle(2 * es.Size.lineSizeMultiplier, es.Colors.colliderCenter); - this.pixelShape2.graphics.moveTo(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y); - this.pixelShape2.graphics.lineTo(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y); - this.pixelShape2.graphics.endFill(); - }; - CircleCollider.prototype.toString = function () { - return "[CircleCollider: bounds: " + this.bounds + ", radius: " + this.shape.radius + "]"; - }; - return CircleCollider; - }(es.Collider)); - es.CircleCollider = CircleCollider; -})(es || (es = {})); -var es; -(function (es) { - var PolygonCollider = (function (_super) { - __extends(PolygonCollider, _super); - function PolygonCollider(points) { - var _this = _super.call(this) || this; - var isPolygonClosed = points[0] == points[points.length - 1]; - if (isPolygonClosed) - points.splice(points.length - 1, 1); - var center = es.Polygon.findPolygonCenter(points); - _this.setLocalOffset(center); - es.Polygon.recenterPolygonVerts(points); - _this.shape = new es.Polygon(points); - return _this; - } - return PolygonCollider; - }(es.Collider)); - es.PolygonCollider = PolygonCollider; -})(es || (es = {})); -var es; -(function (es) { - var RenderableComponent = (function (_super) { - __extends(RenderableComponent, _super); - function RenderableComponent() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.displayObject = new egret.DisplayObject(); - _this.hollowShape = new egret.Shape(); - _this.pixelShape = new egret.Shape(); - _this.color = 0x000000; - _this._areBoundsDirty = true; - _this.debugRenderEnabled = true; - _this._localOffset = es.Vector2.zero; - _this._renderLayer = 0; - _this._bounds = new es.Rectangle(); - return _this; - } - Object.defineProperty(RenderableComponent.prototype, "width", { - get: function () { - return this.bounds.width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "height", { - get: function () { - return this.bounds.height; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "localOffset", { - get: function () { - return this._localOffset; - }, - set: function (value) { - this.setLocalOffset(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "renderLayer", { - get: function () { - return this._renderLayer; - }, - set: function (value) { - this.setRenderLayer(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, es.Vector2.zero, this.entity.transform.scale, this.entity.transform.rotation, this.width, this.height); - this._areBoundsDirty = false; - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "isVisible", { - get: function () { - return this._isVisible; - }, - set: function (value) { - if (this._isVisible != value) { - this._isVisible = value; - if (this._isVisible) - this.onBecameVisible(); - else - this.onBecameInvisible(); - } - }, - enumerable: true, - configurable: true - }); - RenderableComponent.prototype.onEntityTransformChanged = function (comp) { - this._areBoundsDirty = true; - }; - RenderableComponent.prototype.debugRender = function (camera) { - if (!this.debugRenderEnabled) - return; - if (!this.hollowShape.parent) - this.debugDisplayObject.addChild(this.hollowShape); - if (!this.pixelShape.parent) - this.debugDisplayObject.addChild(this.pixelShape); - if (!this.entity.getComponent(es.Collider)) { - this.hollowShape.graphics.clear(); - this.hollowShape.graphics.beginFill(es.Colors.renderableBounds, 0); - this.hollowShape.graphics.lineStyle(1, es.Colors.renderableBounds); - this.hollowShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.hollowShape.graphics.endFill(); - } - var pixelPos = es.Vector2.add(this.entity.transform.position, this._localOffset).subtract(camera.bounds.location); - this.pixelShape.graphics.clear(); - this.pixelShape.graphics.beginFill(es.Colors.renderableCenter, 0); - this.pixelShape.graphics.lineStyle(4, es.Colors.renderableCenter); - this.pixelShape.graphics.moveTo(pixelPos.x, pixelPos.y); - this.pixelShape.graphics.lineTo(pixelPos.x, pixelPos.y); - this.pixelShape.graphics.endFill(); - }; - RenderableComponent.prototype.isVisibleFromCamera = function (camera) { - if (!camera) - return false; - this.isVisible = camera.bounds.intersects(this.bounds); - return this.isVisible; - }; - RenderableComponent.prototype.setRenderLayer = function (renderLayer) { - if (renderLayer != this._renderLayer) { - this.displayObject.zIndex = renderLayer; - var oldRenderLayer = this._renderLayer; - this._renderLayer = renderLayer; - if (this.entity && this.entity.scene) - this.entity.scene.renderableComponents.updateRenderableRenderLayer(this, oldRenderLayer, this._renderLayer); - } - return this; - }; - RenderableComponent.prototype.setColor = function (color) { - this.color = color; - return this; - }; - RenderableComponent.prototype.setLocalOffset = function (offset) { - if (this._localOffset != offset) { - this._localOffset = offset; - } - return this; - }; - RenderableComponent.prototype.sync = function (camera) { - if (this.displayObject.x != this.bounds.x - camera.bounds.y) - this.displayObject.x = this.bounds.x - camera.bounds.y; - if (this.displayObject.y != this.bounds.y - camera.bounds.y) - this.displayObject.y = this.bounds.y - camera.bounds.y; - if (this.displayObject.scaleX != this.entity.scale.x) - this.displayObject.scaleX = this.entity.scale.x; - if (this.displayObject.scaleY != this.entity.scale.y) - this.displayObject.scaleY = this.entity.scale.y; - if (this.displayObject.rotation != this.entity.rotationDegrees) - this.displayObject.rotation = this.entity.rotationDegrees; - }; - RenderableComponent.prototype.compareTo = function (other) { - return other.renderLayer - this.renderLayer; - }; - RenderableComponent.prototype.toString = function () { - return "[RenderableComponent] renderLayer: " + this.renderLayer; - }; - RenderableComponent.prototype.onBecameVisible = function () { - this.displayObject.visible = this.isVisible; - this.debugDisplayObject.visible = this.isVisible; - }; - RenderableComponent.prototype.onBecameInvisible = function () { - this.displayObject.visible = this.isVisible; - this.debugDisplayObject.visible = this.isVisible; - }; - return RenderableComponent; - }(es.Component)); - es.RenderableComponent = RenderableComponent; -})(es || (es = {})); -var es; -(function (es) { - var Mesh = (function (_super) { - __extends(Mesh, _super); - function Mesh() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.displayObject = new egret.Mesh(); - _this._primitiveCount = 0; - _this._width = 0; - _this._height = 0; - _this._triangles = []; - _this._verts = []; - return _this; - } - Object.defineProperty(Mesh.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - this._bounds.calculateBounds(es.Vector2.add(this.entity.transform.position, this._topLeftVertPosition), es.Vector2.zero, es.Vector2.zero, this.entity.transform.scale, this.entity.transform.rotation, this._width, this._height); - this._areBoundsDirty = false; - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Mesh.prototype.recalculateBounds = function (recalculateUVs) { - this._topLeftVertPosition = new es.Vector2(Number.MAX_VALUE, Number.MAX_VALUE); - var max = new es.Vector2(Number.MIN_VALUE, Number.MIN_VALUE); - for (var i = 0; i < this._verts.length; i++) { - this._topLeftVertPosition.x = Math.min(this._topLeftVertPosition.x, this._verts[i].position.x); - this._topLeftVertPosition.y = Math.min(this._topLeftVertPosition.y, this._verts[i].position.y); - max.x = Math.max(max.x, this._verts[i].position.x); - max.y = Math.max(max.y, this._verts[i].position.y); - } - this._width = max.x - this._topLeftVertPosition.x; - this._height = max.y - this._topLeftVertPosition.y; - if (recalculateUVs) { - for (var i = 0; i < this._verts.length; i++) { - this._verts[i].textureCoordinate.x = (this._verts[i].position.x - this._topLeftVertPosition.x) / this._width; - this._verts[i].textureCoordinate.y = (this._verts[i].position.y - this._topLeftVertPosition.y) / this._height; - } - } - return this; - }; - Mesh.prototype.setTexture = function (texture) { - this.displayObject.texture = texture; - return this; - }; - Mesh.prototype.setVertPositions = function (positions) { - if (this._verts == undefined || this._verts.length != positions.length) { - this._verts = new Array(positions.length); - this._verts.fill(new VertexPositionColorTexture(), 0, positions.length); - } - for (var i = 0; i < this._verts.length; i++) { - this._verts[i].position = positions[i]; - } - return this; - }; - Mesh.prototype.setTriangles = function (triangles) { - if (triangles.length % 3 != 0) { - console.error("三角形必须是3的倍数"); - return; - } - this._primitiveCount = triangles.length / 3; - this._triangles = triangles; - return this; - }; - Mesh.prototype.render = function (camera) { - var renderNode = this.displayObject.$renderNode; - renderNode.imageWidth = this._width; - renderNode.imageHeight = this._height; - renderNode.vertices = this._triangles; - }; - return Mesh; - }(es.RenderableComponent)); - es.Mesh = Mesh; - var VertexPositionColorTexture = (function () { - function VertexPositionColorTexture() { - } - return VertexPositionColorTexture; - }()); - es.VertexPositionColorTexture = VertexPositionColorTexture; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var SpriteRenderer = (function (_super) { - __extends(SpriteRenderer, _super); - function SpriteRenderer(sprite) { - if (sprite === void 0) { sprite = null; } - var _this = _super.call(this) || this; - if (sprite instanceof es.Sprite) - _this.setSprite(sprite); - else if (sprite instanceof egret.Texture) - _this.setSprite(new es.Sprite(sprite)); - return _this; - } - Object.defineProperty(SpriteRenderer.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - if (this._sprite) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, this.entity.transform.scale, this.entity.transform.rotation, this._sprite.sourceRect.width, this._sprite.sourceRect.height); - this._areBoundsDirty = false; - } - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteRenderer.prototype, "originNormalized", { - get: function () { - return new es.Vector2(this._origin.x / this.width * this.entity.transform.scale.x, this._origin.y / this.height * this.entity.transform.scale.y); - }, - set: function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteRenderer.prototype, "origin", { - get: function () { - return this._origin; - }, - set: function (value) { - this.setOrigin(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteRenderer.prototype, "sprite", { - get: function () { - return this._sprite; - }, - set: function (value) { - this.setSprite(value); - }, - enumerable: true, - configurable: true - }); - SpriteRenderer.prototype.setSprite = function (sprite) { - this._sprite = sprite; - if (this._sprite) { - this._origin = this._sprite.origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - } - this.displayObject = new Bitmap(sprite.texture2D); - this.displayObject.touchEnabled = false; - return this; - }; - SpriteRenderer.prototype.setOrigin = function (origin) { - if (!this._origin.equals(origin)) { - this._origin = origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - this._areBoundsDirty = true; - } - return this; - }; - SpriteRenderer.prototype.setOriginNormalized = function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - return this; - }; - SpriteRenderer.prototype.render = function (camera) { - this.sync(camera); - if (this.displayObject.x != this.bounds.x - camera.bounds.x + this._origin.x) - this.displayObject.x = this.bounds.x - camera.bounds.x + this._origin.x * this.entity.scale.x; - if (this.displayObject.y != this.bounds.y - camera.bounds.y + this._origin.y) - this.displayObject.y = this.bounds.y - camera.bounds.y + this._origin.y * this.entity.scale.y; - if (this.displayObject.anchorOffsetX != this._origin.x) - this.displayObject.anchorOffsetX = this._origin.x; - if (this.displayObject.anchorOffsetY != this._origin.y) - this.displayObject.anchorOffsetY = this._origin.y; - }; - return SpriteRenderer; - }(es.RenderableComponent)); - es.SpriteRenderer = SpriteRenderer; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var RenderTexture = egret.RenderTexture; - var TiledSpriteRenderer = (function (_super) { - __extends(TiledSpriteRenderer, _super); - function TiledSpriteRenderer(sprite) { - var _this = _super.call(this, sprite) || this; - _this._textureScale = es.Vector2.one; - _this._inverseTexScale = es.Vector2.one; - _this._gapX = 0; - _this._gapY = 0; - _this._sourceRect = sprite.sourceRect; - var bitmap = _this.displayObject; - bitmap.$fillMode = egret.BitmapFillMode.REPEAT; - return _this; - } - Object.defineProperty(TiledSpriteRenderer.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - if (this._sprite) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, this.entity.transform.scale, this.entity.transform.rotation, this.width, this.height); - this._areBoundsDirty = false; - } - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "scrollX", { - get: function () { - return this._sourceRect.x; - }, - set: function (value) { - this._sourceRect.x = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "scrollY", { - get: function () { - return this._sourceRect.y; - }, - set: function (value) { - this._sourceRect.y = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "textureScale", { - get: function () { - return this._textureScale; - }, - set: function (value) { - this._textureScale = value; - this._inverseTexScale = new es.Vector2(1 / this._textureScale.x, 1 / this._textureScale.y); - this._sourceRect.width = Math.floor(this._sprite.sourceRect.width * this._inverseTexScale.x); - this._sourceRect.height = Math.floor(this._sprite.sourceRect.height * this._inverseTexScale.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "width", { - get: function () { - return this._sourceRect.width; - }, - set: function (value) { - this._areBoundsDirty = true; - this._sourceRect.width = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "height", { - get: function () { - return this._sourceRect.height; - }, - set: function (value) { - this._areBoundsDirty = true; - this._sourceRect.height = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "gapXY", { - get: function () { - return new es.Vector2(this._gapX, this._gapY); - }, - set: function (value) { - this._gapX = value.x; - this._gapY = value.y; - var renderTexture = new RenderTexture(); - var newRectangle = this.sprite.sourceRect; - newRectangle.x = 0; - newRectangle.y = 0; - newRectangle.width += this._gapX; - newRectangle.height += this._gapY; - renderTexture.drawToTexture(this.displayObject, newRectangle); - if (!this.displayObject) { - this.displayObject = new Bitmap(renderTexture); - } - else { - this.displayObject.texture = renderTexture; - } - }, - enumerable: true, - configurable: true - }); - TiledSpriteRenderer.prototype.setGapXY = function (value) { - this.gapXY = value; - return this; - }; - TiledSpriteRenderer.prototype.render = function (camera) { - _super.prototype.render.call(this, camera); - var bitmap = this.displayObject; - bitmap.width = this.width; - bitmap.height = this.height; - bitmap.scrollRect = this._sourceRect; - }; - return TiledSpriteRenderer; - }(es.SpriteRenderer)); - es.TiledSpriteRenderer = TiledSpriteRenderer; -})(es || (es = {})); -var es; -(function (es) { - var ScrollingSpriteRenderer = (function (_super) { - __extends(ScrollingSpriteRenderer, _super); - function ScrollingSpriteRenderer(sprite) { - var _this = _super.call(this, sprite) || this; - _this.scrollSpeedX = 15; - _this.scroolSpeedY = 0; - _this._scrollX = 0; - _this._scrollY = 0; - _this._scrollWidth = 0; - _this._scrollHeight = 0; - _this._scrollWidth = _this.width; - _this._scrollHeight = _this.height; - return _this; - } - Object.defineProperty(ScrollingSpriteRenderer.prototype, "textureScale", { - get: function () { - return this._textureScale; - }, - set: function (value) { - this._textureScale = value; - this._inverseTexScale = new es.Vector2(1 / this._textureScale.x, 1 / this._textureScale.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollingSpriteRenderer.prototype, "scrollWidth", { - get: function () { - return this._scrollWidth; - }, - set: function (value) { - this._scrollWidth = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollingSpriteRenderer.prototype, "scrollHeight", { - get: function () { - return this._scrollHeight; - }, - set: function (value) { - this._scrollHeight = value; - }, - enumerable: true, - configurable: true - }); - ScrollingSpriteRenderer.prototype.update = function () { - if (!this.sprite) - return; - this._scrollX += this.scrollSpeedX * es.Time.deltaTime; - this._scrollY += this.scroolSpeedY * es.Time.deltaTime; - this._sourceRect.x = Math.floor(this._scrollX); - this._sourceRect.y = Math.floor(this._scrollY); - this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX); - this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY); - }; - return ScrollingSpriteRenderer; - }(es.TiledSpriteRenderer)); - es.ScrollingSpriteRenderer = ScrollingSpriteRenderer; -})(es || (es = {})); -var es; -(function (es) { - var SpriteSheet = egret.SpriteSheet; - var Sprite = (function () { - function Sprite(texture, sourceRect, origin) { - if (sourceRect === void 0) { sourceRect = new es.Rectangle(0, 0, texture.textureWidth, texture.textureHeight); } - if (origin === void 0) { origin = sourceRect.getHalfSize(); } - this.uvs = new es.Rectangle(); - this.texture2D = texture; - this.sourceRect = sourceRect; - this.center = new es.Vector2(sourceRect.width * 0.5, sourceRect.height * 0.5); - this.origin = origin; - var inverseTexW = 1 / texture.textureWidth; - var inverseTexH = 1 / texture.textureHeight; - this.uvs.x = sourceRect.x * inverseTexW; - this.uvs.y = sourceRect.y * inverseTexH; - this.uvs.width = sourceRect.width * inverseTexW; - this.uvs.height = sourceRect.height * inverseTexH; - } - Sprite.spritesFromAtlas = function (texture, cellWidth, cellHeight, cellOffset, maxCellsToInclude) { - if (cellOffset === void 0) { cellOffset = 0; } - if (maxCellsToInclude === void 0) { maxCellsToInclude = Number.MAX_VALUE; } - var sprites = []; - var cols = texture.textureWidth / cellWidth; - var rows = texture.textureHeight / cellHeight; - var i = 0; - var spriteSheet = new SpriteSheet(texture); - for (var y = 0; y < rows; y++) { - for (var x = 0; x < cols; x++) { - if (i++ < cellOffset) - continue; - var texture_1 = spriteSheet.getTexture(y + "_" + x); - if (!texture_1) - texture_1 = spriteSheet.createTexture(y + "_" + x, x * cellWidth, y * cellHeight, cellWidth, cellHeight); - sprites.push(new Sprite(texture_1)); - if (sprites.length == maxCellsToInclude) - return sprites; - } - } - return sprites; - }; - return Sprite; - }()); - es.Sprite = Sprite; -})(es || (es = {})); -var es; -(function (es) { - var SpriteAnimation = (function () { - function SpriteAnimation(sprites, frameRate) { - if (frameRate === void 0) { frameRate = 10; } - this.sprites = sprites; - this.frameRate = frameRate; - } - return SpriteAnimation; - }()); - es.SpriteAnimation = SpriteAnimation; -})(es || (es = {})); -var es; -(function (es) { - var LoopMode; - (function (LoopMode) { - LoopMode[LoopMode["loop"] = 0] = "loop"; - LoopMode[LoopMode["once"] = 1] = "once"; - LoopMode[LoopMode["clampForever"] = 2] = "clampForever"; - LoopMode[LoopMode["pingPong"] = 3] = "pingPong"; - LoopMode[LoopMode["pingPongOnce"] = 4] = "pingPongOnce"; - })(LoopMode = es.LoopMode || (es.LoopMode = {})); - var State; - (function (State) { - State[State["none"] = 0] = "none"; - State[State["running"] = 1] = "running"; - State[State["paused"] = 2] = "paused"; - State[State["completed"] = 3] = "completed"; - })(State = es.State || (es.State = {})); - var SpriteAnimator = (function (_super) { - __extends(SpriteAnimator, _super); - function SpriteAnimator(sprite) { - var _this = _super.call(this, sprite) || this; - _this.speed = 1; - _this.animationState = State.none; - _this._elapsedTime = 0; - _this._animations = new Map(); - return _this; - } - Object.defineProperty(SpriteAnimator.prototype, "isRunning", { - get: function () { - return this.animationState == State.running; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteAnimator.prototype, "animations", { - get: function () { - return this._animations; - }, - enumerable: true, - configurable: true - }); - SpriteAnimator.prototype.update = function () { - if (this.animationState != State.running || !this.currentAnimation) - return; - var animation = this.currentAnimation; - var secondsPerFrame = 1 / (animation.frameRate * this.speed); - var iterationDuration = secondsPerFrame * animation.sprites.length; - this._elapsedTime += es.Time.deltaTime; - var time = Math.abs(this._elapsedTime); - if (this._loopMode == LoopMode.once && time > iterationDuration || - this._loopMode == LoopMode.pingPongOnce && time > iterationDuration * 2) { - this.animationState = State.completed; - this._elapsedTime = 0; - this.currentFrame = 0; - this.displayObject.texture = animation.sprites[this.currentFrame].texture2D; - return; - } - var i = Math.floor(time / secondsPerFrame); - var n = animation.sprites.length; - if (n > 2 && (this._loopMode == LoopMode.pingPong || this._loopMode == LoopMode.pingPongOnce)) { - var maxIndex = n - 1; - this.currentFrame = maxIndex - Math.abs(maxIndex - i % (maxIndex * 2)); - } - else { - this.currentFrame = i % n; - } - this.displayObject.texture = animation.sprites[this.currentFrame].texture2D; - }; - SpriteAnimator.prototype.addAnimation = function (name, animation) { - if (!this.sprite && animation.sprites.length > 0) - this.setSprite(animation.sprites[0]); - this._animations[name] = animation; - return this; - }; - SpriteAnimator.prototype.play = function (name, loopMode) { - if (loopMode === void 0) { loopMode = null; } - this.currentAnimation = this._animations[name]; - this.currentAnimationName = name; - this.currentFrame = 0; - this.animationState = State.running; - this.displayObject.texture = this.currentAnimation.sprites[0].texture2D; - this._elapsedTime = 0; - this._loopMode = loopMode ? loopMode : LoopMode.loop; - }; - SpriteAnimator.prototype.isAnimationActive = function (name) { - return this.currentAnimation && this.currentAnimationName == name; - }; - SpriteAnimator.prototype.pause = function () { - this.animationState = State.paused; - }; - SpriteAnimator.prototype.unPause = function () { - this.animationState = State.running; - }; - SpriteAnimator.prototype.stop = function () { - this.currentAnimation = null; - this.currentAnimationName = null; - this.currentFrame = 0; - this.animationState = State.none; - }; - return SpriteAnimator; - }(es.SpriteRenderer)); - es.SpriteAnimator = SpriteAnimator; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var StaticSpriteContainerRenderer = (function (_super) { - __extends(StaticSpriteContainerRenderer, _super); - function StaticSpriteContainerRenderer(sprite) { - if (sprite === void 0) { sprite = null; } - var _this = _super.call(this) || this; - _this.displayObject = new egret.DisplayObjectContainer(); - _this.displayObjectCache = new Map(); - for (var _i = 0, sprite_1 = sprite; _i < sprite_1.length; _i++) { - var s = sprite_1[_i]; - if (s instanceof es.Sprite) - _this.pushSprite(s); - else if (s instanceof egret.Texture) - _this.pushSprite(new es.Sprite(s)); - } - _this.displayObject.cacheAsBitmap = true; - return _this; - } - Object.defineProperty(StaticSpriteContainerRenderer.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - if (this.displayObject) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, this.entity.transform.scale, this.entity.transform.rotation, this.displayObject.width, this.displayObject.height); - this._areBoundsDirty = false; - } - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(StaticSpriteContainerRenderer.prototype, "originNormalized", { - get: function () { - return new es.Vector2(this._origin.x / this.width * this.entity.transform.scale.x, this._origin.y / this.height * this.entity.transform.scale.y); - }, - set: function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(StaticSpriteContainerRenderer.prototype, "origin", { - get: function () { - return this._origin; - }, - set: function (value) { - this.setOrigin(value); - }, - enumerable: true, - configurable: true - }); - StaticSpriteContainerRenderer.prototype.pushSprite = function (sprite) { - if (sprite) { - this._origin = sprite.origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - } - var bitmap = new Bitmap(sprite.texture2D); - this.displayObject.addChild(new Bitmap(sprite.texture2D)); - this.displayObjectCache.set(sprite, bitmap); - return this; - }; - StaticSpriteContainerRenderer.prototype.getSprite = function (sprite) { - return this.displayObjectCache.get(sprite); - }; - StaticSpriteContainerRenderer.prototype.setOrigin = function (origin) { - if (this._origin != origin) { - this._origin = origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - this._areBoundsDirty = true; - } - return this; - }; - StaticSpriteContainerRenderer.prototype.setOriginNormalized = function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - return this; - }; - StaticSpriteContainerRenderer.prototype.render = function (camera) { - this.sync(camera); - if (this.displayObject.x != this.bounds.x - camera.bounds.x) - this.displayObject.x = this.bounds.x - camera.bounds.x; - if (this.displayObject.y != this.bounds.y - camera.bounds.y) - this.displayObject.y = this.bounds.y - camera.bounds.y; - }; - return StaticSpriteContainerRenderer; - }(es.RenderableComponent)); - es.StaticSpriteContainerRenderer = StaticSpriteContainerRenderer; -})(es || (es = {})); -var es; -(function (es) { - var EntitySystem = (function () { - function EntitySystem(matcher) { - this._entities = []; - this._matcher = matcher ? matcher : es.Matcher.empty(); - } - Object.defineProperty(EntitySystem.prototype, "scene", { - get: function () { - return this._scene; - }, - set: function (value) { - this._scene = value; - this._entities = []; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EntitySystem.prototype, "matcher", { - get: function () { - return this._matcher; - }, - enumerable: true, - configurable: true - }); - EntitySystem.prototype.initialize = function () { - }; - EntitySystem.prototype.onChanged = function (entity) { - var contains = this._entities.contains(entity); - var interest = this._matcher.IsIntersted(entity); - if (interest && !contains) - this.add(entity); - else if (!interest && contains) - this.remove(entity); - }; - EntitySystem.prototype.add = function (entity) { - this._entities.push(entity); - this.onAdded(entity); - }; - EntitySystem.prototype.onAdded = function (entity) { - }; - EntitySystem.prototype.remove = function (entity) { - this._entities.remove(entity); - this.onRemoved(entity); - }; - EntitySystem.prototype.onRemoved = function (entity) { - }; - EntitySystem.prototype.update = function () { - this.begin(); - this.process(this._entities); - }; - EntitySystem.prototype.lateUpdate = function () { - this.lateProcess(this._entities); - this.end(); - }; - EntitySystem.prototype.begin = function () { - }; - EntitySystem.prototype.process = function (entities) { - }; - EntitySystem.prototype.lateProcess = function (entities) { - }; - EntitySystem.prototype.end = function () { - }; - return EntitySystem; - }()); - es.EntitySystem = EntitySystem; -})(es || (es = {})); -var es; -(function (es) { - var EntityProcessingSystem = (function (_super) { - __extends(EntityProcessingSystem, _super); - function EntityProcessingSystem(matcher) { - return _super.call(this, matcher) || this; - } - EntityProcessingSystem.prototype.lateProcessEntity = function (entity) { - }; - EntityProcessingSystem.prototype.process = function (entities) { - var _this = this; - entities.forEach(function (entity) { return _this.processEntity(entity); }); - }; - EntityProcessingSystem.prototype.lateProcess = function (entities) { - var _this = this; - entities.forEach(function (entity) { return _this.lateProcessEntity(entity); }); - }; - return EntityProcessingSystem; - }(es.EntitySystem)); - es.EntityProcessingSystem = EntityProcessingSystem; -})(es || (es = {})); -var es; -(function (es) { - var PassiveSystem = (function (_super) { - __extends(PassiveSystem, _super); - function PassiveSystem() { - return _super !== null && _super.apply(this, arguments) || this; - } - PassiveSystem.prototype.onChanged = function (entity) { - }; - PassiveSystem.prototype.process = function (entities) { - this.begin(); - this.end(); - }; - return PassiveSystem; - }(es.EntitySystem)); - es.PassiveSystem = PassiveSystem; -})(es || (es = {})); -var es; -(function (es) { - var ProcessingSystem = (function (_super) { - __extends(ProcessingSystem, _super); - function ProcessingSystem() { - return _super !== null && _super.apply(this, arguments) || this; - } - ProcessingSystem.prototype.onChanged = function (entity) { - }; - ProcessingSystem.prototype.process = function (entities) { - this.begin(); - this.processSystem(); - this.end(); - }; - return ProcessingSystem; - }(es.EntitySystem)); - es.ProcessingSystem = ProcessingSystem; -})(es || (es = {})); -var es; -(function (es) { - var BitSet = (function () { - function BitSet(nbits) { - if (nbits === void 0) { nbits = 64; } - var length = nbits >> 6; - if ((nbits & BitSet.LONG_MASK) != 0) - length++; - this._bits = new Array(length); - } - BitSet.prototype.and = function (bs) { - var max = Math.min(this._bits.length, bs._bits.length); - var i; - for (var i_1 = 0; i_1 < max; ++i_1) - this._bits[i_1] &= bs._bits[i_1]; - while (i < this._bits.length) - this._bits[i++] = 0; - }; - BitSet.prototype.andNot = function (bs) { - var i = Math.min(this._bits.length, bs._bits.length); - while (--i >= 0) - this._bits[i] &= ~bs._bits[i]; - }; - BitSet.prototype.cardinality = function () { - var card = 0; - for (var i = this._bits.length - 1; i >= 0; i--) { - var a = this._bits[i]; - if (a == 0) - continue; - if (a == -1) { - card += 64; - continue; - } - a = ((a >> 1) & 0x5555555555555555) + (a & 0x5555555555555555); - a = ((a >> 2) & 0x3333333333333333) + (a & 0x3333333333333333); - var b = ((a >> 32) + a); - b = ((b >> 4) & 0x0f0f0f0f) + (b & 0x0f0f0f0f); - b = ((b >> 8) & 0x00ff00ff) + (b & 0x00ff00ff); - card += ((b >> 16) & 0x0000ffff) + (b & 0x0000ffff); - } - return card; - }; - BitSet.prototype.clear = function (pos) { - if (pos != undefined) { - var offset = pos >> 6; - this.ensure(offset); - this._bits[offset] &= ~(1 << pos); - } - else { - for (var i = 0; i < this._bits.length; i++) - this._bits[i] = 0; - } - }; - BitSet.prototype.get = function (pos) { - var offset = pos >> 6; - if (offset >= this._bits.length) - return false; - return (this._bits[offset] & (1 << pos)) != 0; - }; - BitSet.prototype.intersects = function (set) { - var i = Math.min(this._bits.length, set._bits.length); - while (--i >= 0) { - if ((this._bits[i] & set._bits[i]) != 0) - return true; - } - return false; - }; - BitSet.prototype.isEmpty = function () { - for (var i = this._bits.length - 1; i >= 0; i--) { - if (this._bits[i]) - return false; - } - return true; - }; - BitSet.prototype.nextSetBit = function (from) { - var offset = from >> 6; - var mask = 1 << from; - while (offset < this._bits.length) { - var h = this._bits[offset]; - do { - if ((h & mask) != 0) - return from; - mask <<= 1; - from++; - } while (mask != 0); - mask = 1; - offset++; - } - return -1; - }; - BitSet.prototype.set = function (pos, value) { - if (value === void 0) { value = true; } - if (value) { - var offset = pos >> 6; - this.ensure(offset); - this._bits[offset] |= 1 << pos; - } - else { - this.clear(pos); - } - }; - BitSet.prototype.ensure = function (lastElt) { - if (lastElt >= this._bits.length) { - var nd = new Number[lastElt + 1]; - nd = this._bits.copyWithin(0, 0, this._bits.length); - this._bits = nd; - } - }; - BitSet.LONG_MASK = 0x3f; - return BitSet; - }()); - es.BitSet = BitSet; -})(es || (es = {})); -var es; -(function (es) { - var ComponentList = (function () { - function ComponentList(entity) { - this._components = new es.FastList(); - this._componentsToAdd = []; - this._componentsToRemove = []; - this._tempBufferList = []; - this._entity = entity; - } - Object.defineProperty(ComponentList.prototype, "count", { - get: function () { - return this._components.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ComponentList.prototype, "buffer", { - get: function () { - return this._components.buffer; - }, - enumerable: true, - configurable: true - }); - ComponentList.prototype.markEntityListUnsorted = function () { - this._isComponentListUnsorted = true; - }; - ComponentList.prototype.add = function (component) { - this._componentsToAdd.push(component); - }; - ComponentList.prototype.remove = function (component) { - if (this._componentsToRemove.contains(component)) - console.warn("\u60A8\u6B63\u5728\u5C1D\u8BD5\u5220\u9664\u4E00\u4E2A\u60A8\u5DF2\u7ECF\u5220\u9664\u7684\u7EC4\u4EF6(" + component + ")"); - if (this._componentsToAdd.contains(component)) { - this._componentsToAdd.remove(component); - return; - } - this._componentsToRemove.push(component); - }; - ComponentList.prototype.removeAllComponents = function () { - for (var i = 0; i < this._components.length; i++) { - this.handleRemove(this._components[i]); - } - this._components.clear(); - this._componentsToAdd.length = 0; - this._componentsToRemove.length = 0; - }; - ComponentList.prototype.deregisterAllComponents = function () { - for (var i = 0; i < this._components.length; i++) { - var component = this._components.buffer[i]; - if (!component) - continue; - if (component instanceof es.RenderableComponent) { - if (component.displayObject.parent) - component.displayObject.parent.removeChild(component.displayObject); - this._entity.scene.renderableComponents.remove(component); - } - if (component.debugDisplayObject.parent) - component.debugDisplayObject.parent.removeChild(component.debugDisplayObject); - this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component), false); - this._entity.scene.entityProcessors.onComponentRemoved(this._entity); - } - }; - ComponentList.prototype.registerAllComponents = function () { - for (var i = 0; i < this._components.length; i++) { - var component = this._components.buffer[i]; - if (component instanceof es.RenderableComponent) { - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.displayObject); - this._entity.scene.renderableComponents.add(component); - } - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.debugDisplayObject); - this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component)); - this._entity.scene.entityProcessors.onComponentAdded(this._entity); - } - if (this._entity.scene.dynamicBatch) - this._entity.scene.dynamicInBatch(); - }; - ComponentList.prototype.updateLists = function () { - if (this._componentsToRemove.length > 0) { - for (var i = 0; i < this._componentsToRemove.length; i++) { - this.handleRemove(this._componentsToRemove[i]); - this._components.remove(this._componentsToRemove[i]); - } - this._componentsToRemove.length = 0; - } - if (this._componentsToAdd.length > 0) { - for (var i = 0, count = this._componentsToAdd.length; i < count; i++) { - var component = this._componentsToAdd[i]; - if (component instanceof es.RenderableComponent) { - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.displayObject); - this._entity.scene.renderableComponents.add(component); - } - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.debugDisplayObject); - this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component)); - this._entity.scene.entityProcessors.onComponentAdded(this._entity); - this._components.add(component); - this._tempBufferList.push(component); - } - if (this._entity.scene.dynamicBatch) - this._entity.scene.dynamicInBatch(); - this._componentsToAdd.length = 0; - this._isComponentListUnsorted = true; - for (var i = 0; i < this._tempBufferList.length; i++) { - var component = this._tempBufferList[i]; - component.onAddedToEntity(); - if (component.enabled) { - component.onEnabled(); - } - } - this._tempBufferList.length = 0; - } - if (this._isComponentListUnsorted) { - this._components.sort(ComponentList.compareUpdatableOrder); - this._isComponentListUnsorted = false; - } - }; - ComponentList.prototype.handleRemove = function (component) { - if (!component) - return; - if (component instanceof es.RenderableComponent) { - if (component.displayObject.parent) - component.displayObject.parent.removeChild(component.displayObject); - this._entity.scene.renderableComponents.remove(component); - } - if (component.debugDisplayObject.parent) - component.debugDisplayObject.parent.removeChild(component.debugDisplayObject); - this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component), false); - this._entity.scene.entityProcessors.onComponentRemoved(this._entity); - component.onRemovedFromEntity(); - component.entity = null; - }; - ComponentList.prototype.getComponent = function (type, onlyReturnInitializedComponents) { - for (var i = 0; i < this._components.length; i++) { - var component = this._components.buffer[i]; - if (component instanceof type) - return component; - } - if (!onlyReturnInitializedComponents) { - for (var i = 0; i < this._componentsToAdd.length; i++) { - var component = this._componentsToAdd[i]; - if (component instanceof type) - return component; - } - } - return null; - }; - ComponentList.prototype.getComponents = function (typeName, components) { - if (!components) - components = []; - for (var i = 0; i < this._components.length; i++) { - var component = this._components.buffer[i]; - if (typeof (typeName) == "string") { - if (egret.is(component, typeName)) { - components.push(component); - } - } - else { - if (component instanceof typeName) { - components.push(component); - } - } - } - for (var i = 0; i < this._componentsToAdd.length; i++) { - var component = this._componentsToAdd[i]; - if (typeof (typeName) == "string") { - if (egret.is(component, typeName)) { - components.push(component); - } - } - else { - if (component instanceof typeName) { - components.push(component); - } - } - } - return components; - }; - ComponentList.prototype.update = function () { - this.updateLists(); - for (var i = 0; i < this._components.length; i++) { - var updatableComponent = this._components.buffer[i]; - if (updatableComponent.enabled && - (updatableComponent.updateInterval == 1 || - es.Time.frameCount % updatableComponent.updateInterval == 0)) - updatableComponent.update(); - } - }; - ComponentList.prototype.onEntityTransformChanged = function (comp) { - for (var i = 0; i < this._components.length; i++) { - if (this._components.buffer[i].enabled) - this._components.buffer[i].onEntityTransformChanged(comp); - } - for (var i = 0; i < this._componentsToAdd.length; i++) { - if (this._componentsToAdd[i].enabled) - this._componentsToAdd[i].onEntityTransformChanged(comp); - } - }; - ComponentList.prototype.onEntityEnabled = function () { - for (var i = 0; i < this._components.length; i++) - this._components.buffer[i].onEnabled(); - }; - ComponentList.prototype.onEntityDisabled = function () { - for (var i = 0; i < this._components.length; i++) - this._components.buffer[i].onDisabled(); - }; - ComponentList.prototype.debugRender = function (camera) { - for (var i = 0; i < this._components.length; i++) { - if (this._components.buffer[i].enabled) - this._components.buffer[i].debugRender(camera); - } - }; - ComponentList.compareUpdatableOrder = new es.IUpdatableComparer(); - return ComponentList; - }()); - es.ComponentList = ComponentList; -})(es || (es = {})); -var es; -(function (es) { - var ComponentTypeManager = (function () { - function ComponentTypeManager() { - } - ComponentTypeManager.add = function (type) { - if (!this._componentTypesMask.has(type)) - this._componentTypesMask[type] = this._componentTypesMask.size; - }; - ComponentTypeManager.getIndexFor = function (type) { - var v = -1; - if (!this._componentTypesMask.has(type)) { - this.add(type); - v = this._componentTypesMask.get(type); - } - return v; - }; - ComponentTypeManager._componentTypesMask = new Map(); - return ComponentTypeManager; - }()); - es.ComponentTypeManager = ComponentTypeManager; -})(es || (es = {})); -var es; -(function (es) { - var EntityList = (function () { - function EntityList(scene) { - this._entities = []; - this._entitiesToAdded = []; - this._entitiesToRemove = []; - this._entityDict = new Map(); - this._unsortedTags = new Set(); - this._addToSceneEntityList = []; - this.frameAllocate = false; - this.maxAllocate = 10; - this.scene = scene; - } - Object.defineProperty(EntityList.prototype, "count", { - get: function () { - return this._entities.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EntityList.prototype, "buffer", { - get: function () { - return this._entities; - }, - enumerable: true, - configurable: true - }); - EntityList.prototype.markEntityListUnsorted = function () { - this._isEntityListUnsorted = true; - }; - EntityList.prototype.markTagUnsorted = function (tag) { - this._unsortedTags.add(tag); - }; - EntityList.prototype.add = function (entity) { - if (this._entitiesToAdded.indexOf(entity) == -1) - this._entitiesToAdded.push(entity); - }; - EntityList.prototype.remove = function (entity) { - if (!this._entitiesToRemove.contains(entity)) { - console.warn("\u60A8\u6B63\u5728\u5C1D\u8BD5\u5220\u9664\u5DF2\u7ECF\u5220\u9664\u7684\u5B9E\u4F53(" + entity.name + ")"); - return; - } - if (this._entitiesToAdded.contains(entity)) { - this._entitiesToAdded.remove(entity); - return; - } - if (!this._entitiesToRemove.contains(entity)) - this._entitiesToRemove.push(entity); - }; - EntityList.prototype.removeAllEntities = function () { - this._unsortedTags.clear(); - this._entitiesToAdded.length = 0; - this._isEntityListUnsorted = false; - this.updateLists(); - for (var i = 0; i < this._entities.length; i++) { - this._entities[i]._isDestroyed = true; - this._entities[i].onRemovedFromScene(); - this._entities[i].scene = null; - } - this._entities.length = 0; - this._entityDict.clear(); - }; - EntityList.prototype.contains = function (entity) { - return this._entities.findIndex(function (e) { return e.id == entity.id; }) != -1 || - this._entitiesToAdded.findIndex(function (e) { return e.id == entity.id; }) != -1; - }; - EntityList.prototype.getTagList = function (tag) { - var list = this._entityDict.get(tag); - if (!list) { - list = []; - this._entityDict.set(tag, list); - } - return list; - }; - EntityList.prototype.addToTagList = function (entity) { - var list = this.getTagList(entity.tag); - if (list.findIndex(function (e) { return e.id == entity.id; }) == -1) { - list.push(entity); - this._unsortedTags.add(entity.tag); - } - }; - EntityList.prototype.removeFromTagList = function (entity) { - var list = this._entityDict.get(entity.tag); - if (list) { - list.remove(entity); - } - }; - EntityList.prototype.update = function () { - for (var i = 0; i < this._entities.length; i++) { - var entity = this._entities[i]; - if (entity.enabled && (entity.updateInterval == 1 || es.Time.frameCount % entity.updateInterval == 0)) - entity.update(); - } - }; - EntityList.prototype.updateLists = function () { - var _this = this; - if (this._entitiesToRemove.length > 0) { - for (var _i = 0, _a = this._entitiesToRemove; _i < _a.length; _i++) { - var entity = _a[_i]; - this.removeFromTagList(entity); - this._entities.remove(entity); - entity.onRemovedFromScene(); - entity.scene = null; - this.scene.entityProcessors.onEntityRemoved(entity); - } - this._entitiesToRemove.length = 0; - } - while (this._addToSceneEntityList.length > 0) { - var entity = this._addToSceneEntityList.shift(); - entity.onAddedToScene(); - } - if (this._entitiesToAdded.length > 0) { - if (this.frameAllocate && this._entitiesToAdded.length > this.maxAllocate) { - for (var i = 0; i < this.maxAllocate; i++) { - this.perEntityAddToScene(); - } - if (this._entitiesToAdded.length == 0) - this._isEntityListUnsorted = true; - } - else { - while (this._entitiesToAdded.length > 0) { - this.perEntityAddToScene(); - } - this._isEntityListUnsorted = true; - } - } - if (this._isEntityListUnsorted) { - this._entities.sort(function (a, b) { - return a.compareTo(b); - }); - this._isEntityListUnsorted = false; - } - if (this._addToSceneEntityList.length == 0 && this._unsortedTags.size > 0) { - this._unsortedTags.forEach(function (tag) { - _this._entityDict.get(tag).sort(function (a, b) { - return a.compareTo(b); - }); - }); - this._unsortedTags.clear(); - } - }; - EntityList.prototype.perEntityAddToScene = function () { - var entity = this._entitiesToAdded.shift(); - this._addToSceneEntityList.push(entity); - if (this._entities.findIndex(function (e) { return e.id == entity.id; }) == -1) { - this._entities.push(entity); - entity.scene = this.scene; - this.addToTagList(entity); - this.scene.entityProcessors.onEntityAdded(entity); - } - }; - EntityList.prototype.findEntity = function (name) { - for (var i = 0; i < this._entities.length; i++) { - if (this._entities[i].name == name) - return this._entities[i]; - } - return this._entitiesToAdded.firstOrDefault(function (entity) { return entity.name == name; }); - }; - EntityList.prototype.entitiesWithTag = function (tag) { - var list = this.getTagList(tag); - var returnList = es.ListPool.obtain(); - returnList.length = this._entities.length; - for (var i = 0; i < list.length; i++) - returnList.push(list[i]); - return returnList; - }; - EntityList.prototype.entitiesOfType = function (type) { - var list = es.ListPool.obtain(); - for (var i = 0; i < this._entities.length; i++) { - if (this._entities[i] instanceof type) - list.push(this._entities[i]); - } - for (var _i = 0, _a = this._entitiesToAdded; _i < _a.length; _i++) { - var entity = _a[_i]; - if (entity instanceof type) - list.push(entity); - } - return list; - }; - EntityList.prototype.findComponentOfType = function (type) { - for (var i = 0; i < this._entities.length; i++) { - if (this._entities[i].enabled) { - var comp = this._entities[i].getComponent(type); - if (comp) - return comp; - } - } - for (var i = 0; i < this._entitiesToAdded.length; i++) { - var entity = this._entitiesToAdded[i]; - if (entity.enabled) { - var comp = entity.getComponent(type); - if (comp) - return comp; - } - } - return null; - }; - EntityList.prototype.findComponentsOfType = function (type) { - var comps = es.ListPool.obtain(); - for (var i = 0; i < this._entities.length; i++) { - if (this._entities[i].enabled) - this._entities[i].getComponents(type, comps); - } - for (var i = 0; i < this._entitiesToAdded.length; i++) { - var entity = this._entitiesToAdded[i]; - if (entity.enabled) - entity.getComponents(type, comps); - } - return comps; - }; - return EntityList; - }()); - es.EntityList = EntityList; -})(es || (es = {})); -var es; -(function (es) { - var EntityProcessorList = (function () { - function EntityProcessorList() { - this._processors = []; - } - EntityProcessorList.prototype.add = function (processor) { - this._processors.push(processor); - }; - EntityProcessorList.prototype.remove = function (processor) { - this._processors.remove(processor); - }; - EntityProcessorList.prototype.onComponentAdded = function (entity) { - this.notifyEntityChanged(entity); - }; - EntityProcessorList.prototype.onComponentRemoved = function (entity) { - this.notifyEntityChanged(entity); - }; - EntityProcessorList.prototype.onEntityAdded = function (entity) { - this.notifyEntityChanged(entity); - }; - EntityProcessorList.prototype.onEntityRemoved = function (entity) { - this.removeFromProcessors(entity); - }; - EntityProcessorList.prototype.begin = function () { - }; - EntityProcessorList.prototype.update = function () { - for (var i = 0; i < this._processors.length; i++) { - this._processors[i].update(); - } - }; - EntityProcessorList.prototype.lateUpdate = function () { - for (var i = 0; i < this._processors.length; i++) { - this._processors[i].lateUpdate(); - } - }; - EntityProcessorList.prototype.end = function () { - }; - EntityProcessorList.prototype.getProcessor = function () { - for (var i = 0; i < this._processors.length; i++) { - var processor = this._processors[i]; - if (processor instanceof es.EntitySystem) - return processor; - } - return null; - }; - EntityProcessorList.prototype.notifyEntityChanged = function (entity) { - for (var i = 0; i < this._processors.length; i++) { - this._processors[i].onChanged(entity); - } - }; - EntityProcessorList.prototype.removeFromProcessors = function (entity) { - for (var i = 0; i < this._processors.length; i++) { - this._processors[i].remove(entity); - } - }; - return EntityProcessorList; - }()); - es.EntityProcessorList = EntityProcessorList; -})(es || (es = {})); -var es; -(function (es) { - var FasterDictionary = (function () { - function FasterDictionary(size) { - if (size === void 0) { size = 1; } - this._freeValueCellIndex = 0; - this._collisions = 0; - this._valuesInfo = new Array(size); - this._values = new Array(size); - this._buckets = new Array(es.HashHelpers.getPrime(size)); - } - FasterDictionary.prototype.getValuesArray = function (count) { - count.value = this._freeValueCellIndex; - return this._values; - }; - Object.defineProperty(FasterDictionary.prototype, "valuesArray", { - get: function () { - return this._values; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(FasterDictionary.prototype, "count", { - get: function () { - return this._freeValueCellIndex; - }, - enumerable: true, - configurable: true - }); - FasterDictionary.prototype.add = function (key, value) { - if (!this.addValue(key, value, { value: 0 })) - throw new Error("key 已经存在"); - }; - FasterDictionary.prototype.addValue = function (key, value, indexSet) { - var hash = es.HashHelpers.getHashCode(key); - var bucketIndex = FasterDictionary.reduce(hash, this._buckets.length); - if (this._freeValueCellIndex == this._values.length) { - var expandPrime = es.HashHelpers.expandPrime(this._freeValueCellIndex); - this._values.length = expandPrime; - this._valuesInfo.length = expandPrime; - } - var valueIndex = es.NumberExtension.toNumber(this._buckets[bucketIndex]) - 1; - if (valueIndex == -1) { - this._valuesInfo[this._freeValueCellIndex] = new FastNode(key, hash); - } - else { - { - var currentValueIndex = valueIndex; - do { - if (this._valuesInfo[currentValueIndex].hashcode == hash && - this._valuesInfo[currentValueIndex].key == key) { - this._values[currentValueIndex] = value; - indexSet.value = currentValueIndex; - return false; - } - currentValueIndex = this._valuesInfo[currentValueIndex].previous; - } while (currentValueIndex != -1); - } - this._collisions++; - this._valuesInfo[this._freeValueCellIndex] = new FastNode(key, hash, valueIndex); - this._valuesInfo[valueIndex].next = this._freeValueCellIndex; - } - this._buckets[bucketIndex] = (this._freeValueCellIndex + 1); - this._values[this._freeValueCellIndex] = value; - indexSet.value = this._freeValueCellIndex; - this._freeValueCellIndex++; - if (this._collisions > this._buckets.length) { - this._buckets = new Array(es.HashHelpers.expandPrime(this._collisions)); - this._collisions = 0; - for (var newValueIndex = 0; newValueIndex < this._freeValueCellIndex; newValueIndex++) { - bucketIndex = FasterDictionary.reduce(this._valuesInfo[newValueIndex].hashcode, this._buckets.length); - var existingValueIndex = es.NumberExtension.toNumber(this._buckets[bucketIndex]) - 1; - this._buckets[bucketIndex] = newValueIndex + 1; - if (existingValueIndex != -1) { - this._collisions++; - this._valuesInfo[newValueIndex].previous = existingValueIndex; - this._valuesInfo[newValueIndex].next = -1; - this._valuesInfo[existingValueIndex].next = newValueIndex; - } - else { - this._valuesInfo[newValueIndex].next = -1; - this._valuesInfo[newValueIndex].previous = -1; - } - } - } - return true; - }; - FasterDictionary.prototype.remove = function (key) { - var hash = FasterDictionary.hash(key); - var bucketIndex = FasterDictionary.reduce(hash, this._buckets.length); - var indexToValueToRemove = es.NumberExtension.toNumber(this._buckets[bucketIndex]) - 1; - while (indexToValueToRemove != -1) { - if (this._valuesInfo[indexToValueToRemove].hashcode == hash && - this._valuesInfo[indexToValueToRemove].key == key) { - if (this._buckets[bucketIndex] - 1 == indexToValueToRemove) { - if (this._valuesInfo[indexToValueToRemove].next != -1) - throw new Error("如果 bucket 指向单元格,那么 next 必须不存在。"); - var value = this._valuesInfo[indexToValueToRemove].previous; - this._buckets[bucketIndex] = value + 1; - } - else { - if (this._valuesInfo[indexToValueToRemove].next == -1) - throw new Error("如果 bucket 指向另一个单元格,则 NEXT 必须存在"); - } - FasterDictionary.updateLinkedList(indexToValueToRemove, this._valuesInfo); - break; - } - indexToValueToRemove = this._valuesInfo[indexToValueToRemove].previous; - } - if (indexToValueToRemove == -1) - return false; - this._freeValueCellIndex--; - if (indexToValueToRemove != this._freeValueCellIndex) { - var movingBucketIndex = FasterDictionary.reduce(this._valuesInfo[this._freeValueCellIndex].hashcode, this._buckets.length); - if (this._buckets[movingBucketIndex] - 1 == this._freeValueCellIndex) - this._buckets[movingBucketIndex] = (indexToValueToRemove + 1); - var next = this._valuesInfo[this._freeValueCellIndex].next; - var previous = this._valuesInfo[this._freeValueCellIndex].previous; - if (next != -1) - this._valuesInfo[next].previous = indexToValueToRemove; - if (previous != -1) - this._valuesInfo[previous].next = indexToValueToRemove; - this._valuesInfo[indexToValueToRemove] = this._valuesInfo[this._freeValueCellIndex]; - this._values[indexToValueToRemove] = this._values[this._freeValueCellIndex]; - } - return true; - }; - FasterDictionary.prototype.trim = function () { - var expandPrime = es.HashHelpers.expandPrime(this._freeValueCellIndex); - if (expandPrime < this._valuesInfo.length) { - this._values.length = expandPrime; - this._valuesInfo.length = expandPrime; - } - }; - FasterDictionary.prototype.clear = function () { - if (this._freeValueCellIndex == 0) - return; - this._freeValueCellIndex = 0; - this._buckets.length = 0; - this._values.length = 0; - this._valuesInfo.length = 0; - }; - FasterDictionary.prototype.fastClear = function () { - if (this._freeValueCellIndex == 0) - return; - this._freeValueCellIndex = 0; - this._buckets.length = 0; - this._valuesInfo.length = 0; - }; - FasterDictionary.prototype.containsKey = function (key) { - if (this.tryFindIndex(key, { value: 0 })) { - return true; - } - return false; - }; - FasterDictionary.prototype.tryGetValue = function (key) { - var findIndex = { value: 0 }; - if (this.tryFindIndex(key, findIndex)) { - return this._values[findIndex.value]; - } - return null; - }; - FasterDictionary.prototype.tryFindIndex = function (key, findIndex) { - var hash = FasterDictionary.hash(key); - var bucketIndex = FasterDictionary.reduce(hash, this._buckets.length); - var valueIndex = es.NumberExtension.toNumber(this._buckets[bucketIndex]) - 1; - while (valueIndex != -1) { - if (this._valuesInfo[valueIndex].hashcode == hash && this._valuesInfo[valueIndex].key == key) { - findIndex.value = valueIndex; - return true; - } - valueIndex = this._valuesInfo[valueIndex].previous; - } - findIndex.value = 0; - return false; - }; - FasterDictionary.prototype.getDirectValue = function (index) { - return this._values[index]; - }; - FasterDictionary.prototype.getIndex = function (key) { - var findIndex = { value: 0 }; - if (this.tryFindIndex(key, findIndex)) - return findIndex.value; - throw new Error("未找到key"); - }; - FasterDictionary.updateLinkedList = function (index, valuesInfo) { - var next = valuesInfo[index].next; - var previous = valuesInfo[index].previous; - if (next != -1) - valuesInfo[next].previous = previous; - if (previous != -1) - valuesInfo[previous].next = next; - }; - FasterDictionary.hash = function (key) { - return es.HashHelpers.getHashCode(key); - }; - FasterDictionary.reduce = function (x, n) { - if (x >= n) - return x % n; - return x; - }; - return FasterDictionary; - }()); - es.FasterDictionary = FasterDictionary; - var FastNode = (function () { - function FastNode(key, hash, previousNode) { - if (previousNode === void 0) { previousNode = -1; } - this.key = key; - this.hashcode = hash; - this.previous = previousNode; - this.next = -1; - } - return FastNode; - }()); - es.FastNode = FastNode; -})(es || (es = {})); -var es; -(function (es) { - var FastList = (function () { - function FastList(size) { - if (size === void 0) { size = 5; } - this.length = 0; - this.buffer = new Array(size); - } - FastList.prototype.clear = function () { - this.buffer.length = 0; - this.length = 0; - }; - FastList.prototype.reset = function () { - this.length = 0; - }; - FastList.prototype.add = function (item) { - if (this.length == this.buffer.length) - this.buffer.length = Math.max(this.buffer.length << 1, 10); - this.buffer[this.length++] = item; - }; - FastList.prototype.remove = function (item) { - var comp = es.EqualityComparer.default(); - for (var i = 0; i < this.length; ++i) { - if (comp.equals(this.buffer[i], item)) { - this.removeAt(i); - return; - } - } - }; - FastList.prototype.removeAt = function (index) { - if (index >= this.length) - throw new Error("index超出范围!"); - this.length--; - this.buffer.removeAt(index); - }; - FastList.prototype.contains = function (item) { - var comp = es.EqualityComparer.default(); - for (var i = 0; i < this.length; ++i) { - if (comp.equals(this.buffer[i], item)) - return true; - } - return false; - }; - FastList.prototype.ensureCapacity = function (additionalItemCount) { - if (additionalItemCount === void 0) { additionalItemCount = 1; } - if (this.length + additionalItemCount >= this.buffer.length) - this.buffer.length = Math.max(this.buffer.length << 1, this.length + additionalItemCount); - }; - FastList.prototype.addRange = function (array) { - for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { - var item = array_1[_i]; - this.add(item); - } - }; - FastList.prototype.sort = function (comparer) { - this.buffer.sort(comparer.compare); - }; - return FastList; - }()); - es.FastList = FastList; -})(es || (es = {})); -var es; -(function (es) { - var HashHelpers = (function () { - function HashHelpers() { - } - HashHelpers.isPrime = function (candidate) { - if ((candidate & 1) != 0) { - var limit = Math.sqrt(candidate); - for (var divisor = 3; divisor <= limit; divisor += 2) { - if ((candidate & divisor) == 0) - return false; - } - return true; - } - return (candidate == 2); - }; - HashHelpers.getPrime = function (min) { - if (min < 0) - throw new Error("参数错误 min不能小于0"); - for (var i = 0; i < this.primes.length; i++) { - var prime = this.primes[i]; - if (prime >= min) - return prime; - } - for (var i = (min | 1); i < Number.MAX_VALUE; i += 2) { - if (this.isPrime(i) && ((i - 1) % this.hashPrime != 0)) - return i; - } - return min; - }; - HashHelpers.expandPrime = function (oldSize) { - var newSize = 2 * oldSize; - if (newSize > this.maxPrimeArrayLength && this.maxPrimeArrayLength > oldSize) { - return this.maxPrimeArrayLength; - } - return this.getPrime(newSize); - }; - HashHelpers.getHashCode = function (str) { - var s; - if (typeof str == 'object') { - s = JSON.stringify(str); - } - else { - s = str.toString(); - } - var hash = 0; - if (s.length == 0) - return hash; - for (var i = 0; i < s.length; i++) { - var char = s.charCodeAt(i); - hash = ((hash << 5) - hash) + char; - hash = hash & hash; - } - return hash; - }; - HashHelpers.hashCollisionThreshold = 100; - HashHelpers.hashPrime = 101; - HashHelpers.primes = [3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919, - 1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591, - 17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523, 108631, 130363, 156437, - 187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263, - 1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369]; - HashHelpers.maxPrimeArrayLength = 0x7FEFFFFD; - return HashHelpers; - }()); - es.HashHelpers = HashHelpers; -})(es || (es = {})); -var es; -(function (es) { - var Matcher = (function () { - function Matcher() { - this.allSet = new es.BitSet(); - this.exclusionSet = new es.BitSet(); - this.oneSet = new es.BitSet(); - } - Matcher.empty = function () { - return new Matcher(); - }; - Matcher.prototype.getAllSet = function () { - return this.allSet; - }; - Matcher.prototype.getExclusionSet = function () { - return this.exclusionSet; - }; - Matcher.prototype.getOneSet = function () { - return this.oneSet; - }; - Matcher.prototype.IsIntersted = function (e) { - if (!this.allSet.isEmpty()) { - for (var i = this.allSet.nextSetBit(0); i >= 0; i = this.allSet.nextSetBit(i + 1)) { - if (!e.componentBits.get(i)) - return false; - } - } - if (!this.exclusionSet.isEmpty() && this.exclusionSet.intersects(e.componentBits)) - return false; - if (!this.oneSet.isEmpty() && !this.oneSet.intersects(e.componentBits)) - return false; - return true; - }; - Matcher.prototype.all = function () { - var _this = this; - var types = []; - for (var _i = 0; _i < arguments.length; _i++) { - types[_i] = arguments[_i]; - } - types.forEach(function (type) { - _this.allSet.set(es.ComponentTypeManager.getIndexFor(type)); - }); - return this; - }; - Matcher.prototype.exclude = function () { - var _this = this; - var types = []; - for (var _i = 0; _i < arguments.length; _i++) { - types[_i] = arguments[_i]; - } - types.forEach(function (type) { - _this.exclusionSet.set(es.ComponentTypeManager.getIndexFor(type)); - }); - return this; - }; - Matcher.prototype.one = function () { - var _this = this; - var types = []; - for (var _i = 0; _i < arguments.length; _i++) { - types[_i] = arguments[_i]; - } - types.forEach(function (type) { - _this.oneSet.set(es.ComponentTypeManager.getIndexFor(type)); - }); - return this; - }; - return Matcher; - }()); - es.Matcher = Matcher; -})(es || (es = {})); -var ObjectUtils = (function () { - function ObjectUtils() { - } - ObjectUtils.clone = function (p, c) { - if (c === void 0) { c = null; } - var c = c || {}; - for (var i in p) { - if (typeof p[i] === 'object') { - c[i] = p[i] instanceof Array ? [] : {}; - this.clone(p[i], c[i]); - } - else { - c[i] = p[i]; - } - } - return c; - }; - ObjectUtils.elements = function (p) { - var c = []; - for (var i in p) { - if (Array.isArray(p[i])) { - for (var _i = 0, _a = p[i]; _i < _a.length; _i++) { - var v = _a[_i]; - c.push(v); - } - } - else { - c.push(p[i]); - } - } - return c; - }; - return ObjectUtils; -}()); -var es; -(function (es) { - var RenderableComparer = (function () { - function RenderableComparer() { - } - RenderableComparer.prototype.compare = function (self, other) { - return other.renderLayer - self.renderLayer; - }; - return RenderableComparer; - }()); - es.RenderableComparer = RenderableComparer; -})(es || (es = {})); -var es; -(function (es) { - var RenderableComponentList = (function () { - function RenderableComponentList() { - this._components = []; - this._componentsByRenderLayer = new Map(); - this._unsortedRenderLayers = []; - this._componentsNeedSort = true; - } - Object.defineProperty(RenderableComponentList.prototype, "componentsNeedSort", { - get: function () { - return this._componentsNeedSort; - }, - set: function (value) { - this._componentsNeedSort = value; - es.Core.scene.sortableChildren = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponentList.prototype, "count", { - get: function () { - return this._components.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponentList.prototype, "buffer", { - get: function () { - return this._components; - }, - enumerable: true, - configurable: true - }); - RenderableComponentList.prototype.add = function (component) { - this._components.push(component); - this.addToRenderLayerList(component, component.renderLayer); - }; - RenderableComponentList.prototype.remove = function (component) { - this._components.remove(component); - this._componentsByRenderLayer.get(component.renderLayer).remove(component); - }; - RenderableComponentList.prototype.updateRenderableRenderLayer = function (component, oldRenderLayer, newRenderLayer) { - if (this._componentsByRenderLayer.has(oldRenderLayer) && this._componentsByRenderLayer.get(oldRenderLayer).contains(component)) { - this._componentsByRenderLayer.get(oldRenderLayer).remove(component); - this.addToRenderLayerList(component, newRenderLayer); - } - }; - RenderableComponentList.prototype.setRenderLayerNeedsComponentSort = function (renderLayer) { - if (!this._unsortedRenderLayers.contains(renderLayer)) - this._unsortedRenderLayers.push(renderLayer); - this.componentsNeedSort = true; - }; - RenderableComponentList.prototype.setNeedsComponentSort = function () { - this.componentsNeedSort = true; - }; - RenderableComponentList.prototype.addToRenderLayerList = function (component, renderLayer) { - var list = this.componentsWithRenderLayer(renderLayer); - if (list.contains(component)) { - console.warn("组件呈现层列表已经包含此组件"); - return; - } - list.push(component); - if (!this._unsortedRenderLayers.contains(renderLayer)) - this._unsortedRenderLayers.push(renderLayer); - this.componentsNeedSort = true; - }; - RenderableComponentList.prototype.componentsWithRenderLayer = function (renderLayer) { - if (!this._componentsByRenderLayer.get(renderLayer)) { - this._componentsByRenderLayer.set(renderLayer, []); - } - return this._componentsByRenderLayer.get(renderLayer); - }; - RenderableComponentList.prototype.updateList = function () { - if (this.componentsNeedSort) { - this._components.sort(RenderableComponentList.compareUpdatableOrder.compare); - this.componentsNeedSort = false; - } - if (this._unsortedRenderLayers.length > 0) { - for (var i = 0, count = this._unsortedRenderLayers.length; i < count; i++) { - var renderLayerComponents = this._componentsByRenderLayer.get(this._unsortedRenderLayers[i]); - if (renderLayerComponents) { - renderLayerComponents.sort(RenderableComponentList.compareUpdatableOrder.compare); - } - } - this._unsortedRenderLayers.length = 0; - } - }; - RenderableComponentList.compareUpdatableOrder = new es.RenderableComparer(); - return RenderableComponentList; - }()); - es.RenderableComponentList = RenderableComponentList; -})(es || (es = {})); -var StringUtils = (function () { - function StringUtils() { - } - StringUtils.matchChineseWord = function (str) { - var patternA = /[\u4E00-\u9FA5]+/gim; - return str.match(patternA); - }; - StringUtils.lTrim = function (target) { - var startIndex = 0; - while (this.isWhiteSpace(target.charAt(startIndex))) { - startIndex++; - } - return target.slice(startIndex, target.length); - }; - StringUtils.rTrim = function (target) { - var endIndex = target.length - 1; - while (this.isWhiteSpace(target.charAt(endIndex))) { - endIndex--; - } - return target.slice(0, endIndex + 1); - }; - StringUtils.trim = function (target) { - if (target == null) { - return null; - } - return this.rTrim(this.lTrim(target)); - }; - StringUtils.isWhiteSpace = function (str) { - if (str == " " || str == "\t" || str == "\r" || str == "\n") - return true; - return false; - }; - StringUtils.replaceMatch = function (mainStr, targetStr, replaceStr, caseMark) { - if (caseMark === void 0) { caseMark = false; } - var len = mainStr.length; - var tempStr = ""; - var isMatch = false; - var tempTarget = caseMark == true ? targetStr.toLowerCase() : targetStr; - for (var i = 0; i < len; i++) { - isMatch = false; - if (mainStr.charAt(i) == tempTarget.charAt(0)) { - if (mainStr.substr(i, tempTarget.length) == tempTarget) { - isMatch = true; - } - } - if (isMatch) { - tempStr += replaceStr; - i = i + tempTarget.length - 1; - } - else { - tempStr += mainStr.charAt(i); - } - } - return tempStr; - }; - StringUtils.htmlSpecialChars = function (str, reversion) { - if (reversion === void 0) { reversion = false; } - var len = this.specialSigns.length; - for (var i = 0; i < len; i += 2) { - var from = void 0; - var to = void 0; - from = this.specialSigns[i]; - to = this.specialSigns[i + 1]; - if (reversion) { - var temp = from; - from = to; - to = temp; - } - str = this.replaceMatch(str, from, to); - } - return str; - }; - StringUtils.zfill = function (str, width) { - if (width === void 0) { width = 2; } - if (!str) { - return str; - } - width = Math.floor(width); - var slen = str.length; - if (slen >= width) { - return str; - } - var negative = false; - if (str.substr(0, 1) == '-') { - negative = true; - str = str.substr(1); - } - var len = width - slen; - for (var i = 0; i < len; i++) { - str = '0' + str; - } - if (negative) { - str = '-' + str; - } - return str; - }; - StringUtils.reverse = function (str) { - if (str.length > 1) - return this.reverse(str.substring(1)) + str.substring(0, 1); - else - return str; - }; - StringUtils.cutOff = function (str, start, len, order) { - if (order === void 0) { order = true; } - start = Math.floor(start); - len = Math.floor(len); - var length = str.length; - if (start > length) - start = length; - var s = start; - var e = start + len; - var newStr; - if (order) { - newStr = str.substring(0, s) + str.substr(e, length); - } - else { - s = length - 1 - start - len; - e = s + len; - newStr = str.substring(0, s + 1) + str.substr(e + 1, length); - } - return newStr; - }; - StringUtils.strReplace = function (str, rStr) { - var i = 0, len = rStr.length; - for (; i < len; i++) { - if (rStr[i] == null || rStr[i] == "") { - rStr[i] = "无"; - } - str = str.replace("{" + i + "}", rStr[i]); - } - return str; - }; - StringUtils.specialSigns = [ - '&', '&', - '<', '<', - '>', '>', - '"', '"', - "'", ''', - '®', '®', - '©', '©', - '™', '™', - ]; - return StringUtils; -}()); -var es; -(function (es) { - var TextureUtils = (function () { - function TextureUtils() { - } - TextureUtils.convertImageToCanvas = function (texture, rect) { - if (!this.sharedCanvas) { - this.sharedCanvas = egret.sys.createCanvas(); - this.sharedContext = this.sharedCanvas.getContext("2d"); - } - var w = texture.$getTextureWidth(); - var h = texture.$getTextureHeight(); - if (!rect) { - rect = egret.$TempRectangle; - rect.x = 0; - rect.y = 0; - rect.width = w; - rect.height = h; - } - rect.x = Math.min(rect.x, w - 1); - rect.y = Math.min(rect.y, h - 1); - rect.width = Math.min(rect.width, w - rect.x); - rect.height = Math.min(rect.height, h - rect.y); - var iWidth = Math.floor(rect.width); - var iHeight = Math.floor(rect.height); - var surface = this.sharedCanvas; - surface["style"]["width"] = iWidth + "px"; - surface["style"]["height"] = iHeight + "px"; - this.sharedCanvas.width = iWidth; - this.sharedCanvas.height = iHeight; - if (egret.Capabilities.renderMode == "webgl") { - var renderTexture = void 0; - if (!texture.$renderBuffer) { - if (egret.sys.systemRenderer["renderClear"]) { - egret.sys.systemRenderer["renderClear"](); - } - renderTexture = new egret.RenderTexture(); - renderTexture.drawToTexture(new egret.Bitmap(texture)); - } - else { - renderTexture = texture; - } - var pixels = renderTexture.$renderBuffer.getPixels(rect.x, rect.y, iWidth, iHeight); - var x = 0; - var y = 0; - for (var i = 0; i < pixels.length; i += 4) { - this.sharedContext.fillStyle = - 'rgba(' + pixels[i] - + ',' + pixels[i + 1] - + ',' + pixels[i + 2] - + ',' + (pixels[i + 3] / 255) + ')'; - this.sharedContext.fillRect(x, y, 1, 1); - x++; - if (x == iWidth) { - x = 0; - y++; - } - } - if (!texture.$renderBuffer) { - renderTexture.dispose(); - } - return surface; - } - else { - var bitmapData = texture; - var offsetX = Math.round(bitmapData.$offsetX); - var offsetY = Math.round(bitmapData.$offsetY); - var bitmapWidth = bitmapData.$bitmapWidth; - var bitmapHeight = bitmapData.$bitmapHeight; - var $TextureScaleFactor = es.Core._instance.stage.textureScaleFactor; - this.sharedContext.drawImage(bitmapData.$bitmapData.source, bitmapData.$bitmapX + rect.x / $TextureScaleFactor, bitmapData.$bitmapY + rect.y / $TextureScaleFactor, bitmapWidth * rect.width / w, bitmapHeight * rect.height / h, offsetX, offsetY, rect.width, rect.height); - return surface; - } - }; - TextureUtils.toDataURL = function (type, texture, rect, encoderOptions) { - try { - var surface = this.convertImageToCanvas(texture, rect); - var result = surface.toDataURL(type, encoderOptions); - return result; - } - catch (e) { - egret.$error(1033); - } - return null; - }; - TextureUtils.eliFoTevas = function (type, texture, filePath, rect, encoderOptions) { - var surface = this.convertImageToCanvas(texture, rect); - var result = surface.toTempFilePathSync({ - fileType: type.indexOf("png") >= 0 ? "png" : "jpg" - }); - wx.getFileSystemManager().saveFile({ - tempFilePath: result, - filePath: wx.env.USER_DATA_PATH + "/" + filePath, - success: function (res) { - } - }); - return result; - }; - TextureUtils.getPixel32 = function (texture, x, y) { - egret.$warn(1041, "getPixel32", "getPixels"); - return texture.getPixels(x, y); - }; - TextureUtils.getPixels = function (texture, x, y, width, height) { - if (width === void 0) { width = 1; } - if (height === void 0) { height = 1; } - if (egret.Capabilities.renderMode == "webgl") { - var renderTexture = void 0; - if (!texture.$renderBuffer) { - renderTexture = new egret.RenderTexture(); - renderTexture.drawToTexture(new egret.Bitmap(texture)); - } - else { - renderTexture = texture; - } - var pixels = renderTexture.$renderBuffer.getPixels(x, y, width, height); - return pixels; - } - try { - var surface = this.convertImageToCanvas(texture); - var result = this.sharedContext.getImageData(x, y, width, height).data; - return result; - } - catch (e) { - egret.$error(1039); - } - }; - return TextureUtils; - }()); - es.TextureUtils = TextureUtils; -})(es || (es = {})); -var es; -(function (es) { - var Time = (function () { - function Time() { - } - Time.update = function (currentTime) { - var dt = (currentTime - this._lastTime) / 1000; - this.deltaTime = dt * this.timeScale; - this.unscaledDeltaTime = dt; - this._timeSinceSceneLoad += dt; - this.frameCount++; - this._lastTime = currentTime; - }; - Time.sceneChanged = function () { - this._timeSinceSceneLoad = 0; - }; - Time.checkEvery = function (interval) { - return Math.floor(this._timeSinceSceneLoad / interval) > Math.floor((this._timeSinceSceneLoad - this.deltaTime) / interval); - }; - Time.deltaTime = 0; - Time.timeScale = 1; - Time.frameCount = 0; - Time._lastTime = 0; - return Time; - }()); - es.Time = Time; -})(es || (es = {})); -var TimeUtils = (function () { - function TimeUtils() { - } - TimeUtils.monthId = function (d) { - if (d === void 0) { d = null; } - d = d ? d : new Date(); - var y = d.getFullYear(); - var m = d.getMonth() + 1; - var g = m < 10 ? "0" : ""; - return parseInt(y + g + m); - }; - TimeUtils.dateId = function (t) { - if (t === void 0) { t = null; } - t = t ? t : new Date(); - var m = t.getMonth() + 1; - var a = m < 10 ? "0" : ""; - var d = t.getDate(); - var b = d < 10 ? "0" : ""; - return parseInt(t.getFullYear() + a + m + b + d); - }; - TimeUtils.weekId = function (d, first) { - if (d === void 0) { d = null; } - if (first === void 0) { first = true; } - d = d ? d : new Date(); - var c = new Date(); - c.setTime(d.getTime()); - c.setDate(1); - c.setMonth(0); - var year = c.getFullYear(); - var firstDay = c.getDay(); - if (firstDay == 0) { - firstDay = 7; - } - var max = false; - if (firstDay <= 4) { - max = firstDay > 1; - c.setDate(c.getDate() - (firstDay - 1)); - } - else { - c.setDate(c.getDate() + 7 - firstDay + 1); - } - var num = this.diffDay(d, c, false); - if (num < 0) { - c.setDate(1); - c.setMonth(0); - c.setDate(c.getDate() - 1); - return this.weekId(c, false); - } - var week = num / 7; - var weekIdx = Math.floor(week) + 1; - if (weekIdx == 53) { - c.setTime(d.getTime()); - c.setDate(c.getDate() - 1); - var endDay = c.getDay(); - if (endDay == 0) { - endDay = 7; - } - if (first && (!max || endDay < 4)) { - c.setFullYear(c.getFullYear() + 1); - c.setDate(1); - c.setMonth(0); - return this.weekId(c, false); - } - } - var g = weekIdx > 9 ? "" : "0"; - var s = year + "00" + g + weekIdx; - return parseInt(s); - }; - TimeUtils.diffDay = function (a, b, fixOne) { - if (fixOne === void 0) { fixOne = false; } - var x = (a.getTime() - b.getTime()) / 86400000; - return fixOne ? Math.ceil(x) : Math.floor(x); - }; - TimeUtils.getFirstDayOfWeek = function (d) { - d = d ? d : new Date(); - var day = d.getDay() || 7; - return new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1 - day, 0, 0, 0, 0); - }; - TimeUtils.getFirstOfDay = function (d) { - d = d ? d : new Date(); - d.setHours(0, 0, 0, 0); - return d; - }; - TimeUtils.getNextFirstOfDay = function (d) { - return new Date(this.getFirstOfDay(d).getTime() + 86400000); - }; - TimeUtils.formatDate = function (date) { - var y = date.getFullYear(); - var m = date.getMonth() + 1; - m = m < 10 ? '0' + m : m; - var d = date.getDate(); - d = d < 10 ? ('0' + d) : d; - return y + '-' + m + '-' + d; - }; - TimeUtils.formatDateTime = function (date) { - var y = date.getFullYear(); - var m = date.getMonth() + 1; - m = m < 10 ? ('0' + m) : m; - var d = date.getDate(); - d = d < 10 ? ('0' + d) : d; - var h = date.getHours(); - var i = date.getMinutes(); - i = i < 10 ? ('0' + i) : i; - var s = date.getSeconds(); - s = s < 10 ? ('0' + s) : s; - return y + '-' + m + '-' + d + ' ' + h + ':' + i + ":" + s; - }; - TimeUtils.parseDate = function (s) { - var t = Date.parse(s); - if (!isNaN(t)) { - return new Date(Date.parse(s.replace(/-/g, "/"))); - } - else { - return new Date(); - } - }; - TimeUtils.secondToTime = function (time, partition, showHour) { - if (time === void 0) { time = 0; } - if (partition === void 0) { partition = ":"; } - if (showHour === void 0) { showHour = true; } - var hours = Math.floor(time / 3600); - var minutes = Math.floor(time % 3600 / 60); - var seconds = Math.floor(time % 3600 % 60); - var h = hours.toString(); - var m = minutes.toString(); - var s = seconds.toString(); - if (hours < 10) - h = "0" + h; - if (minutes < 10) - m = "0" + m; - if (seconds < 10) - s = "0" + s; - var timeStr; - if (showHour) - timeStr = h + partition + m + partition + s; - else - timeStr = m + partition + s; - return timeStr; - }; - TimeUtils.timeToMillisecond = function (time, partition) { - if (partition === void 0) { partition = ":"; } - var _ary = time.split(partition); - var timeNum = 0; - var len = _ary.length; - for (var i = 0; i < len; i++) { - var n = _ary[i]; - timeNum += n * Math.pow(60, (len - 1 - i)); - } - timeNum *= 1000; - return timeNum.toString(); - }; - return TimeUtils; -}()); -var es; -(function (es) { - var Graphics = (function () { - function Graphics() { - var _this = this; - var arrayBuffer = new ArrayBuffer(1); - arrayBuffer[0] = 0xffffff; - egret.BitmapData.create("arraybuffer", arrayBuffer, function (bitmapData) { - var tex = new egret.Texture(); - tex.bitmapData = bitmapData; - _this.pixelTexture = new es.Sprite(tex); - }); - } - return Graphics; - }()); - es.Graphics = Graphics; -})(es || (es = {})); -var es; -(function (es) { - var GraphicsCapabilities = (function (_super) { - __extends(GraphicsCapabilities, _super); - function GraphicsCapabilities() { - return _super !== null && _super.apply(this, arguments) || this; - } - GraphicsCapabilities.prototype.initialize = function (device) { - this.platformInitialize(device); - }; - GraphicsCapabilities.prototype.platformInitialize = function (device) { - if (GraphicsCapabilities.runtimeType != egret.RuntimeType.WXGAME) - return; - var capabilities = this; - capabilities["isMobile"] = true; - var systemInfo = wx.getSystemInfoSync(); - var systemStr = systemInfo.system.toLowerCase(); - if (systemStr.indexOf("ios") > -1) { - capabilities["os"] = "iOS"; - } - else if (systemStr.indexOf("android") > -1) { - capabilities["os"] = "Android"; - } - var language = systemInfo.language; - if (language.indexOf('zh') > -1) { - language = "zh-CN"; - } - else { - language = "en-US"; - } - capabilities["language"] = language; - }; - return GraphicsCapabilities; - }(egret.Capabilities)); - es.GraphicsCapabilities = GraphicsCapabilities; -})(es || (es = {})); -var es; -(function (es) { - var GraphicsDevice = (function () { - function GraphicsDevice() { - this.setup(); - this.graphicsCapabilities = new es.GraphicsCapabilities(); - this.graphicsCapabilities.initialize(this); - } - Object.defineProperty(GraphicsDevice.prototype, "viewport", { - get: function () { - return this._viewport; - }, - enumerable: true, - configurable: true - }); - GraphicsDevice.prototype.setup = function () { - this._viewport = new es.Viewport(0, 0, es.Core._instance.stage.stageWidth, es.Core._instance.stage.stageHeight); - }; - return GraphicsDevice; - }()); - es.GraphicsDevice = GraphicsDevice; -})(es || (es = {})); -var es; -(function (es) { - var Viewport = (function () { - function Viewport(x, y, width, height) { - this._x = x; - this._y = y; - this._width = width; - this._height = height; - this._minDepth = 0; - this._maxDepth = 1; - } - Object.defineProperty(Viewport.prototype, "width", { - get: function () { - return this._width; - }, - set: function (value) { - this._width = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Viewport.prototype, "height", { - get: function () { - return this._height; - }, - set: function (value) { - this._height = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Viewport.prototype, "aspectRatio", { - get: function () { - if ((this._height != 0) && (this._width != 0)) - return (this._width / this._height); - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Viewport.prototype, "bounds", { - get: function () { - return new es.Rectangle(this._x, this._y, this._width, this._height); - }, - set: function (value) { - this._x = value.x; - this._y = value.y; - this._width = value.width; - this._height = value.height; - }, - enumerable: true, - configurable: true - }); - return Viewport; - }()); - es.Viewport = Viewport; -})(es || (es = {})); -var es; -(function (es) { - var GaussianBlurEffect = (function (_super) { - __extends(GaussianBlurEffect, _super); - function GaussianBlurEffect() { - return _super.call(this, es.PostProcessor.default_vert, GaussianBlurEffect.blur_frag, { - screenWidth: es.Core.graphicsDevice.viewport.width, - screenHeight: es.Core.graphicsDevice.viewport.height - }) || this; - } - GaussianBlurEffect.blur_frag = "precision mediump float;\n" + - "uniform sampler2D uSampler;\n" + - "uniform float screenWidth;\n" + - "uniform float screenHeight;\n" + - "float normpdf(in float x, in float sigma)\n" + - "{\n" + - "return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n" + - "}\n" + - "void main()\n" + - "{\n" + - "vec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\n" + - "const int mSize = 11;\n" + - "const int kSize = (mSize - 1)/2;\n" + - "float kernel[mSize];\n" + - "vec3 final_colour = vec3(0.0);\n" + - "float sigma = 7.0;\n" + - "float z = 0.0;\n" + - "for (int j = 0; j <= kSize; ++j)\n" + - "{\n" + - "kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n" + - "}\n" + - "for (int j = 0; j < mSize; ++j)\n" + - "{\n" + - "z += kernel[j];\n" + - "}\n" + - "for (int i = -kSize; i <= kSize; ++i)\n" + - "{\n" + - "for (int j = -kSize; j <= kSize; ++j)\n" + - "{\n" + - "final_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n" + - "}\n}\n" + - "gl_FragColor = vec4(final_colour/(z*z), 1.0);\n" + - "}"; - return GaussianBlurEffect; - }(egret.CustomFilter)); - es.GaussianBlurEffect = GaussianBlurEffect; -})(es || (es = {})); -var es; -(function (es) { - var PolygonLightEffect = (function (_super) { - __extends(PolygonLightEffect, _super); - function PolygonLightEffect() { - return _super.call(this, PolygonLightEffect.vertSrc, PolygonLightEffect.fragmentSrc) || this; - } - PolygonLightEffect.vertSrc = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - "uniform vec2 projectionVector;\n" + - "varying vec2 vTextureCoord;\n" + - "const vec2 center = vec2(-1.0, 1.0);\n" + - "void main(void) {\n" + - " gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - " vTextureCoord = aTextureCoord;\n" + - "}"; - PolygonLightEffect.fragmentSrc = "precision lowp float;\n" + - "varying vec2 vTextureCoord;\n" + - "uniform sampler2D uSampler;\n" + - "#define SAMPLE_COUNT 15\n" + - "uniform vec2 _sampleOffsets[SAMPLE_COUNT];\n" + - "uniform float _sampleWeights[SAMPLE_COUNT];\n" + - "void main(void) {\n" + - "vec4 c = vec4(0, 0, 0, 0);\n" + - "for( int i = 0; i < SAMPLE_COUNT; i++ )\n" + - " c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\n" + - "gl_FragColor = c;\n" + - "}"; - return PolygonLightEffect; - }(egret.CustomFilter)); - es.PolygonLightEffect = PolygonLightEffect; -})(es || (es = {})); -var es; -(function (es) { - var PostProcessor = (function () { - function PostProcessor(effect) { - if (effect === void 0) { effect = null; } - this.enabled = true; - this.effect = effect; - } - PostProcessor.prototype.onAddedToScene = function (scene) { - this.scene = scene; - this.shape = new egret.Shape(); - this.shape.graphics.beginFill(0xFFFFFF, 1); - this.shape.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this.shape.graphics.endFill(); - scene.addChild(this.shape); - }; - PostProcessor.prototype.process = function () { - this.drawFullscreenQuad(); - }; - PostProcessor.prototype.onSceneBackBufferSizeChanged = function (newWidth, newHeight) { - }; - PostProcessor.prototype.unload = function () { - if (this.effect) { - this.effect = null; - } - this.scene.removeChild(this.shape); - this.scene = null; - }; - PostProcessor.prototype.drawFullscreenQuad = function () { - this.scene.filters = [this.effect]; - }; - PostProcessor.default_vert = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - "attribute vec2 aColor;\n" + - "uniform vec2 projectionVector;\n" + - "varying vec2 vTextureCoord;\n" + - "varying vec4 vColor;\n" + - "const vec2 center = vec2(-1.0, 1.0);\n" + - "void main(void) {\n" + - "gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - "vTextureCoord = aTextureCoord;\n" + - "vColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n" + - "}"; - return PostProcessor; - }()); - es.PostProcessor = PostProcessor; -})(es || (es = {})); -var es; -(function (es) { - var GaussianBlurPostProcessor = (function (_super) { - __extends(GaussianBlurPostProcessor, _super); - function GaussianBlurPostProcessor() { - return _super !== null && _super.apply(this, arguments) || this; - } - GaussianBlurPostProcessor.prototype.onAddedToScene = function (scene) { - _super.prototype.onAddedToScene.call(this, scene); - this.effect = new es.GaussianBlurEffect(); - }; - return GaussianBlurPostProcessor; - }(es.PostProcessor)); - es.GaussianBlurPostProcessor = GaussianBlurPostProcessor; -})(es || (es = {})); -var es; -(function (es) { - var Renderer = (function () { - function Renderer(renderOrder, camera) { - if (camera === void 0) { camera = null; } - this.renderOrder = 0; - this.shouldDebugRender = true; - this.camera = camera; - this.renderOrder = renderOrder; - } - Object.defineProperty(Renderer.prototype, "wantsToRenderToSceneRenderTarget", { - get: function () { - return !!this.renderTexture; - }, - enumerable: true, - configurable: true - }); - Renderer.prototype.onAddedToScene = function (scene) { - }; - Renderer.prototype.unload = function () { - }; - Renderer.prototype.onSceneBackBufferSizeChanged = function (newWidth, newHeight) { - }; - Renderer.prototype.compareTo = function (other) { - return this.renderOrder - other.renderOrder; - }; - Renderer.prototype.beginRender = function (cam) { - }; - Renderer.prototype.renderAfterStateCheck = function (renderable, cam) { - renderable.render(cam); - }; - Renderer.prototype.debugRender = function (scene, cam) { - for (var i = 0; i < scene.entities.count; i++) { - var entity = scene.entities.buffer[i]; - if (entity.enabled) - entity.debugRender(cam); - } - }; - return Renderer; - }()); - es.Renderer = Renderer; -})(es || (es = {})); -var es; -(function (es) { - var DefaultRenderer = (function (_super) { - __extends(DefaultRenderer, _super); - function DefaultRenderer() { - return _super.call(this, 0, null) || this; - } - DefaultRenderer.prototype.render = function (scene) { - var cam = this.camera ? this.camera : scene.camera; - this.beginRender(cam); - for (var i = 0; i < scene.renderableComponents.count; i++) { - var renderable = scene.renderableComponents.buffer[i]; - if (renderable.enabled && renderable.isVisibleFromCamera(cam)) - this.renderAfterStateCheck(renderable, cam); - } - }; - return DefaultRenderer; - }(es.Renderer)); - es.DefaultRenderer = DefaultRenderer; -})(es || (es = {})); -var es; -(function (es) { - var RenderLayerExcludeRenderer = (function (_super) { - __extends(RenderLayerExcludeRenderer, _super); - function RenderLayerExcludeRenderer(renderOrder) { - var excludedRenderLayers = []; - for (var _i = 1; _i < arguments.length; _i++) { - excludedRenderLayers[_i - 1] = arguments[_i]; - } - var _this = _super.call(this, renderOrder, null) || this; - _this.excludedRenderLayers = excludedRenderLayers; - return _this; - } - RenderLayerExcludeRenderer.prototype.render = function (scene) { - var cam = this.camera ? this.camera : scene.camera; - this.beginRender(cam); - for (var i = 0; i < scene.renderableComponents.count; i++) { - var renderable = scene.renderableComponents.buffer[i]; - if (!this.excludedRenderLayers.contains(renderable.renderLayer) && renderable.enabled && - renderable.isVisibleFromCamera(cam)) - this.renderAfterStateCheck(renderable, cam); - } - if (this.shouldDebugRender && es.Core.debugRenderEndabled) - this.debugRender(scene, cam); - }; - RenderLayerExcludeRenderer.prototype.debugRender = function (scene, cam) { - for (var i = 0; i < scene.renderableComponents.count; i++) { - var renderable = scene.renderableComponents.buffer[i]; - if (!this.excludedRenderLayers.contains(renderable.renderLayer) && renderable.enabled && - renderable.isVisibleFromCamera(cam)) - renderable.debugRender(cam); - } - _super.prototype.debugRender.call(this, scene, cam); - }; - return RenderLayerExcludeRenderer; - }(es.Renderer)); - es.RenderLayerExcludeRenderer = RenderLayerExcludeRenderer; -})(es || (es = {})); -var es; -(function (es) { - var ScreenSpaceRenderer = (function (_super) { - __extends(ScreenSpaceRenderer, _super); - function ScreenSpaceRenderer(renderOrder) { - var renderLayers = []; - for (var _i = 1; _i < arguments.length; _i++) { - renderLayers[_i - 1] = arguments[_i]; - } - var _this = _super.call(this, renderOrder, null) || this; - renderLayers.sort(); - renderLayers.reverse(); - _this.renderLayers = renderLayers; - return _this; - } - ScreenSpaceRenderer.prototype.render = function (scene) { - this.beginRender(this.camera); - for (var i = 0; i < this.renderLayers.length; i++) { - var renderables = scene.renderableComponents.componentsWithRenderLayer(this.renderLayers[i]); - for (var j = 0; j < renderables.length; j++) { - var renderable = renderables[j]; - if (renderable.enabled && renderable.isVisibleFromCamera(this.camera)) - this.renderAfterStateCheck(renderable, this.camera); - } - } - if (this.shouldDebugRender && es.Core.debugRenderEndabled) - this.debugRender(scene, this.camera); - }; - ScreenSpaceRenderer.prototype.debugRender = function (scene, cam) { - for (var i = 0; i < this.renderLayers.length; i++) { - var renderables = scene.renderableComponents.componentsWithRenderLayer(this.renderLayers[i]); - for (var j = 0; j < renderables.length; j++) { - var entity = renderables[j]; - if (entity.enabled) - entity.debugRender(cam); - } - } - }; - ScreenSpaceRenderer.prototype.onSceneBackBufferSizeChanged = function (newWidth, newHeight) { - _super.prototype.onSceneBackBufferSizeChanged.call(this, newWidth, newHeight); - if (!this.camera) - this.camera = es.Core.scene.createEntity("screenspace camera").addComponent(new es.Camera()); - }; - return ScreenSpaceRenderer; - }(es.Renderer)); - es.ScreenSpaceRenderer = ScreenSpaceRenderer; -})(es || (es = {})); -var es; -(function (es) { - var PolyLight = (function (_super) { - __extends(PolyLight, _super); - function PolyLight(radius, color, power) { - var _this = _super.call(this) || this; - _this._indices = []; - _this.radius = radius; - _this.power = power; - _this.color = color; - _this.computeTriangleIndices(); - return _this; - } - Object.defineProperty(PolyLight.prototype, "radius", { - get: function () { - return this._radius; - }, - set: function (value) { - this.setRadius(value); - }, - enumerable: true, - configurable: true - }); - PolyLight.prototype.setRadius = function (radius) { - if (radius != this._radius) { - this._radius = radius; - this._areBoundsDirty = true; - } - }; - PolyLight.prototype.render = function (camera) { - }; - PolyLight.prototype.reset = function () { - }; - PolyLight.prototype.computeTriangleIndices = function (totalTris) { - if (totalTris === void 0) { totalTris = 20; } - this._indices.length = 0; - for (var i = 0; i < totalTris; i += 2) { - this._indices.push(0); - this._indices.push(i + 2); - this._indices.push(i + 1); - } - }; - return PolyLight; - }(es.RenderableComponent)); - es.PolyLight = PolyLight; -})(es || (es = {})); -var es; -(function (es) { - var GaussianBlur = (function () { - function GaussianBlur() { - } - GaussianBlur.createBlurredTexture = function (image, deviation) { - if (deviation === void 0) { deviation = 1; } - var pixelData = image.getPixels(0, 0, image.textureWidth, image.textureHeight); - var srcData = new Array(image.textureWidth * image.textureHeight); - for (var i = 0; i < image.textureWidth; i++) { - for (var j = 0; j < image.textureHeight; j++) { - var width = image.textureWidth; - var r = pixelData[i * 4 + j * width]; - var g = pixelData[i * 4 + j * width + 1]; - var b = pixelData[i * 4 + j * width + 2]; - var a = pixelData[i * 4 + j * width + 3]; - srcData[i + j * width] = new es.Color(r, g, b, a); - } - } - var destData = this.createBlurredTextureData(srcData, image.textureWidth, image.textureHeight, deviation); - var arrayBuffer = new ArrayBuffer(destData.length); - destData.forEach(function (value, index) { - arrayBuffer[index] = value.packedValue; - }); - egret.BitmapData.create("arraybuffer", arrayBuffer, function (bitmapData) { - }); - }; - GaussianBlur.createBlurredTextureData = function (srcData, width, height, deviation) { - if (deviation === void 0) { deviation = 1; } - var matrixR = new es.FasterDictionary(); - var matrixG = new es.FasterDictionary(); - var matrixB = new es.FasterDictionary(); - var matrixA = new es.FasterDictionary(); - var destData = new Array(width * height); - for (var i = 0; i < width; i++) { - for (var j = 0; j < height; j++) { - matrixR.add({ x: i, y: j }, srcData[i + j * width].r); - matrixG.add({ x: i, y: j }, srcData[i + j * width].g); - matrixB.add({ x: i, y: j }, srcData[i + j * width].b); - matrixA.add({ x: i, y: j }, srcData[i + j * width].a); - } - } - matrixR = this.gaussianConvolution(matrixR, deviation); - matrixG = this.gaussianConvolution(matrixG, deviation); - matrixB = this.gaussianConvolution(matrixB, deviation); - matrixA = this.gaussianConvolution(matrixA, deviation); - for (var i = 0; i < width; i++) { - for (var j = 0; j < height; j++) { - var r = Math.min(255, matrixR.tryGetValue({ x: i, y: j })); - var g = Math.min(255, matrixG.tryGetValue({ x: i, y: j })); - var b = Math.min(255, matrixB.tryGetValue({ x: i, y: j })); - var a = Math.min(255, matrixA.tryGetValue({ x: i, y: j })); - destData[i + j * width] = new es.Color(r, g, b, a); - } - } - return destData; - }; - GaussianBlur.gaussianConvolution = function (matrix, deviation) { - var kernel = this.calculateNormalized1DSampleKernel(deviation); - var res1 = new es.FasterDictionary(); - var res2 = new es.FasterDictionary(); - for (var i = 0; i < matrix._valuesInfo.length; i++) { - for (var j = 0; j < matrix.valuesArray.length; j++) - res1.add({ x: i, y: j }, this.processPoint(matrix, i, j, kernel, 0)); - } - for (var i = 0; i < matrix._valuesInfo.length; i++) { - for (var j = 0; j < matrix.valuesArray.length; j++) - res2.add({ x: i, y: j }, this.processPoint(res1, i, j, kernel, 1)); - } - return res2; - }; - GaussianBlur.processPoint = function (matrix, x, y, kernel, direction) { - var res = 0; - var half = kernel._valuesInfo.length / 2; - for (var i = 0; i < kernel._valuesInfo.length; i++) { - var cox = direction == 0 ? x + i - half : x; - var coy = direction == 1 ? y + i - half : y; - if (cox >= 0 && cox < matrix._valuesInfo.length && coy >= 0 && coy < matrix.valuesArray.length) - res += matrix.tryGetValue({ x: cox, y: coy }) * kernel.tryGetValue({ x: i, y: 0 }); - } - return res; - }; - GaussianBlur.calculate1DSampleKernel = function (deviation) { - var size = Math.ceil(deviation * 3) * 3 + 1; - return this.calculate1DSampleKernelOfSize(deviation, size); - }; - GaussianBlur.calculate1DSampleKernelOfSize = function (deviation, size) { - var ret = new es.FasterDictionary(); - var half = (size - 1) / 2; - for (var i = 0; i < size; i++) { - ret.add({ x: i, y: 0 }, 1 / (Math.sqrt(2 * Math.PI) * deviation) * Math.exp(-(i - half) * (i - half) / (2 * deviation * deviation))); - } - return ret; - }; - GaussianBlur.calculateNormalized1DSampleKernel = function (deviation) { - return this.normalizeMatrix(this.calculate1DSampleKernel(deviation)); - }; - GaussianBlur.normalizeMatrix = function (matrix) { - var ret = new es.FasterDictionary(); - var sum = 0; - for (var i = 0; i < ret._valuesInfo.length; i++) { - for (var j = 0; j < ret.valuesArray.length; j++) { - sum += matrix.tryGetValue({ x: i, y: j }); - } - } - if (sum != 0) { - for (var i = 0; i < ret._valuesInfo.length; i++) { - for (var j = 0; j < ret.valuesArray.length; j++) { - ret.add({ x: i, y: j }, matrix.tryGetValue({ x: i, y: j }) / sum); - } - } - } - return ret; - }; - return GaussianBlur; - }()); - es.GaussianBlur = GaussianBlur; -})(es || (es = {})); -var es; -(function (es) { - var SceneTransition = (function () { - function SceneTransition(sceneLoadAction) { - this.sceneLoadAction = sceneLoadAction; - this.loadsNewScene = sceneLoadAction != null; - } - Object.defineProperty(SceneTransition.prototype, "hasPreviousSceneRender", { - get: function () { - if (!this._hasPreviousSceneRender) { - this._hasPreviousSceneRender = true; - return false; - } - return true; - }, - enumerable: true, - configurable: true - }); - SceneTransition.prototype.preRender = function () { - }; - SceneTransition.prototype.render = function () { - }; - SceneTransition.prototype.onBeginTransition = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.loadNextScene()]; - case 1: - _a.sent(); - this.transitionComplete(); - return [2]; - } - }); - }); - }; - SceneTransition.prototype.tickEffectProgressProperty = function (filter, duration, easeType, reverseDirection) { - if (reverseDirection === void 0) { reverseDirection = false; } - return new Promise(function (resolve) { - var start = reverseDirection ? 1 : 0; - var end = reverseDirection ? 0 : 1; - egret.Tween.get(filter.uniforms).set({ _progress: start }).to({ _progress: end }, duration * 1000, easeType).call(function () { - resolve(); - }); - }); - }; - SceneTransition.prototype.transitionComplete = function () { - es.Core._instance._sceneTransition = null; - if (this.onTransitionCompleted) { - this.onTransitionCompleted(); - } - }; - SceneTransition.prototype.loadNextScene = function () { - return __awaiter(this, void 0, void 0, function () { - var _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (this.onScreenObscured) - this.onScreenObscured(); - if (!this.loadsNewScene) { - this.isNewSceneLoaded = true; - } - _a = es.Core; - return [4, this.sceneLoadAction()]; - case 1: - _a.scene = _b.sent(); - this.isNewSceneLoaded = true; - return [2]; - } - }); - }); - }; - return SceneTransition; - }()); - es.SceneTransition = SceneTransition; -})(es || (es = {})); -var es; -(function (es) { - var FadeTransition = (function (_super) { - __extends(FadeTransition, _super); - function FadeTransition(sceneLoadAction) { - var _this = _super.call(this, sceneLoadAction) || this; - _this.fadeToColor = 0x000000; - _this.fadeOutDuration = 0.4; - _this.fadeEaseType = egret.Ease.quadInOut; - _this.delayBeforeFadeInDuration = 0.1; - _this._alpha = 0; - _this._mask = new egret.Shape(); - return _this; - } - FadeTransition.prototype.onBeginTransition = function () { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - if (!this._mask.parent) - es.Core.scene.stage.addChild(this._mask); - this._mask.graphics.beginFill(this.fadeToColor, 1); - this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this._mask.graphics.endFill(); - egret.Tween.get(this).to({ _alpha: 1 }, this.fadeOutDuration * 1000, this.fadeEaseType) - .call(function () { return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.loadNextScene()]; - case 1: - _a.sent(); - return [2]; - } - }); - }); }).wait(this.delayBeforeFadeInDuration).call(function () { - egret.Tween.get(_this).to({ _alpha: 0 }, _this.fadeOutDuration * 1000, _this.fadeEaseType).call(function () { - _this.transitionComplete(); - }); - }); - return [2]; - }); - }); - }; - FadeTransition.prototype.transitionComplete = function () { - _super.prototype.transitionComplete.call(this); - if (this._mask.parent) - this._mask.parent.removeChild(this._mask); - }; - FadeTransition.prototype.render = function () { - this._mask.graphics.clear(); - this._mask.graphics.beginFill(this.fadeToColor, this._alpha); - this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this._mask.graphics.endFill(); - }; - return FadeTransition; - }(es.SceneTransition)); - es.FadeTransition = FadeTransition; -})(es || (es = {})); -var es; -(function (es) { - var WindTransition = (function (_super) { - __extends(WindTransition, _super); - function WindTransition(sceneLoadAction) { - var _this = _super.call(this, sceneLoadAction) || this; - _this.duration = 1; - _this.easeType = egret.Ease.quadOut; - var vertexSrc = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - "uniform vec2 projectionVector;\n" + - "varying vec2 vTextureCoord;\n" + - "const vec2 center = vec2(-1.0, 1.0);\n" + - "void main(void) {\n" + - " gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - " vTextureCoord = aTextureCoord;\n" + - "}"; - var fragmentSrc = "precision lowp float;\n" + - "varying vec2 vTextureCoord;\n" + - "uniform sampler2D uSampler;\n" + - "uniform float _progress;\n" + - "uniform float _size;\n" + - "uniform float _windSegments;\n" + - "void main(void) {\n" + - "vec2 co = floor(vec2(0.0, vTextureCoord.y * _windSegments));\n" + - "float x = sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453;\n" + - "float r = x - floor(x);\n" + - "float m = smoothstep(0.0, -_size, vTextureCoord.x * (1.0 - _size) + _size * r - (_progress * (1.0 + _size)));\n" + - "vec4 fg = texture2D(uSampler, vTextureCoord);\n" + - "gl_FragColor = mix(fg, vec4(0, 0, 0, 0), m);\n" + - "}"; - _this._windEffect = new egret.CustomFilter(vertexSrc, fragmentSrc, { - _progress: 0, - _size: 0.3, - _windSegments: 100 - }); - _this._mask = new egret.Shape(); - _this._mask.graphics.beginFill(0xFFFFFF, 1); - _this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - _this._mask.graphics.endFill(); - _this._mask.filters = [_this._windEffect]; - es.Core.scene.stage.addChild(_this._mask); - return _this; - } - Object.defineProperty(WindTransition.prototype, "windSegments", { - set: function (value) { - this._windEffect.uniforms._windSegments = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WindTransition.prototype, "size", { - set: function (value) { - this._windEffect.uniforms._size = value; - }, - enumerable: true, - configurable: true - }); - WindTransition.prototype.onBeginTransition = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - this.loadNextScene(); - return [4, this.tickEffectProgressProperty(this._windEffect, this.duration, this.easeType)]; - case 1: - _a.sent(); - this.transitionComplete(); - return [2]; - } - }); - }); - }; - WindTransition.prototype.transitionComplete = function () { - _super.prototype.transitionComplete.call(this); - if (this._mask.parent) - this._mask.parent.removeChild(this._mask); - }; - return WindTransition; - }(es.SceneTransition)); - es.WindTransition = WindTransition; -})(es || (es = {})); -var es; -(function (es) { - var Bezier = (function () { - function Bezier() { - } - Bezier.getPoint = function (p0, p1, p2, t) { - t = es.MathHelper.clamp01(t); - var oneMinusT = 1 - t; - return es.Vector2.add(es.Vector2.add(es.Vector2.multiply(new es.Vector2(oneMinusT * oneMinusT), p0), es.Vector2.multiply(new es.Vector2(2 * oneMinusT * t), p1)), es.Vector2.multiply(new es.Vector2(t * t), p2)); - }; - Bezier.getFirstDerivative = function (p0, p1, p2, t) { - return es.Vector2.add(es.Vector2.multiply(new es.Vector2(2 * (1 - t)), es.Vector2.subtract(p1, p0)), es.Vector2.multiply(new es.Vector2(2 * t), es.Vector2.subtract(p2, p1))); - }; - Bezier.getFirstDerivativeThree = function (start, firstControlPoint, secondControlPoint, end, t) { - t = es.MathHelper.clamp01(t); - var oneMunusT = 1 - t; - return es.Vector2.add(es.Vector2.add(es.Vector2.multiply(new es.Vector2(3 * oneMunusT * oneMunusT), es.Vector2.subtract(firstControlPoint, start)), es.Vector2.multiply(new es.Vector2(6 * oneMunusT * t), es.Vector2.subtract(secondControlPoint, firstControlPoint))), es.Vector2.multiply(new es.Vector2(3 * t * t), es.Vector2.subtract(end, secondControlPoint))); - }; - Bezier.getPointThree = function (start, firstControlPoint, secondControlPoint, end, t) { - t = es.MathHelper.clamp01(t); - var oneMunusT = 1 - t; - return es.Vector2.add(es.Vector2.add(es.Vector2.add(es.Vector2.multiply(new es.Vector2(oneMunusT * oneMunusT * oneMunusT), start), es.Vector2.multiply(new es.Vector2(3 * oneMunusT * oneMunusT * t), firstControlPoint)), es.Vector2.multiply(new es.Vector2(3 * oneMunusT * t * t), secondControlPoint)), es.Vector2.multiply(new es.Vector2(t * t * t), end)); - }; - Bezier.getOptimizedDrawingPoints = function (start, firstCtrlPoint, secondCtrlPoint, end, distanceTolerance) { - if (distanceTolerance === void 0) { distanceTolerance = 1; } - var points = es.ListPool.obtain(); - points.push(start); - this.recursiveGetOptimizedDrawingPoints(start, firstCtrlPoint, secondCtrlPoint, end, points, distanceTolerance); - points.push(end); - return points; - }; - Bezier.recursiveGetOptimizedDrawingPoints = function (start, firstCtrlPoint, secondCtrlPoint, end, points, distanceTolerance) { - var pt12 = es.Vector2.divide(es.Vector2.add(start, firstCtrlPoint), new es.Vector2(2)); - var pt23 = es.Vector2.divide(es.Vector2.add(firstCtrlPoint, secondCtrlPoint), new es.Vector2(2)); - var pt34 = es.Vector2.divide(es.Vector2.add(secondCtrlPoint, end), new es.Vector2(2)); - var pt123 = es.Vector2.divide(es.Vector2.add(pt12, pt23), new es.Vector2(2)); - var pt234 = es.Vector2.divide(es.Vector2.add(pt23, pt34), new es.Vector2(2)); - var pt1234 = es.Vector2.divide(es.Vector2.add(pt123, pt234), new es.Vector2(2)); - var deltaLine = es.Vector2.subtract(end, start); - var d2 = Math.abs(((firstCtrlPoint.x, end.x) * deltaLine.y - (firstCtrlPoint.y - end.y) * deltaLine.x)); - var d3 = Math.abs(((secondCtrlPoint.x - end.x) * deltaLine.y - (secondCtrlPoint.y - end.y) * deltaLine.x)); - if ((d2 + d3) * (d2 + d3) < distanceTolerance * (deltaLine.x * deltaLine.x + deltaLine.y * deltaLine.y)) { - points.push(pt1234); - return; - } - this.recursiveGetOptimizedDrawingPoints(start, pt12, pt123, pt1234, points, distanceTolerance); - this.recursiveGetOptimizedDrawingPoints(pt1234, pt234, pt34, end, points, distanceTolerance); - }; - return Bezier; - }()); - es.Bezier = Bezier; -})(es || (es = {})); -var es; -(function (es) { - var Flags = (function () { - function Flags() { - } - Flags.isFlagSet = function (self, flag) { - return (self & flag) != 0; - }; - Flags.isUnshiftedFlagSet = function (self, flag) { - flag = 1 << flag; - return (self & flag) != 0; - }; - Flags.setFlagExclusive = function (self, flag) { - self.value = 1 << flag; - }; - Flags.setFlag = function (self, flag) { - self.value = (self.value | 1 << flag); - }; - Flags.unsetFlag = function (self, flag) { - flag = 1 << flag; - self.value = (self.value & (~flag)); - }; - Flags.invertFlags = function (self) { - self.value = ~self.value; - }; - return Flags; - }()); - es.Flags = Flags; -})(es || (es = {})); -var es; -(function (es) { - var MathHelper = (function () { - function MathHelper() { - } - MathHelper.toDegrees = function (radians) { - return radians * 57.295779513082320876798154814105; - }; - MathHelper.toRadians = function (degrees) { - return degrees * 0.017453292519943295769236907684886; - }; - MathHelper.map = function (value, leftMin, leftMax, rightMin, rightMax) { - return rightMin + (value - leftMin) * (rightMax - rightMin) / (leftMax - leftMin); - }; - MathHelper.lerp = function (value1, value2, amount) { - return value1 + (value2 - value1) * amount; - }; - MathHelper.clamp = function (value, min, max) { - if (value < min) - return min; - if (value > max) - return max; - return value; - }; - MathHelper.pointOnCirlce = function (circleCenter, radius, angleInDegrees) { - var radians = MathHelper.toRadians(angleInDegrees); - return new es.Vector2(Math.cos(radians) * radians + circleCenter.x, Math.sin(radians) * radians + circleCenter.y); - }; - MathHelper.isEven = function (value) { - return value % 2 == 0; - }; - MathHelper.clamp01 = function (value) { - if (value < 0) - return 0; - if (value > 1) - return 1; - return value; - }; - MathHelper.angleBetweenVectors = function (from, to) { - return Math.atan2(to.y - from.y, to.x - from.x); - }; - MathHelper.incrementWithWrap = function (t, length) { - t++; - if (t == length) - return 0; - return t; - }; - MathHelper.approach = function (start, end, shift) { - if (start < end) - return Math.min(start + shift, end); - return Math.max(start - shift, end); - }; - MathHelper.Epsilon = 0.00001; - MathHelper.Rad2Deg = 57.29578; - MathHelper.Deg2Rad = 0.0174532924; - MathHelper.PiOver2 = Math.PI / 2; - return MathHelper; - }()); - es.MathHelper = MathHelper; -})(es || (es = {})); -var es; -(function (es) { - es.matrixPool = []; - var Matrix2D = (function (_super) { - __extends(Matrix2D, _super); - function Matrix2D() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(Matrix2D.prototype, "m11", { - get: function () { - return this.a; - }, - set: function (value) { - this.a = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2D.prototype, "m12", { - get: function () { - return this.b; - }, - set: function (value) { - this.b = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2D.prototype, "m21", { - get: function () { - return this.c; - }, - set: function (value) { - this.c = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2D.prototype, "m22", { - get: function () { - return this.d; - }, - set: function (value) { - this.d = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2D.prototype, "m31", { - get: function () { - return this.tx; - }, - set: function (value) { - this.tx = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2D.prototype, "m32", { - get: function () { - return this.ty; - }, - set: function (value) { - this.ty = value; - }, - enumerable: true, - configurable: true - }); - Matrix2D.create = function () { - var matrix = es.matrixPool.pop(); - if (!matrix) - matrix = new Matrix2D(); - return matrix; - }; - Matrix2D.prototype.identity = function () { - this.a = this.d = 1; - this.b = this.c = this.tx = this.ty = 0; - return this; - }; - Matrix2D.prototype.translate = function (dx, dy) { - this.tx += dx; - this.ty += dy; - return this; - }; - Matrix2D.prototype.scale = function (sx, sy) { - if (sx !== 1) { - this.a *= sx; - this.c *= sx; - this.tx *= sx; - } - if (sy !== 1) { - this.b *= sy; - this.d *= sy; - this.ty *= sy; - } - return this; - }; - Matrix2D.prototype.rotate = function (angle) { - angle = +angle; - if (angle !== 0) { - angle = angle / DEG_TO_RAD; - var u = Math.cos(angle); - var v = Math.sin(angle); - var ta = this.a; - var tb = this.b; - var tc = this.c; - var td = this.d; - var ttx = this.tx; - var tty = this.ty; - this.a = ta * u - tb * v; - this.b = ta * v + tb * u; - this.c = tc * u - td * v; - this.d = tc * v + td * u; - this.tx = ttx * u - tty * v; - this.ty = ttx * v + tty * u; - } - return this; - }; - Matrix2D.prototype.invert = function () { - this.$invertInto(this); - return this; - }; - Matrix2D.prototype.add = function (matrix) { - this.m11 += matrix.m11; - this.m12 += matrix.m12; - this.m21 += matrix.m21; - this.m22 += matrix.m22; - this.m31 += matrix.m31; - this.m32 += matrix.m32; - return this; - }; - Matrix2D.prototype.substract = function (matrix) { - this.m11 -= matrix.m11; - this.m12 -= matrix.m12; - this.m21 -= matrix.m21; - this.m22 -= matrix.m22; - this.m31 -= matrix.m31; - this.m32 -= matrix.m32; - return this; - }; - Matrix2D.prototype.divide = function (matrix) { - this.m11 /= matrix.m11; - this.m12 /= matrix.m12; - this.m21 /= matrix.m21; - this.m22 /= matrix.m22; - this.m31 /= matrix.m31; - this.m32 /= matrix.m32; - return this; - }; - Matrix2D.prototype.multiply = function (matrix) { - var m11 = (this.m11 * matrix.m11) + (this.m12 * matrix.m21); - var m12 = (this.m11 * matrix.m12) + (this.m12 * matrix.m22); - var m21 = (this.m21 * matrix.m11) + (this.m22 * matrix.m21); - var m22 = (this.m21 * matrix.m12) + (this.m22 * matrix.m22); - var m31 = (this.m31 * matrix.m11) + (this.m32 * matrix.m21) + matrix.m31; - var m32 = (this.m31 * matrix.m12) + (this.m32 * matrix.m22) + matrix.m32; - this.m11 = m11; - this.m12 = m12; - this.m21 = m21; - this.m22 = m22; - this.m31 = m31; - this.m32 = m32; - return this; - }; - Matrix2D.prototype.determinant = function () { - return this.m11 * this.m22 - this.m12 * this.m21; - }; - Matrix2D.prototype.release = function (matrix) { - if (!matrix) - return; - es.matrixPool.push(matrix); - }; - return Matrix2D; - }(egret.Matrix)); - es.Matrix2D = Matrix2D; -})(es || (es = {})); -var es; -(function (es) { - var Rectangle = (function (_super) { - __extends(Rectangle, _super); - function Rectangle() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(Rectangle.prototype, "max", { - get: function () { - return new es.Vector2(this.right, this.bottom); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "center", { - get: function () { - return new es.Vector2(this.x + (this.width / 2), this.y + (this.height / 2)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "location", { - get: function () { - return new es.Vector2(this.x, this.y); - }, - set: function (value) { - this.x = value.x; - this.y = value.y; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "size", { - get: function () { - return new es.Vector2(this.width, this.height); - }, - set: function (value) { - this.width = value.x; - this.height = value.y; - }, - enumerable: true, - configurable: true - }); - Rectangle.fromMinMax = function (minX, minY, maxX, maxY) { - return new Rectangle(minX, minY, maxX - minX, maxY - minY); - }; - Rectangle.rectEncompassingPoints = function (points) { - var minX = Number.POSITIVE_INFINITY; - var minY = Number.POSITIVE_INFINITY; - var maxX = Number.NEGATIVE_INFINITY; - var maxY = Number.NEGATIVE_INFINITY; - for (var i = 0; i < points.length; i++) { - var pt = points[i]; - if (pt.x < minX) - minX = pt.x; - if (pt.x > maxX) - maxX = pt.x; - if (pt.y < minY) - minY = pt.y; - if (pt.y > maxY) - maxY = pt.y; - } - return this.fromMinMax(minX, minY, maxX, maxY); - }; - Rectangle.prototype.intersects = function (value) { - return value.left < this.right && - this.left < value.right && - value.top < this.bottom && - this.top < value.bottom; - }; - Rectangle.prototype.rayIntersects = function (ray, distance) { - distance.value = 0; - var maxValue = Number.MAX_VALUE; - if (Math.abs(ray.direction.x) < 1E-06) { - if ((ray.start.x < this.x) || (ray.start.x > this.x + this.width)) - return false; - } - else { - var num11 = 1 / ray.direction.x; - var num8 = (this.x - ray.start.x) * num11; - var num7 = (this.x + this.width - ray.start.x) * num11; - if (num8 > num7) { - var num14 = num8; - num8 = num7; - num7 = num14; - } - distance.value = Math.max(num8, distance.value); - maxValue = Math.min(num7, maxValue); - if (distance.value > maxValue) - return false; - } - if (Math.abs(ray.direction.y) < 1E-06) { - if ((ray.start.y < this.y) || (ray.start.y > this.y + this.height)) - return false; - } - else { - var num10 = 1 / ray.direction.y; - var num6 = (this.y - ray.start.y) * num10; - var num5 = (this.y + this.height - ray.start.y) * num10; - if (num6 > num5) { - var num13 = num6; - num6 = num5; - num5 = num13; - } - distance.value = Math.max(num6, distance.value); - maxValue = Math.max(num5, maxValue); - if (distance.value > maxValue) - return false; - } - return true; - }; - Rectangle.prototype.containsRect = function (value) { - return ((((this.x <= value.x) && (value.x < (this.x + this.width))) && - (this.y <= value.y)) && - (value.y < (this.y + this.height))); - }; - Rectangle.prototype.contains = function (x, y) { - return ((((this.x <= x) && (x < (this.x + this.width))) && (this.y <= y)) && (y < (this.y + this.height))); - }; - Rectangle.prototype.getHalfSize = function () { - return new es.Vector2(this.width * 0.5, this.height * 0.5); - }; - Rectangle.prototype.getClosestPointOnRectangleBorderToPoint = function (point, edgeNormal) { - edgeNormal = es.Vector2.zero; - var res = new es.Vector2(); - res.x = es.MathHelper.clamp(point.x, this.left, this.right); - res.y = es.MathHelper.clamp(point.y, this.top, this.bottom); - if (this.contains(res.x, res.y)) { - var dl = res.x - this.left; - var dr = this.right - res.x; - var dt = res.y - this.top; - var db = this.bottom - res.y; - var min = Math.min(dl, dr, dt, db); - if (min == dt) { - res.y = this.top; - edgeNormal.y = -1; - } - else if (min == db) { - res.y = this.bottom; - edgeNormal.y = 1; - } - else if (min == dl) { - res.x = this.left; - edgeNormal.x = -1; - } - else { - res.x = this.right; - edgeNormal.x = 1; - } - } - else { - if (res.x == this.left) - edgeNormal.x = -1; - if (res.x == this.right) - edgeNormal.x = 1; - if (res.y == this.top) - edgeNormal.y = -1; - if (res.y == this.bottom) - edgeNormal.y = 1; - } - return res; - }; - Rectangle.prototype.getClosestPointOnBoundsToOrigin = function () { - var max = this.max; - var minDist = Math.abs(this.location.x); - var boundsPoint = new es.Vector2(this.location.x, 0); - if (Math.abs(max.x) < minDist) { - minDist = Math.abs(max.x); - boundsPoint.x = max.x; - boundsPoint.y = 0; - } - if (Math.abs(max.y) < minDist) { - minDist = Math.abs(max.y); - boundsPoint.x = 0; - boundsPoint.y = max.y; - } - if (Math.abs(this.location.y) < minDist) { - minDist = Math.abs(this.location.y); - boundsPoint.x = 0; - boundsPoint.y = this.location.y; - } - return boundsPoint; - }; - Rectangle.prototype.calculateBounds = function (parentPosition, position, origin, scale, rotation, width, height) { - if (rotation == 0) { - this.x = parentPosition.x + position.x - origin.x * scale.x; - this.y = parentPosition.y + position.y - origin.y * scale.y; - this.width = width * scale.x; - this.height = height * scale.y; - } - else { - var worldPosX = parentPosition.x + position.x; - var worldPosY = parentPosition.y + position.y; - this._transformMat = es.Matrix2D.create().translate(-worldPosX - origin.x, -worldPosY - origin.y); - this._tempMat = es.Matrix2D.create().scale(scale.x, scale.y); - this._transformMat = this._transformMat.multiply(this._tempMat); - this._tempMat = es.Matrix2D.create().rotate(rotation); - this._transformMat = this._transformMat.multiply(this._tempMat); - this._tempMat = es.Matrix2D.create().translate(worldPosX, worldPosY); - this._transformMat = this._transformMat.multiply(this._tempMat); - var topLeft = new es.Vector2(worldPosX, worldPosY); - var topRight = new es.Vector2(worldPosX + width, worldPosY); - var bottomLeft = new es.Vector2(worldPosX, worldPosY + height); - var bottomRight = new es.Vector2(worldPosX + width, worldPosY + height); - es.Vector2Ext.transformR(topLeft, this._transformMat, topLeft); - es.Vector2Ext.transformR(topRight, this._transformMat, topRight); - es.Vector2Ext.transformR(bottomLeft, this._transformMat, bottomLeft); - es.Vector2Ext.transformR(bottomRight, this._transformMat, bottomRight); - var minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - var maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - var minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - var maxY = Math.max(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - this.location = new es.Vector2(minX, minY); - this.width = maxX - minX; - this.height = maxY - minY; - } - }; - return Rectangle; - }(egret.Rectangle)); - es.Rectangle = Rectangle; -})(es || (es = {})); -var es; -(function (es) { - var SubpixelFloat = (function () { - function SubpixelFloat() { - this.remainder = 0; - } - SubpixelFloat.prototype.update = function (amount) { - this.remainder += amount; - var motion = Math.floor(Math.trunc(this.remainder)); - this.remainder -= motion; - amount = motion; - return amount; - }; - SubpixelFloat.prototype.reset = function () { - this.remainder = 0; - }; - return SubpixelFloat; - }()); - es.SubpixelFloat = SubpixelFloat; -})(es || (es = {})); -var es; -(function (es) { - var SubpixelVector2 = (function () { - function SubpixelVector2() { - this._x = new es.SubpixelFloat(); - this._y = new es.SubpixelFloat(); - } - SubpixelVector2.prototype.update = function (amount) { - amount.x = this._x.update(amount.x); - amount.y = this._y.update(amount.y); - }; - SubpixelVector2.prototype.reset = function () { - this._x.reset(); - this._y.reset(); - }; - return SubpixelVector2; - }()); - es.SubpixelVector2 = SubpixelVector2; -})(es || (es = {})); -var es; -(function (es) { - var Vector3 = (function () { - function Vector3(x, y, z) { - this.x = x; - this.y = y; - this.z = z; - } - return Vector3; - }()); - es.Vector3 = Vector3; -})(es || (es = {})); -var es; -(function (es) { - var ColliderTriggerHelper = (function () { - function ColliderTriggerHelper(entity) { - this._activeTriggerIntersections = []; - this._previousTriggerIntersections = []; - this._tempTriggerList = []; - this._entity = entity; - } - ColliderTriggerHelper.prototype.update = function () { - var colliders = this._entity.getComponents(es.Collider); - for (var i = 0; i < colliders.length; i++) { - var collider = colliders[i]; - var neighbors = es.Physics.boxcastBroadphase(collider.bounds, collider.collidesWithLayers); - var _loop_5 = function (j) { - var neighbor = neighbors[j]; - if (!collider.isTrigger && !neighbor.isTrigger) - return "continue"; - if (collider.overlaps(neighbor)) { - var pair_1 = new es.Pair(collider, neighbor); - var shouldReportTriggerEvent = this_1._activeTriggerIntersections.findIndex(function (value) { - return value.first == pair_1.first && value.second == pair_1.second; - }) == -1 && this_1._previousTriggerIntersections.findIndex(function (value) { - return value.first == pair_1.first && value.second == pair_1.second; - }) == -1; - if (shouldReportTriggerEvent) - this_1.notifyTriggerListeners(pair_1, true); - if (!this_1._activeTriggerIntersections.contains(pair_1)) - this_1._activeTriggerIntersections.push(pair_1); - } - }; - var this_1 = this; - for (var j = 0; j < neighbors.length; j++) { - _loop_5(j); - } - } - es.ListPool.free(colliders); - this.checkForExitedColliders(); - }; - ColliderTriggerHelper.prototype.checkForExitedColliders = function () { - var _this = this; - var _loop_6 = function (i) { - var index = this_2._previousTriggerIntersections.findIndex(function (value) { - if (value.first == _this._activeTriggerIntersections[i].first && value.second == _this._activeTriggerIntersections[i].second) - return true; - return false; - }); - if (index != -1) - this_2._previousTriggerIntersections.removeAt(index); - }; - var this_2 = this; - for (var i = 0; i < this._activeTriggerIntersections.length; i++) { - _loop_6(i); - } - for (var i = 0; i < this._previousTriggerIntersections.length; i++) { - this.notifyTriggerListeners(this._previousTriggerIntersections[i], false); - } - this._previousTriggerIntersections.length = 0; - for (var i = 0; i < this._activeTriggerIntersections.length; i++) { - if (!this._previousTriggerIntersections.contains(this._activeTriggerIntersections[i])) { - this._previousTriggerIntersections.push(this._activeTriggerIntersections[i]); - } - } - this._activeTriggerIntersections.length = 0; - }; - ColliderTriggerHelper.prototype.notifyTriggerListeners = function (collisionPair, isEntering) { - collisionPair.first.entity.getComponents("ITriggerListener", this._tempTriggerList); - for (var i = 0; i < this._tempTriggerList.length; i++) { - if (isEntering) { - this._tempTriggerList[i].onTriggerEnter(collisionPair.second, collisionPair.first); - } - else { - this._tempTriggerList[i].onTriggerExit(collisionPair.second, collisionPair.first); - } - this._tempTriggerList.length = 0; - if (collisionPair.second.entity) { - collisionPair.second.entity.getComponents("ITriggerListener", this._tempTriggerList); - for (var i_2 = 0; i_2 < this._tempTriggerList.length; i_2++) { - if (isEntering) { - this._tempTriggerList[i_2].onTriggerEnter(collisionPair.first, collisionPair.second); - } - else { - this._tempTriggerList[i_2].onTriggerExit(collisionPair.first, collisionPair.second); - } - } - this._tempTriggerList.length = 0; - } - } - }; - return ColliderTriggerHelper; - }()); - es.ColliderTriggerHelper = ColliderTriggerHelper; -})(es || (es = {})); -var es; -(function (es) { - var PointSectors; - (function (PointSectors) { - PointSectors[PointSectors["center"] = 0] = "center"; - PointSectors[PointSectors["top"] = 1] = "top"; - PointSectors[PointSectors["bottom"] = 2] = "bottom"; - PointSectors[PointSectors["topLeft"] = 9] = "topLeft"; - PointSectors[PointSectors["topRight"] = 5] = "topRight"; - PointSectors[PointSectors["left"] = 8] = "left"; - PointSectors[PointSectors["right"] = 4] = "right"; - PointSectors[PointSectors["bottomLeft"] = 10] = "bottomLeft"; - PointSectors[PointSectors["bottomRight"] = 6] = "bottomRight"; - })(PointSectors = es.PointSectors || (es.PointSectors = {})); - var Collisions = (function () { - function Collisions() { - } - Collisions.isLineToLine = function (a1, a2, b1, b2) { - var b = es.Vector2.subtract(a2, a1); - var d = es.Vector2.subtract(b2, b1); - var bDotDPerp = b.x * d.y - b.y * d.x; - if (bDotDPerp == 0) - return false; - var c = es.Vector2.subtract(b1, a1); - var t = (c.x * d.y - c.y * d.x) / bDotDPerp; - if (t < 0 || t > 1) - return false; - var u = (c.x * b.y - c.y * b.x) / bDotDPerp; - if (u < 0 || u > 1) - return false; - return true; - }; - Collisions.lineToLineIntersection = function (a1, a2, b1, b2) { - var intersection = new es.Vector2(0, 0); - var b = es.Vector2.subtract(a2, a1); - var d = es.Vector2.subtract(b2, b1); - var bDotDPerp = b.x * d.y - b.y * d.x; - if (bDotDPerp == 0) - return intersection; - var c = es.Vector2.subtract(b1, a1); - var t = (c.x * d.y - c.y * d.x) / bDotDPerp; - if (t < 0 || t > 1) - return intersection; - var u = (c.x * b.y - c.y * b.x) / bDotDPerp; - if (u < 0 || u > 1) - return intersection; - intersection = es.Vector2.add(a1, new es.Vector2(t * b.x, t * b.y)); - return intersection; - }; - Collisions.closestPointOnLine = function (lineA, lineB, closestTo) { - var v = es.Vector2.subtract(lineB, lineA); - var w = es.Vector2.subtract(closestTo, lineA); - var t = es.Vector2.dot(w, v) / es.Vector2.dot(v, v); - t = es.MathHelper.clamp(t, 0, 1); - return es.Vector2.add(lineA, new es.Vector2(v.x * t, v.y * t)); - }; - Collisions.circleToCircle = function (circleCenter1, circleRadius1, circleCenter2, circleRadius2) { - return es.Vector2.distanceSquared(circleCenter1, circleCenter2) < (circleRadius1 + circleRadius2) * (circleRadius1 + circleRadius2); - }; - Collisions.circleToLine = function (circleCenter, radius, lineFrom, lineTo) { - return es.Vector2.distanceSquared(circleCenter, this.closestPointOnLine(lineFrom, lineTo, circleCenter)) < radius * radius; - }; - Collisions.circleToPoint = function (circleCenter, radius, point) { - return es.Vector2.distanceSquared(circleCenter, point) < radius * radius; - }; - Collisions.rectToCircle = function (rect, cPosition, cRadius) { - if (this.rectToPoint(rect.x, rect.y, rect.width, rect.height, cPosition)) - return true; - var edgeFrom = es.Vector2.zero; - var edgeTo = es.Vector2.zero; - var sector = this.getSector(rect.x, rect.y, rect.width, rect.height, cPosition); - if ((sector & PointSectors.top) != 0) { - edgeFrom = new es.Vector2(rect.x, rect.y); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y); - if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) - return true; - } - if ((sector & PointSectors.bottom) != 0) { - edgeFrom = new es.Vector2(rect.x, rect.y + rect.width); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); - if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) - return true; - } - if ((sector & PointSectors.left) != 0) { - edgeFrom = new es.Vector2(rect.x + rect.width, rect.y); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); - if (this.circleToLine(cPosition, cRadius, edgeFrom, edgeTo)) - return true; - } - return false; - }; - Collisions.rectToLine = function (rect, lineFrom, lineTo) { - var fromSector = this.getSector(rect.x, rect.y, rect.width, rect.height, lineFrom); - var toSector = this.getSector(rect.x, rect.y, rect.width, rect.height, lineTo); - if (fromSector == PointSectors.center || toSector == PointSectors.center) { - return true; - } - else if ((fromSector & toSector) != 0) { - return false; - } - else { - var both = fromSector | toSector; - var edgeFrom = void 0; - var edgeTo = void 0; - if ((both & PointSectors.top) != 0) { - edgeFrom = new es.Vector2(rect.x, rect.y); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y); - if (this.isLineToLine(edgeFrom, edgeTo, lineFrom, lineTo)) - return true; - } - if ((both & PointSectors.bottom) != 0) { - edgeFrom = new es.Vector2(rect.x, rect.y + rect.height); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); - if (this.isLineToLine(edgeFrom, edgeTo, lineFrom, lineTo)) - return true; - } - if ((both & PointSectors.left) != 0) { - edgeFrom = new es.Vector2(rect.x, rect.y); - edgeTo = new es.Vector2(rect.x, rect.y + rect.height); - if (this.isLineToLine(edgeFrom, edgeTo, lineFrom, lineTo)) - return true; - } - if ((both & PointSectors.right) != 0) { - edgeFrom = new es.Vector2(rect.x + rect.width, rect.y); - edgeTo = new es.Vector2(rect.x + rect.width, rect.y + rect.height); - if (this.isLineToLine(edgeFrom, edgeTo, lineFrom, lineTo)) - return true; - } - } - return false; - }; - Collisions.rectToPoint = function (rX, rY, rW, rH, point) { - return point.x >= rX && point.y >= rY && point.x < rX + rW && point.y < rY + rH; - }; - Collisions.getSector = function (rX, rY, rW, rH, point) { - var sector = PointSectors.center; - if (point.x < rX) - sector |= PointSectors.left; - else if (point.x >= rX + rW) - sector |= PointSectors.right; - if (point.y < rY) - sector |= PointSectors.top; - else if (point.y >= rY + rH) - sector |= PointSectors.bottom; - return sector; - }; - return Collisions; - }()); - es.Collisions = Collisions; -})(es || (es = {})); -var es; -(function (es) { - var RaycastHit = (function () { - function RaycastHit(collider, fraction, distance, point, normal) { - this.fraction = 0; - this.distance = 0; - this.point = es.Vector2.zero; - this.normal = es.Vector2.zero; - this.collider = collider; - this.fraction = fraction; - this.distance = distance; - this.point = point; - this.centroid = es.Vector2.zero; - } - RaycastHit.prototype.setValues = function (collider, fraction, distance, point) { - this.collider = collider; - this.fraction = fraction; - this.distance = distance; - this.point = point; - }; - RaycastHit.prototype.setValuesNonCollider = function (fraction, distance, point, normal) { - this.fraction = fraction; - this.distance = distance; - this.point = point; - this.normal = normal; - }; - RaycastHit.prototype.reset = function () { - this.collider = null; - this.fraction = this.distance = 0; - }; - RaycastHit.prototype.toString = function () { - return "[RaycastHit] fraction: " + this.fraction + ", distance: " + this.distance + ", normal: " + this.normal + ", centroid: " + this.centroid + ", point: " + this.point; - }; - return RaycastHit; - }()); - es.RaycastHit = RaycastHit; -})(es || (es = {})); -var es; -(function (es) { - var Physics = (function () { - function Physics() { - } - Physics.reset = function () { - this._spatialHash = new es.SpatialHash(this.spatialHashCellSize); - }; - Physics.clear = function () { - this._spatialHash.clear(); - }; - Physics.overlapCircleAll = function (center, randius, results, layerMask) { - if (layerMask === void 0) { layerMask = -1; } - if (results.length == 0) { - console.error("An empty results array was passed in. No results will ever be returned."); - return; - } - return this._spatialHash.overlapCircle(center, randius, results, layerMask); - }; - Physics.boxcastBroadphase = function (rect, layerMask) { - if (layerMask === void 0) { layerMask = this.allLayers; } - return this._spatialHash.aabbBroadphase(rect, null, layerMask); - }; - Physics.boxcastBroadphaseExcludingSelf = function (collider, rect, layerMask) { - if (layerMask === void 0) { layerMask = this.allLayers; } - return this._spatialHash.aabbBroadphase(rect, collider, layerMask); - }; - Physics.addCollider = function (collider) { - Physics._spatialHash.register(collider); - }; - Physics.removeCollider = function (collider) { - Physics._spatialHash.remove(collider); - }; - Physics.updateCollider = function (collider) { - this._spatialHash.remove(collider); - this._spatialHash.register(collider); - }; - Physics.linecast = function (start, end, layerMask) { - if (layerMask === void 0) { layerMask = Physics.allLayers; } - this._hitArray[0].reset(); - this.linecastAll(start, end, this._hitArray, layerMask); - return this._hitArray[0]; - }; - Physics.linecastAll = function (start, end, hits, layerMask) { - if (layerMask === void 0) { layerMask = Physics.allLayers; } - if (hits.length == 0) { - console.warn("传入了一个空的hits数组。没有点击会被返回"); - return 0; - } - return this._spatialHash.linecast(start, end, hits, layerMask); - }; - Physics.debugDraw = function (secondsToDisplay) { - this._spatialHash.debugDraw(secondsToDisplay, 2); - }; - Physics.spatialHashCellSize = 100; - Physics.allLayers = -1; - Physics.raycastsHitTriggers = false; - Physics.raycastsStartInColliders = false; - Physics._hitArray = [ - new es.RaycastHit() - ]; - return Physics; - }()); - es.Physics = Physics; -})(es || (es = {})); -var es; -(function (es) { - var Ray2D = (function () { - function Ray2D(position, end) { - this.start = position; - this.end = end; - this.direction = es.Vector2.subtract(this.end, this.start); - } - return Ray2D; - }()); - es.Ray2D = Ray2D; -})(es || (es = {})); -var es; -(function (es) { - var SpatialHash = (function () { - function SpatialHash(cellSize) { - if (cellSize === void 0) { cellSize = 100; } - this.gridBounds = new es.Rectangle(); - this._overlapTestCircle = new es.Circle(0); - this._cellDict = new NumberDictionary(); - this._tempHashSet = []; - this._cellSize = cellSize; - this._inverseCellSize = 1 / this._cellSize; - this._raycastParser = new RaycastResultParser(); - } - SpatialHash.prototype.register = function (collider) { - var bounds = collider.bounds; - collider.registeredPhysicsBounds = bounds; - var p1 = this.cellCoords(bounds.x, bounds.y); - var p2 = this.cellCoords(bounds.right, bounds.bottom); - if (!this.gridBounds.contains(p1.x, p1.y)) { - this.gridBounds = es.RectangleExt.union(this.gridBounds, p1); - } - if (!this.gridBounds.contains(p2.x, p2.y)) { - this.gridBounds = es.RectangleExt.union(this.gridBounds, p2); - } - for (var x = p1.x; x <= p2.x; x++) { - for (var y = p1.y; y <= p2.y; y++) { - var c = this.cellAtPosition(x, y, true); - if (!c.firstOrDefault(function (c) { return c.hashCode == collider.hashCode; })) - c.push(collider); - } - } - }; - SpatialHash.prototype.remove = function (collider) { - var bounds = collider.registeredPhysicsBounds; - var p1 = this.cellCoords(bounds.x, bounds.y); - var p2 = this.cellCoords(bounds.right, bounds.bottom); - for (var x = p1.x; x <= p2.x; x++) { - for (var y = p1.y; y <= p2.y; y++) { - var cell = this.cellAtPosition(x, y); - if (!cell) - console.log("\u4ECE\u4E0D\u5B58\u5728\u78B0\u649E\u5668\u7684\u5355\u5143\u683C\u4E2D\u79FB\u9664\u78B0\u649E\u5668: [" + collider + "]"); - else - cell.remove(collider); - } - } - }; - SpatialHash.prototype.removeWithBruteForce = function (obj) { - this._cellDict.remove(obj); - }; - SpatialHash.prototype.clear = function () { - this._cellDict.clear(); - }; - SpatialHash.prototype.debugDraw = function (secondsToDisplay, textScale) { - if (textScale === void 0) { textScale = 1; } - for (var x = this.gridBounds.x; x <= this.gridBounds.right; x++) { - for (var y = this.gridBounds.y; y <= this.gridBounds.bottom; y++) { - var cell = this.cellAtPosition(x, y); - if (cell && cell.length > 0) - this.debugDrawCellDetails(x, y, cell.length, secondsToDisplay, textScale); - } - } - }; - SpatialHash.prototype.aabbBroadphase = function (bounds, excludeCollider, layerMask) { - this._tempHashSet.length = 0; - var p1 = this.cellCoords(bounds.x, bounds.y); - var p2 = this.cellCoords(bounds.right, bounds.bottom); - for (var x = p1.x; x <= p2.x; x++) { - for (var y = p1.y; y <= p2.y; y++) { - var cell = this.cellAtPosition(x, y); - if (!cell) - continue; - var _loop_7 = function (i) { - var collider = cell[i]; - if (collider == excludeCollider || !es.Flags.isFlagSet(layerMask, collider.physicsLayer.value)) - return "continue"; - if (bounds.intersects(collider.bounds)) { - if (!this_3._tempHashSet.firstOrDefault(function (c) { return c.hashCode == collider.hashCode; })) - this_3._tempHashSet.push(collider); - } - }; - var this_3 = this; - for (var i = 0; i < cell.length; i++) { - _loop_7(i); - } - } - } - return this._tempHashSet; - }; - SpatialHash.prototype.linecast = function (start, end, hits, layerMask) { - var ray = new es.Ray2D(start, end); - this._raycastParser.start(ray, hits, layerMask); - var currentCell = this.cellCoords(start.x, start.y); - var lastCell = this.cellCoords(end.x, end.y); - var stepX = Math.sign(ray.direction.x); - var stepY = Math.sign(ray.direction.y); - if (currentCell.x == lastCell.x) - stepX = 0; - if (currentCell.y == lastCell.y) - stepY = 0; - var xStep = stepX < 0 ? 0 : stepX; - var yStep = stepY < 0 ? 0 : stepY; - var nextBoundaryX = (currentCell.x + xStep) * this._cellSize; - var nextBoundaryY = (currentCell.y + yStep) * this._cellSize; - var tMaxX = ray.direction.x != 0 ? (nextBoundaryX - ray.start.x) / ray.direction.x : Number.MAX_VALUE; - var tMaxY = ray.direction.y != 0 ? (nextBoundaryY - ray.start.y) / ray.direction.y : Number.MAX_VALUE; - var tDeltaX = ray.direction.x != 0 ? this._cellSize / (ray.direction.x * stepX) : Number.MAX_VALUE; - var tDeltaY = ray.direction.y != 0 ? this._cellSize / (ray.direction.y * stepY) : Number.MAX_VALUE; - var cell = this.cellAtPosition(currentCell.x, currentCell.y); - if (cell && this._raycastParser.checkRayIntersection(currentCell.x, currentCell.y, cell)) { - this._raycastParser.reset(); - return this._raycastParser.hitCounter; - } - while (currentCell.x != lastCell.x || currentCell.y != lastCell.y) { - if (tMaxX < tMaxY) { - currentCell.x = Math.floor(es.MathHelper.approach(currentCell.x, lastCell.x, Math.abs(stepX))); - tMaxX += tDeltaX; - } - else { - currentCell.y = Math.floor(es.MathHelper.approach(currentCell.y, lastCell.y, Math.abs(stepY))); - tMaxY += tDeltaY; - } - cell = this.cellAtPosition(currentCell.x, currentCell.y); - if (cell && this._raycastParser.checkRayIntersection(currentCell.x, currentCell.y, cell)) { - this._raycastParser.reset(); - return this._raycastParser.hitCounter; - } - } - this._raycastParser.reset(); - return this._raycastParser.hitCounter; - }; - SpatialHash.prototype.overlapCircle = function (circleCenter, radius, results, layerMask) { - var bounds = new es.Rectangle(circleCenter.x - radius, circleCenter.y - radius, radius * 2, radius * 2); - this._overlapTestCircle.radius = radius; - this._overlapTestCircle.position = circleCenter; - var resultCounter = 0; - var potentials = this.aabbBroadphase(bounds, null, layerMask); - for (var i = 0; i < potentials.length; i++) { - var collider = potentials[i]; - if (collider instanceof es.BoxCollider) { - results[resultCounter] = collider; - resultCounter++; - } - else if (collider instanceof es.CircleCollider) { - if (collider.shape.overlaps(this._overlapTestCircle)) { - results[resultCounter] = collider; - resultCounter++; - } - } - else if (collider instanceof es.PolygonCollider) { - if (collider.shape.overlaps(this._overlapTestCircle)) { - results[resultCounter] = collider; - resultCounter++; - } - } - else { - throw new Error("overlapCircle against this collider type is not implemented!"); - } - if (resultCounter == results.length) - return resultCounter; - } - return resultCounter; - }; - SpatialHash.prototype.cellCoords = function (x, y) { - return new es.Vector2(Math.floor(x * this._inverseCellSize), Math.floor(y * this._inverseCellSize)); - }; - SpatialHash.prototype.cellAtPosition = function (x, y, createCellIfEmpty) { - if (createCellIfEmpty === void 0) { createCellIfEmpty = false; } - var cell = this._cellDict.tryGetValue(x, y); - if (!cell) { - if (createCellIfEmpty) { - cell = []; - this._cellDict.add(x, y, cell); - } - } - return cell; - }; - SpatialHash.prototype.debugDrawCellDetails = function (x, y, cellCount, secondsToDisplay, textScale) { - if (secondsToDisplay === void 0) { secondsToDisplay = 0.5; } - if (textScale === void 0) { textScale = 1; } - }; - return SpatialHash; - }()); - es.SpatialHash = SpatialHash; - var NumberDictionary = (function () { - function NumberDictionary() { - this._store = new Map(); - } - NumberDictionary.prototype.add = function (x, y, list) { - this._store.set(this.getKey(x, y), list); - }; - NumberDictionary.prototype.remove = function (obj) { - this._store.forEach(function (list) { - if (list.contains(obj)) - list.remove(obj); - }); - }; - NumberDictionary.prototype.tryGetValue = function (x, y) { - return this._store.get(this.getKey(x, y)); - }; - NumberDictionary.prototype.getKey = function (x, y) { - return x + "_" + y; - }; - NumberDictionary.prototype.clear = function () { - this._store.clear(); - }; - return NumberDictionary; - }()); - es.NumberDictionary = NumberDictionary; - var RaycastResultParser = (function () { - function RaycastResultParser() { - this._tempHit = new es.RaycastHit(); - this._checkedColliders = []; - this._cellHits = []; - } - RaycastResultParser.prototype.start = function (ray, hits, layerMask) { - this._ray = ray; - this._hits = hits; - this._layerMask = layerMask; - this.hitCounter = 0; - }; - RaycastResultParser.prototype.checkRayIntersection = function (cellX, cellY, cell) { - var fraction = new es.Ref(0); - for (var i = 0; i < cell.length; i++) { - var potential = cell[i]; - if (this._checkedColliders.contains(potential)) - continue; - this._checkedColliders.push(potential); - if (potential.isTrigger && !es.Physics.raycastsHitTriggers) - continue; - if (!es.Flags.isFlagSet(this._layerMask, potential.physicsLayer.value)) - continue; - var colliderBounds = potential.bounds; - if (colliderBounds.rayIntersects(this._ray, fraction) && fraction.value <= 1) { - if (potential.shape.collidesWithLine(this._ray.start, this._ray.end, this._tempHit)) { - if (!es.Physics.raycastsStartInColliders && potential.shape.containsPoint(this._ray.start)) - continue; - this._tempHit.collider = potential; - this._cellHits.push(this._tempHit); - } - } - } - if (this._cellHits.length == 0) - return false; - this._cellHits.sort(RaycastResultParser.compareRaycastHits); - for (var i = 0; i < this._cellHits.length; i++) { - this._hits[this.hitCounter] = this._cellHits[i]; - this.hitCounter++; - if (this.hitCounter == this._hits.length) - return true; - } - return false; - }; - RaycastResultParser.prototype.reset = function () { - this._hits = null; - this._checkedColliders.length = 0; - this._cellHits.length = 0; - }; - RaycastResultParser.compareRaycastHits = function (a, b) { - return a.distance - b.distance; - }; - return RaycastResultParser; - }()); - es.RaycastResultParser = RaycastResultParser; -})(es || (es = {})); -var es; -(function (es) { - var Shape = (function () { - function Shape() { - } - return Shape; - }()); - es.Shape = Shape; -})(es || (es = {})); -var es; -(function (es) { - var Polygon = (function (_super) { - __extends(Polygon, _super); - function Polygon(points, isBox) { - var _this = _super.call(this) || this; - _this._areEdgeNormalsDirty = true; - _this.isUnrotated = true; - _this.setPoints(points); - _this.isBox = isBox; - return _this; - } - Object.defineProperty(Polygon.prototype, "edgeNormals", { - get: function () { - if (this._areEdgeNormalsDirty) - this.buildEdgeNormals(); - return this._edgeNormals; - }, - enumerable: true, - configurable: true - }); - Polygon.prototype.setPoints = function (points) { - this.points = points; - this.recalculateCenterAndEdgeNormals(); - this._originalPoints = []; - for (var i = 0; i < this.points.length; i++) { - this._originalPoints.push(this.points[i]); - } - }; - Polygon.prototype.recalculateCenterAndEdgeNormals = function () { - this._polygonCenter = Polygon.findPolygonCenter(this.points); - this._areEdgeNormalsDirty = true; - }; - Polygon.prototype.buildEdgeNormals = function () { - var totalEdges = this.isBox ? 2 : this.points.length; - if (this._edgeNormals == undefined || this._edgeNormals.length != totalEdges) - this._edgeNormals = new Array(totalEdges); - var p2; - for (var i = 0; i < totalEdges; i++) { - var p1 = this.points[i]; - if (i + 1 >= this.points.length) - p2 = this.points[0]; - else - p2 = this.points[i + 1]; - var perp = es.Vector2Ext.perpendicular(p1, p2); - es.Vector2Ext.normalize(perp); - this._edgeNormals[i] = perp; - } - }; - Polygon.buildSymmetricalPolygon = function (vertCount, radius) { - var verts = new Array(vertCount); - for (var i = 0; i < vertCount; i++) { - var a = 2 * Math.PI * (i / vertCount); - verts[i] = new es.Vector2(Math.cos(a) * radius, Math.sin(a) * radius); - } - return verts; - }; - Polygon.recenterPolygonVerts = function (points) { - var center = this.findPolygonCenter(points); - for (var i = 0; i < points.length; i++) - points[i].subtract(center); - }; - Polygon.findPolygonCenter = function (points) { - var x = 0, y = 0; - for (var i = 0; i < points.length; i++) { - x += points[i].x; - y += points[i].y; - } - return new es.Vector2(x / points.length, y / points.length); - }; - Polygon.getFarthestPointInDirection = function (points, direction) { - var index = 0; - var maxDot = es.Vector2.dot(points[index], direction); - for (var i = 1; i < points.length; i++) { - var dot = es.Vector2.dot(points[i], direction); - if (dot > maxDot) { - maxDot = dot; - index = i; - } - } - return points[index]; - }; - Polygon.getClosestPointOnPolygonToPoint = function (points, point, distanceSquared, edgeNormal) { - distanceSquared.value = Number.MAX_VALUE; - edgeNormal.x = 0; - edgeNormal.y = 0; - var closestPoint = new es.Vector2(0, 0); - var tempDistanceSquared = 0; - for (var i = 0; i < points.length; i++) { - var j = i + 1; - if (j == points.length) - j = 0; - var closest = es.ShapeCollisions.closestPointOnLine(points[i], points[j], point); - tempDistanceSquared = es.Vector2.distanceSquared(point, closest); - if (tempDistanceSquared < distanceSquared.value) { - distanceSquared.value = tempDistanceSquared; - closestPoint = closest; - var line = es.Vector2.subtract(points[j], points[i]); - edgeNormal.x = -line.y; - edgeNormal.y = line.x; - } - } - es.Vector2Ext.normalize(edgeNormal); - return closestPoint; - }; - Polygon.rotatePolygonVerts = function (radians, originalPoints, rotatedPoints) { - var cos = Math.cos(radians); - var sin = Math.sin(radians); - for (var i = 0; i < originalPoints.length; i++) { - var position = originalPoints[i]; - rotatedPoints[i] = new es.Vector2(position.x * cos + position.y * -sin, position.x * sin + position.y * cos); - } - }; - Polygon.prototype.recalculateBounds = function (collider) { - this.center = collider.localOffset; - if (collider.shouldColliderScaleAndRotateWithTransform) { - var hasUnitScale = true; - var tempMat = void 0; - var combinedMatrix = es.Matrix2D.create().translate(-this._polygonCenter.x, -this._polygonCenter.y); - if (!collider.entity.transform.scale.equals(es.Vector2.one)) { - tempMat = es.Matrix2D.create().scale(collider.entity.transform.scale.x, collider.entity.transform.scale.y); - combinedMatrix = combinedMatrix.multiply(tempMat); - hasUnitScale = false; - this.center = es.Vector2.multiply(collider.localOffset, collider.entity.transform.scale); - } - if (collider.entity.transform.rotation != 0) { - tempMat = es.Matrix2D.create().rotate(collider.entity.transform.rotation); - combinedMatrix = combinedMatrix.multiply(tempMat); - var offsetAngle = Math.atan2(collider.localOffset.y, collider.localOffset.x) * es.MathHelper.Rad2Deg; - var offsetLength = hasUnitScale ? collider._localOffsetLength : - es.Vector2.multiply(collider.localOffset, collider.entity.transform.scale).length(); - this.center = es.MathHelper.pointOnCirlce(es.Vector2.zero, offsetLength, collider.entity.transform.rotationDegrees + offsetAngle); - } - tempMat = es.Matrix2D.create().translate(this._polygonCenter.x, this._polygonCenter.y); - combinedMatrix = combinedMatrix.multiply(tempMat); - es.Vector2Ext.transform(this._originalPoints, combinedMatrix, this.points); - this.isUnrotated = collider.entity.transform.rotation == 0; - if (collider._isRotationDirty) - this._areEdgeNormalsDirty = true; - } - this.position = es.Vector2.add(collider.entity.transform.position, this.center); - this.bounds = es.Rectangle.rectEncompassingPoints(this.points); - this.bounds.location.add(this.position); - }; - Polygon.prototype.overlaps = function (other) { - var result = new es.CollisionResult(); - if (other instanceof Polygon) - return es.ShapeCollisions.polygonToPolygon(this, other, result); - if (other instanceof es.Circle) { - if (es.ShapeCollisions.circleToPolygon(other, this, result)) { - result.invertResult(); - return true; - } - return false; - } - throw new Error("overlaps of Pologon to " + other + " are not supported"); - }; - Polygon.prototype.collidesWithShape = function (other, result) { - if (other instanceof Polygon) { - return es.ShapeCollisions.polygonToPolygon(this, other, result); - } - if (other instanceof es.Circle) { - if (es.ShapeCollisions.circleToPolygon(other, this, result)) { - result.invertResult(); - return true; - } - return false; - } - throw new Error("overlaps of Polygon to " + other + " are not supported"); - }; - Polygon.prototype.collidesWithLine = function (start, end, hit) { - return es.ShapeCollisions.lineToPoly(start, end, this, hit); - }; - Polygon.prototype.containsPoint = function (point) { - point.subtract(this.position); - var isInside = false; - for (var i = 0, j = this.points.length - 1; i < this.points.length; j = i++) { - if (((this.points[i].y > point.y) != (this.points[j].y > point.y)) && - (point.x < (this.points[j].x - this.points[i].x) * (point.y - this.points[i].y) / (this.points[j].y - this.points[i].y) + - this.points[i].x)) { - isInside = !isInside; - } - } - return isInside; - }; - Polygon.prototype.pointCollidesWithShape = function (point, result) { - return es.ShapeCollisions.pointToPoly(point, this, result); - }; - return Polygon; - }(es.Shape)); - es.Polygon = Polygon; -})(es || (es = {})); -var es; -(function (es) { - var Box = (function (_super) { - __extends(Box, _super); - function Box(width, height) { - var _this = _super.call(this, Box.buildBox(width, height), true) || this; - _this.width = width; - _this.height = height; - return _this; - } - Box.buildBox = function (width, height) { - var halfWidth = width / 2; - var halfHeight = height / 2; - var verts = new Array(4); - verts[0] = new es.Vector2(-halfWidth, -halfHeight); - verts[1] = new es.Vector2(halfWidth, -halfHeight); - verts[2] = new es.Vector2(halfWidth, halfHeight); - verts[3] = new es.Vector2(-halfWidth, halfHeight); - return verts; - }; - Box.prototype.updateBox = function (width, height) { - this.width = width; - this.height = height; - var halfWidth = width / 2; - var halfHeight = height / 2; - this.points[0] = new es.Vector2(-halfWidth, -halfHeight); - this.points[1] = new es.Vector2(halfWidth, -halfHeight); - this.points[2] = new es.Vector2(halfWidth, halfHeight); - this.points[3] = new es.Vector2(-halfWidth, halfHeight); - for (var i = 0; i < this.points.length; i++) - this._originalPoints[i] = this.points[i]; - }; - Box.prototype.overlaps = function (other) { - if (this.isUnrotated) { - if (other instanceof Box && other.isUnrotated) - return this.bounds.intersects(other.bounds); - if (other instanceof es.Circle) - return es.Collisions.rectToCircle(this.bounds, other.position, other.radius); - } - return _super.prototype.overlaps.call(this, other); - }; - Box.prototype.collidesWithShape = function (other, result) { - if (other instanceof Box && other.isUnrotated) { - return es.ShapeCollisions.boxToBox(this, other, result); - } - return _super.prototype.collidesWithShape.call(this, other, result); - }; - Box.prototype.containsPoint = function (point) { - if (this.isUnrotated) - return this.bounds.contains(point.x, point.y); - return _super.prototype.containsPoint.call(this, point); - }; - Box.prototype.pointCollidesWithShape = function (point, result) { - if (this.isUnrotated) - return es.ShapeCollisions.pointToBox(point, this, result); - return _super.prototype.pointCollidesWithShape.call(this, point, result); - }; - return Box; - }(es.Polygon)); - es.Box = Box; -})(es || (es = {})); -var es; -(function (es) { - var Circle = (function (_super) { - __extends(Circle, _super); - function Circle(radius) { - var _this = _super.call(this) || this; - _this.radius = radius; - _this._originalRadius = radius; - return _this; - } - Circle.prototype.recalculateBounds = function (collider) { - this.center = collider.localOffset; - if (collider.shouldColliderScaleAndRotateWithTransform) { - var scale = collider.entity.transform.scale; - var hasUnitScale = scale.x == 1 && scale.y == 1; - var maxScale = Math.max(scale.x, scale.y); - this.radius = this._originalRadius * maxScale; - if (collider.entity.transform.rotation != 0) { - var offsetAngle = Math.atan2(collider.localOffset.y, collider.localOffset.x) * es.MathHelper.Rad2Deg; - var offsetLength = hasUnitScale ? collider._localOffsetLength : es.Vector2.multiply(collider.localOffset, collider.entity.transform.scale).length(); - this.center = es.MathHelper.pointOnCirlce(es.Vector2.zero, offsetLength, collider.entity.transform.rotationDegrees + offsetAngle); - } - } - this.position = es.Vector2.add(collider.entity.transform.position, this.center); - this.bounds = new es.Rectangle(this.position.x - this.radius, this.position.y - this.radius, this.radius * 2, this.radius * 2); - }; - Circle.prototype.overlaps = function (other) { - var result = new es.CollisionResult(); - if (other instanceof es.Box && other.isUnrotated) - return es.Collisions.rectToCircle(other.bounds, this.position, this.radius); - if (other instanceof Circle) - return es.Collisions.circleToCircle(this.position, this.radius, other.position, other.radius); - if (other instanceof es.Polygon) - return es.ShapeCollisions.circleToPolygon(this, other, result); - throw new Error("overlaps of circle to " + other + " are not supported"); - }; - Circle.prototype.collidesWithShape = function (other, result) { - if (other instanceof es.Box && other.isUnrotated) { - return es.ShapeCollisions.circleToBox(this, other, result); - } - if (other instanceof Circle) { - return es.ShapeCollisions.circleToCircle(this, other, result); - } - if (other instanceof es.Polygon) { - return es.ShapeCollisions.circleToPolygon(this, other, result); - } - throw new Error("Collisions of Circle to " + other + " are not supported"); - }; - Circle.prototype.collidesWithLine = function (start, end, hit) { - return es.ShapeCollisions.lineToCircle(start, end, this, hit); - }; - Circle.prototype.containsPoint = function (point) { - return (es.Vector2.subtract(point, this.position)).lengthSquared() <= this.radius * this.radius; - }; - Circle.prototype.pointCollidesWithShape = function (point, result) { - return es.ShapeCollisions.pointToCircle(point, this, result); - }; - return Circle; - }(es.Shape)); - es.Circle = Circle; -})(es || (es = {})); -var es; -(function (es) { - var CollisionResult = (function () { - function CollisionResult() { - this.normal = es.Vector2.zero; - this.minimumTranslationVector = es.Vector2.zero; - this.point = es.Vector2.zero; - } - CollisionResult.prototype.removeHorizontal = function (deltaMovement) { - if (Math.sign(this.normal.x) != Math.sign(deltaMovement.x) || (deltaMovement.x == 0 && this.normal.x != 0)) { - var responseDistance = this.minimumTranslationVector.length(); - var fix = responseDistance / this.normal.y; - if (Math.abs(this.normal.x) != 1 && Math.abs(fix) < Math.abs(deltaMovement.y * 3)) { - this.minimumTranslationVector = new es.Vector2(0, -fix); - } - } - }; - CollisionResult.prototype.invertResult = function () { - this.minimumTranslationVector = es.Vector2.negate(this.minimumTranslationVector); - this.normal = es.Vector2.negate(this.normal); - return this; - }; - CollisionResult.prototype.toString = function () { - return "[CollisionResult] normal: " + this.normal + ", minimumTranslationVector: " + this.minimumTranslationVector; - }; - return CollisionResult; - }()); - es.CollisionResult = CollisionResult; -})(es || (es = {})); -var es; -(function (es) { - var RealtimeCollisions = (function () { - function RealtimeCollisions() { - } - RealtimeCollisions.intersectMovingCircleBox = function (s, b, movement, time) { - var e = b.bounds; - e.inflate(s.radius, s.radius); - var ray = new es.Ray2D(es.Vector2.subtract(s.position, movement), s.position); - if (!e.rayIntersects(ray, time) && time.value > 1) - return false; - var point = es.Vector2.add(ray.start, es.Vector2.add(ray.direction, new es.Vector2(time.value))); - var u, v = 0; - if (point.x < b.bounds.left) - u |= 1; - if (point.x > b.bounds.right) - v |= 1; - if (point.y < b.bounds.top) - u |= 2; - if (point.y > b.bounds.bottom) - v |= 2; - var m = u + v; - if (m == 3) { - console.log("m == 3. corner " + es.Time.frameCount); - } - if ((m & (m - 1)) == 0) { - return true; - } - return true; - }; - return RealtimeCollisions; - }()); - es.RealtimeCollisions = RealtimeCollisions; -})(es || (es = {})); -var es; -(function (es) { - var ShapeCollisions = (function () { - function ShapeCollisions() { - } - ShapeCollisions.polygonToPolygon = function (first, second, result) { - var isIntersecting = true; - var firstEdges = first.edgeNormals; - var secondEdges = second.edgeNormals; - var minIntervalDistance = Number.POSITIVE_INFINITY; - var translationAxis = new es.Vector2(); - var polygonOffset = es.Vector2.subtract(first.position, second.position); - var axis; - for (var edgeIndex = 0; edgeIndex < firstEdges.length + secondEdges.length; edgeIndex++) { - if (edgeIndex < firstEdges.length) { - axis = firstEdges[edgeIndex]; - } - else { - axis = secondEdges[edgeIndex - firstEdges.length]; - } - var minA = 0; - var minB = 0; - var maxA = 0; - var maxB = 0; - var intervalDist = 0; - var ta = this.getInterval(axis, first, minA, maxA); - minA = ta.min; - minB = ta.max; - var tb = this.getInterval(axis, second, minB, maxB); - minB = tb.min; - maxB = tb.max; - var relativeIntervalOffset = es.Vector2.dot(polygonOffset, axis); - minA += relativeIntervalOffset; - maxA += relativeIntervalOffset; - intervalDist = this.intervalDistance(minA, maxA, minB, maxB); - if (intervalDist > 0) - isIntersecting = false; - if (!isIntersecting) - return false; - intervalDist = Math.abs(intervalDist); - if (intervalDist < minIntervalDistance) { - minIntervalDistance = intervalDist; - translationAxis = axis; - if (es.Vector2.dot(translationAxis, polygonOffset) < 0) - translationAxis = new es.Vector2(-translationAxis); - } - } - result.normal = translationAxis; - result.minimumTranslationVector = es.Vector2.multiply(new es.Vector2(-translationAxis.x, -translationAxis.y), new es.Vector2(minIntervalDistance)); - return true; - }; - ShapeCollisions.intervalDistance = function (minA, maxA, minB, maxB) { - if (minA < minB) - return minB - maxA; - return minA - minB; - }; - ShapeCollisions.getInterval = function (axis, polygon, min, max) { - var dot = es.Vector2.dot(polygon.points[0], axis); - min = max = dot; - for (var i = 1; i < polygon.points.length; i++) { - dot = es.Vector2.dot(polygon.points[i], axis); - if (dot < min) { - min = dot; - } - else if (dot > max) { - max = dot; - } - } - return { min: min, max: max }; - }; - ShapeCollisions.circleToPolygon = function (circle, polygon, result) { - var poly2Circle = es.Vector2.subtract(circle.position, polygon.position); - var distanceSquared = new es.Ref(0); - var closestPoint = es.Polygon.getClosestPointOnPolygonToPoint(polygon.points, poly2Circle, distanceSquared, result.normal); - var circleCenterInsidePoly = polygon.containsPoint(circle.position); - if (distanceSquared.value > circle.radius * circle.radius && !circleCenterInsidePoly) - return false; - var mtv; - if (circleCenterInsidePoly) { - mtv = es.Vector2.multiply(result.normal, new es.Vector2(Math.sqrt(distanceSquared.value) - circle.radius)); - } - else { - if (distanceSquared.value == 0) { - mtv = es.Vector2.multiply(result.normal, new es.Vector2(circle.radius)); - } - else { - var distance = Math.sqrt(distanceSquared.value); - mtv = es.Vector2.multiply(new es.Vector2(-es.Vector2.subtract(poly2Circle, closestPoint)), new es.Vector2((circle.radius - distanceSquared.value) / distance)); - } - } - result.minimumTranslationVector = mtv; - result.point = es.Vector2.add(closestPoint, polygon.position); - return true; - }; - ShapeCollisions.circleToBox = function (circle, box, result) { - var closestPointOnBounds = box.bounds.getClosestPointOnRectangleBorderToPoint(circle.position, result.normal); - if (box.containsPoint(circle.position)) { - result.point = closestPointOnBounds; - var safePlace = es.Vector2.add(closestPointOnBounds, es.Vector2.multiply(result.normal, new es.Vector2(circle.radius))); - result.minimumTranslationVector = es.Vector2.subtract(circle.position, safePlace); - return true; - } - var sqrDistance = es.Vector2.distanceSquared(closestPointOnBounds, circle.position); - if (sqrDistance == 0) { - result.minimumTranslationVector = es.Vector2.multiply(result.normal, new es.Vector2(circle.radius)); - } - else if (sqrDistance <= circle.radius * circle.radius) { - result.normal = es.Vector2.subtract(circle.position, closestPointOnBounds); - var depth = result.normal.length() - circle.radius; - result.point = closestPointOnBounds; - es.Vector2Ext.normalize(result.normal); - result.minimumTranslationVector = es.Vector2.multiply(new es.Vector2(depth), result.normal); - return true; - } - return false; - }; - ShapeCollisions.pointToCircle = function (point, circle, result) { - var distanceSquared = es.Vector2.distanceSquared(point, circle.position); - var sumOfRadii = 1 + circle.radius; - var collided = distanceSquared < sumOfRadii * sumOfRadii; - if (collided) { - result.normal = es.Vector2.normalize(es.Vector2.subtract(point, circle.position)); - var depth = sumOfRadii - Math.sqrt(distanceSquared); - result.minimumTranslationVector = es.Vector2.multiply(new es.Vector2(-depth, -depth), result.normal); - result.point = es.Vector2.add(circle.position, es.Vector2.multiply(result.normal, new es.Vector2(circle.radius, circle.radius))); - return true; - } - return false; - }; - ShapeCollisions.pointToBox = function (point, box, result) { - if (box.containsPoint(point)) { - result.point = box.bounds.getClosestPointOnRectangleBorderToPoint(point, result.normal); - result.minimumTranslationVector = es.Vector2.subtract(point, result.point); - return true; - } - return false; - }; - ShapeCollisions.closestPointOnLine = function (lineA, lineB, closestTo) { - var v = es.Vector2.subtract(lineB, lineA); - var w = es.Vector2.subtract(closestTo, lineA); - var t = es.Vector2.dot(w, v) / es.Vector2.dot(v, v); - t = es.MathHelper.clamp(t, 0, 1); - return es.Vector2.add(lineA, es.Vector2.multiply(v, new es.Vector2(t, t))); - }; - ShapeCollisions.pointToPoly = function (point, poly, result) { - if (poly.containsPoint(point)) { - var distanceSquared = new es.Ref(0); - var closestPoint = es.Polygon.getClosestPointOnPolygonToPoint(poly.points, es.Vector2.subtract(point, poly.position), distanceSquared, result.normal); - result.minimumTranslationVector = es.Vector2.multiply(result.normal, new es.Vector2(Math.sqrt(distanceSquared.value), Math.sqrt(distanceSquared.value))); - result.point = es.Vector2.add(closestPoint, poly.position); - return true; - } - return false; - }; - ShapeCollisions.circleToCircle = function (first, second, result) { - var distanceSquared = es.Vector2.distanceSquared(first.position, second.position); - var sumOfRadii = first.radius + second.radius; - var collided = distanceSquared < sumOfRadii * sumOfRadii; - if (collided) { - result.normal = es.Vector2.normalize(es.Vector2.subtract(first.position, second.position)); - var depth = sumOfRadii - Math.sqrt(distanceSquared); - result.minimumTranslationVector = es.Vector2.multiply(new es.Vector2(-depth), result.normal); - result.point = es.Vector2.add(second.position, es.Vector2.multiply(result.normal, new es.Vector2(second.radius))); - return true; - } - return false; - }; - ShapeCollisions.boxToBox = function (first, second, result) { - var minkowskiDiff = this.minkowskiDifference(first, second); - if (minkowskiDiff.contains(0, 0)) { - result.minimumTranslationVector = minkowskiDiff.getClosestPointOnBoundsToOrigin(); - if (result.minimumTranslationVector.equals(es.Vector2.zero)) - return false; - result.normal = new es.Vector2(-result.minimumTranslationVector.x, -result.minimumTranslationVector.y); - result.normal.normalize(); - return true; - } - return false; - }; - ShapeCollisions.minkowskiDifference = function (first, second) { - var positionOffset = es.Vector2.subtract(first.position, es.Vector2.add(first.bounds.location, es.Vector2.divide(first.bounds.size, new es.Vector2(2)))); - var topLeft = es.Vector2.subtract(es.Vector2.add(first.bounds.location, positionOffset), second.bounds.max); - var fullSize = es.Vector2.add(first.bounds.size, second.bounds.size); - return new es.Rectangle(topLeft.x, topLeft.y, fullSize.x, fullSize.y); - }; - ShapeCollisions.lineToPoly = function (start, end, polygon, hit) { - var normal = es.Vector2.zero; - var intersectionPoint = es.Vector2.zero; - var fraction = Number.MAX_VALUE; - var hasIntersection = false; - for (var j = polygon.points.length - 1, i = 0; i < polygon.points.length; j = i, i++) { - var edge1 = es.Vector2.add(polygon.position, polygon.points[j]); - var edge2 = es.Vector2.add(polygon.position, polygon.points[i]); - var intersection = es.Vector2.zero; - if (this.lineToLine(edge1, edge2, start, end, intersection)) { - hasIntersection = true; - var distanceFraction = (intersection.x - start.x) / (end.x - start.x); - if (Number.isNaN(distanceFraction) || Number.isFinite(distanceFraction)) - distanceFraction = (intersection.y - start.y) / (end.y - start.y); - if (distanceFraction < fraction) { - var edge = es.Vector2.subtract(edge2, edge1); - normal = new es.Vector2(edge.y, -edge.x); - fraction = distanceFraction; - intersectionPoint = intersection; - } - } - } - if (hasIntersection) { - normal.normalize(); - var distance = es.Vector2.distance(start, intersectionPoint); - hit.setValuesNonCollider(fraction, distance, intersectionPoint, normal); - return true; - } - return false; - }; - ShapeCollisions.lineToLine = function (a1, a2, b1, b2, intersection) { - var b = es.Vector2.subtract(a2, a1); - var d = es.Vector2.subtract(b2, b1); - var bDotDPerp = b.x * d.y - b.y * d.x; - if (bDotDPerp == 0) - return false; - var c = es.Vector2.subtract(b1, a1); - var t = (c.x * d.y - c.y * d.x) / bDotDPerp; - if (t < 0 || t > 1) - return false; - var u = (c.x * b.y - c.y * b.x) / bDotDPerp; - if (u < 0 || u > 1) - return false; - intersection = intersection.add(a1).add(es.Vector2.multiply(new es.Vector2(t), b)); - return true; - }; - ShapeCollisions.lineToCircle = function (start, end, s, hit) { - var lineLength = es.Vector2.distance(start, end); - var d = es.Vector2.divide(es.Vector2.subtract(end, start), new es.Vector2(lineLength)); - var m = es.Vector2.subtract(start, s.position); - var b = es.Vector2.dot(m, d); - var c = es.Vector2.dot(m, m) - s.radius * s.radius; - if (c > 0 && b > 0) - return false; - var discr = b * b - c; - if (discr < 0) - return false; - hit.fraction = -b - Math.sqrt(discr); - if (hit.fraction < 0) - hit.fraction = 0; - hit.point = es.Vector2.add(start, es.Vector2.multiply(new es.Vector2(hit.fraction), d)); - hit.distance = es.Vector2.distance(start, hit.point); - hit.normal = es.Vector2.normalize(es.Vector2.subtract(hit.point, s.position)); - hit.fraction = hit.distance / lineLength; - return true; - }; - ShapeCollisions.boxToBoxCast = function (first, second, movement, hit) { - var minkowskiDiff = this.minkowskiDifference(first, second); - if (minkowskiDiff.contains(0, 0)) { - var mtv = minkowskiDiff.getClosestPointOnBoundsToOrigin(); - if (mtv.equals(es.Vector2.zero)) - return false; - hit.normal = new es.Vector2(-mtv.x); - hit.normal.normalize(); - hit.distance = 0; - hit.fraction = 0; - return true; - } - else { - var ray = new es.Ray2D(es.Vector2.zero, new es.Vector2(-movement.x)); - var fraction = new es.Ref(0); - if (minkowskiDiff.rayIntersects(ray, fraction) && fraction.value <= 1) { - hit.fraction = fraction.value; - hit.distance = movement.length() * fraction.value; - hit.normal = new es.Vector2(-movement.x, -movement.y); - hit.normal.normalize(); - hit.centroid = es.Vector2.add(first.bounds.center, es.Vector2.multiply(movement, new es.Vector2(fraction.value))); - return true; - } - } - return false; - }; - return ShapeCollisions; - }()); - es.ShapeCollisions = ShapeCollisions; -})(es || (es = {})); -var es; -(function (es) { - var Particle = (function () { - function Particle() { - this.mass = 1; - this.radius = 0; - this.collidesWithColliders = true; - } - Particle.prototype.applyForce = function (force) { - this.acceleration.add(es.Vector2.divide(force, new es.Vector2(this.mass))); - }; - return Particle; - }()); - es.Particle = Particle; -})(es || (es = {})); -var es; -(function (es) { - var VerletWorld = (function () { - function VerletWorld(simulationBounds) { - if (simulationBounds === void 0) { simulationBounds = null; } - this.gravity = new es.Vector2(0, 980); - this.constraintIterations = 3; - this.maximumStepIterations = 5; - this.allowDragging = true; - this._composites = []; - this._tempCircle = new es.Circle(1); - this._leftOverTime = 0; - this._fixedDeltaTime = 1 / 60; - this._iterationSteps = 0; - this._fixedDeltaTimeSq = 0; - this.simulationBounds = simulationBounds; - this._fixedDeltaTimeSq = Math.pow(this._fixedDeltaTimeSq, 2); - } - VerletWorld.prototype.update = function () { - this.updateTiming(); - if (this.allowDragging) - this.handleDragging(); - for (var iteration = 1; iteration <= this._iterationSteps; iteration++) { - for (var i = this._composites.length - 1; i >= 0; i--) { - var composite = this._composites[i]; - for (var s = 0; s < this.constraintIterations; s++) - composite.solveConstraints(); - composite.updateParticles(this._fixedDeltaTimeSq, this.gravity); - composite.handleConstraintCollisions(); - for (var j = 0; j < composite.particles.length; j++) { - var p = composite.particles[j]; - if (this.simulationBounds) { - this.constrainParticleToBounds(p); - } - if (p.collidesWithColliders) - this.handleCollisions(p, composite.collidesWithLayers); - } - } - } - }; - VerletWorld.prototype.handleCollisions = function (p, collidesWithLayers) { - var collidedCount = es.Physics.overlapCircleAll(p.position, p.radius, VerletWorld._colliders, collidesWithLayers); - for (var i = 0; i < collidedCount; i++) { - var collider = VerletWorld._colliders[i]; - if (collider.isTrigger) - continue; - var collisionResult = new es.CollisionResult(); - if (p.radius < 2) { - if (collider.shape.pointCollidesWithShape(p.position, collisionResult)) { - p.position.subtract(collisionResult.minimumTranslationVector); - } - } - else { - this._tempCircle.radius = p.radius; - this._tempCircle.position = p.position; - if (this._tempCircle.collidesWithShape(collider.shape, collisionResult)) { - p.position.subtract(collisionResult.minimumTranslationVector); - } - } - } - }; - VerletWorld.prototype.constrainParticleToBounds = function (p) { - var tempPos = p.position; - var bounds = this.simulationBounds; - if (p.radius == 0) { - if (tempPos.y > bounds.height) - tempPos.y = bounds.height; - else if (tempPos.y < bounds.y) - tempPos.y = bounds.y; - if (tempPos.x < bounds.x) - tempPos.x = bounds.x; - else if (tempPos.x > bounds.width) - tempPos.x = bounds.width; - } - else { - if (tempPos.y < bounds.y + p.radius) - tempPos.y = 2 * (bounds.y + p.radius) - tempPos.y; - if (tempPos.y > bounds.height - p.radius) - tempPos.y = 2 * (bounds.height - p.radius) - tempPos.y; - if (tempPos.x > bounds.width - p.radius) - tempPos.x = 2 * (bounds.width - p.radius) - tempPos.x; - if (tempPos.x < bounds.x + p.radius) - tempPos.x = 2 * (bounds.x + p.radius) - tempPos.x; - } - p.position = tempPos; - }; - VerletWorld.prototype.updateTiming = function () { - this._leftOverTime += es.Time.deltaTime; - this._iterationSteps = Math.floor(Math.trunc(this._leftOverTime / this._fixedDeltaTime)); - this._leftOverTime -= this._iterationSteps * this._fixedDeltaTime; - this._iterationSteps = Math.min(this._iterationSteps, this.maximumStepIterations); - }; - VerletWorld.prototype.addComposite = function (composite) { - this._composites.push(composite); - return composite; - }; - VerletWorld.prototype.removeComposite = function (composite) { - this._composites.remove(composite); - }; - VerletWorld.prototype.handleDragging = function () { - }; - VerletWorld.prototype.debugRender = function (camera) { - for (var i = 0; i < this._composites.length; i++) - this._composites[i].debugRender(camera); - }; - VerletWorld._colliders = new Array(4); - return VerletWorld; - }()); - es.VerletWorld = VerletWorld; -})(es || (es = {})); -var es; -(function (es) { - var Composite = (function () { - function Composite() { - this.friction = new es.Vector2(0.98, 1); - this.collidesWithLayers = es.Physics.allLayers; - this.particles = []; - this._constraints = []; - } - Composite.prototype.solveConstraints = function () { - for (var i = this._constraints.length - 1; i >= 0; i--) { - this._constraints[i].solve(); - } - }; - Composite.prototype.updateParticles = function (deltaTimeSquared, gravity) { - for (var j = 0; j < this.particles.length; j++) { - var p = this.particles[j]; - if (p.isPinned) { - p.position = p.pinnedPosition; - continue; - } - p.applyForce(es.Vector2.multiply(new es.Vector2(p.mass), gravity)); - var vel = es.Vector2.subtract(p.position, p.lastPosition).multiply(this.friction); - var nextPos = es.Vector2.add(p.position, vel).add(es.Vector2.multiply(new es.Vector2(0.5 * deltaTimeSquared), p.acceleration)); - p.lastPosition = p.position; - p.position = nextPos; - p.acceleration.x = p.acceleration.y = 0; - } - }; - Composite.prototype.handleConstraintCollisions = function () { - for (var i = this._constraints.length - 1; i >= 0; i--) { - if (this._constraints[i].collidesWithColliders) - this._constraints[i].handleCollisions(this.collidesWithLayers); - } - }; - Composite.prototype.debugRender = function (camera) { - }; - return Composite; - }()); - es.Composite = Composite; -})(es || (es = {})); -var es; -(function (es) { - var Constraint = (function () { - function Constraint() { - this.collidesWithColliders = true; - } - Constraint.prototype.handleCollisions = function (collidesWithLayers) { }; - return Constraint; - }()); - es.Constraint = Constraint; -})(es || (es = {})); -var ArrayUtils = (function () { - function ArrayUtils() { - } - ArrayUtils.bubbleSort = function (ary) { - var isExchange = false; - for (var i = 0; i < ary.length; i++) { - isExchange = false; - for (var j = ary.length - 1; j > i; j--) { - if (ary[j] < ary[j - 1]) { - var temp = ary[j]; - ary[j] = ary[j - 1]; - ary[j - 1] = temp; - isExchange = true; - } - } - if (!isExchange) - break; - } - }; - ArrayUtils.insertionSort = function (ary) { - var len = ary.length; - for (var i = 1; i < len; i++) { - var val = ary[i]; - for (var j = i; j > 0 && ary[j - 1] > val; j--) { - ary[j] = ary[j - 1]; - } - ary[j] = val; - } - }; - ArrayUtils.binarySearch = function (ary, value) { - var startIndex = 0; - var endIndex = ary.length; - var sub = (startIndex + endIndex) >> 1; - while (startIndex < endIndex) { - if (value <= ary[sub]) - endIndex = sub; - else if (value >= ary[sub]) - startIndex = sub + 1; - sub = (startIndex + endIndex) >> 1; - } - if (ary[startIndex] == value) - return startIndex; - return -1; - }; - ArrayUtils.findElementIndex = function (ary, num) { - var len = ary.length; - for (var i = 0; i < len; ++i) { - if (ary[i] == num) - return i; - } - return null; - }; - ArrayUtils.getMaxElementIndex = function (ary) { - var matchIndex = 0; - var len = ary.length; - for (var j = 1; j < len; j++) { - if (ary[j] > ary[matchIndex]) - matchIndex = j; - } - return matchIndex; - }; - ArrayUtils.getMinElementIndex = function (ary) { - var matchIndex = 0; - var len = ary.length; - for (var j = 1; j < len; j++) { - if (ary[j] < ary[matchIndex]) - matchIndex = j; - } - return matchIndex; - }; - ArrayUtils.getUniqueAry = function (ary) { - var uAry = []; - var newAry = []; - var count = ary.length; - for (var i = 0; i < count; ++i) { - var value = ary[i]; - if (uAry.indexOf(value) == -1) - uAry.push(value); - } - count = uAry.length; - for (var i = count - 1; i >= 0; --i) { - newAry.unshift(uAry[i]); - } - return newAry; - }; - ArrayUtils.getDifferAry = function (aryA, aryB) { - aryA = this.getUniqueAry(aryA); - aryB = this.getUniqueAry(aryB); - var ary = aryA.concat(aryB); - var uObj = {}; - var newAry = []; - var count = ary.length; - for (var j = 0; j < count; ++j) { - if (!uObj[ary[j]]) { - uObj[ary[j]] = {}; - uObj[ary[j]].count = 0; - uObj[ary[j]].key = ary[j]; - uObj[ary[j]].count++; - } - else { - if (uObj[ary[j]] instanceof Object) { - uObj[ary[j]].count++; - } - } - } - for (var i in uObj) { - if (uObj[i].count != 2) { - newAry.unshift(uObj[i].key); - } - } - return newAry; - }; - ArrayUtils.swap = function (array, index1, index2) { - var temp = array[index1]; - array[index1] = array[index2]; - array[index2] = temp; - }; - ArrayUtils.clearList = function (ary) { - if (!ary) - return; - var length = ary.length; - for (var i = length - 1; i >= 0; i -= 1) { - ary.splice(i, 1); - } - }; - ArrayUtils.cloneList = function (ary) { - if (!ary) - return null; - return ary.slice(0, ary.length); - }; - ArrayUtils.equals = function (ary1, ary2) { - if (ary1 == ary2) - return true; - var length = ary1.length; - if (length != ary2.length) - return false; - while (length--) { - if (ary1[length] != ary2[length]) - return false; - } - return true; - }; - ArrayUtils.insert = function (ary, index, value) { - if (!ary) - return null; - var length = ary.length; - if (index > length) - index = length; - if (index < 0) - index = 0; - if (index == length) - ary.push(value); - else if (index == 0) - ary.unshift(value); - else { - for (var i = length - 1; i >= index; i -= 1) { - ary[i + 1] = ary[i]; - } - ary[index] = value; - } - return value; - }; - return ArrayUtils; -}()); -var es; -(function (es) { - var Base64Utils = (function () { - function Base64Utils() { - } - Object.defineProperty(Base64Utils, "nativeBase64", { - get: function () { - return (typeof (window.atob) === "function"); - }, - enumerable: true, - configurable: true - }); - Base64Utils.decode = function (input) { - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - if (this.nativeBase64) { - return window.atob(input); - } - else { - var output = [], chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0; - while (i < input.length) { - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - output.push(String.fromCharCode(chr1)); - if (enc3 !== 64) { - output.push(String.fromCharCode(chr2)); - } - if (enc4 !== 64) { - output.push(String.fromCharCode(chr3)); - } - } - output = output.join(""); - return output; - } - }; - Base64Utils.encode = function (input) { - input = input.replace(/\r\n/g, "\n"); - if (this.nativeBase64) { - window.btoa(input); - } - else { - var output = [], chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0; - while (i < input.length) { - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } - else if (isNaN(chr3)) { - enc4 = 64; - } - output.push(this._keyStr.charAt(enc1)); - output.push(this._keyStr.charAt(enc2)); - output.push(this._keyStr.charAt(enc3)); - output.push(this._keyStr.charAt(enc4)); - } - output = output.join(""); - return output; - } - }; - Base64Utils.decodeBase64AsArray = function (input, bytes) { - bytes = bytes || 1; - var dec = Base64Utils.decode(input), i, j, len; - var ar = new Uint32Array(dec.length / bytes); - for (i = 0, len = dec.length / bytes; i < len; i++) { - ar[i] = 0; - for (j = bytes - 1; j >= 0; --j) { - ar[i] += dec.charCodeAt((i * bytes) + j) << (j << 3); - } - } - return ar; - }; - Base64Utils.decompress = function (data, decoded, compression) { - throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!"); - }; - Base64Utils.decodeCSV = function (input) { - var entries = input.replace("\n", "").trim().split(","); - var result = []; - for (var i = 0; i < entries.length; i++) { - result.push(+entries[i]); - } - return result; - }; - Base64Utils._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - return Base64Utils; - }()); - es.Base64Utils = Base64Utils; -})(es || (es = {})); -var es; -(function (es) { - var Color = (function () { - function Color(r, g, b, alpha) { - if (((r | g | b | alpha) & 0xFFFFFF00) != 0) { - var clampedR = es.MathHelper.clamp(r, 0, 255); - var clampedG = es.MathHelper.clamp(g, 0, 255); - var clampedB = es.MathHelper.clamp(b, 0, 255); - var clampedA = es.MathHelper.clamp(alpha, 0, 255); - this._packedValue = (clampedA << 24) | (clampedB << 16) | (clampedG << 8) | (clampedR); - } - else { - this._packedValue = (alpha << 24) | (b << 16) | (g << 8) | r; - } - } - Object.defineProperty(Color.prototype, "b", { - get: function () { - return this._packedValue >> 16; - }, - set: function (value) { - this._packedValue = (this._packedValue & 0xff00ffff) | (value << 16); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Color.prototype, "g", { - get: function () { - return this._packedValue >> 8; - }, - set: function (value) { - this._packedValue = (this._packedValue & 0xffff00ff) | (value << 8); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Color.prototype, "r", { - get: function () { - return this._packedValue; - }, - set: function (value) { - this._packedValue = (this._packedValue & 0xffffff00) | value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Color.prototype, "a", { - get: function () { - return this._packedValue >> 24; - }, - set: function (value) { - this._packedValue = (this._packedValue & 0x00ffffff) | (value << 24); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Color.prototype, "packedValue", { - get: function () { - return this._packedValue; - }, - set: function (value) { - this._packedValue = value; - }, - enumerable: true, - configurable: true - }); - Color.prototype.equals = function (other) { - return this._packedValue == other._packedValue; - }; - return Color; - }()); - es.Color = Color; -})(es || (es = {})); -var es; -(function (es) { - var ContentManager = (function () { - function ContentManager() { - this.loadedAssets = new Map(); - } - ContentManager.prototype.loadRes = function (name, local) { - var _this = this; - if (local === void 0) { local = true; } - return new Promise(function (resolve, reject) { - var res = _this.loadedAssets.get(name); - if (res) { - resolve(res); - return; - } - if (local) { - RES.getResAsync(name).then(function (data) { - _this.loadedAssets.set(name, data); - resolve(data); - }).catch(function (err) { - console.error("资源加载错误:", name, err); - reject(err); - }); - } - else { - RES.getResByUrl(name).then(function (data) { - _this.loadedAssets.set(name, data); - resolve(data); - }).catch(function (err) { - console.error("资源加载错误:", name, err); - reject(err); - }); - } - }); - }; - ContentManager.prototype.dispose = function () { - this.loadedAssets.forEach(function (value) { - var assetsToRemove = value; - if (RES.destroyRes(assetsToRemove)) - assetsToRemove.dispose(); - }); - this.loadedAssets.clear(); - }; - return ContentManager; - }()); - es.ContentManager = ContentManager; -})(es || (es = {})); -var es; -(function (es) { - var DrawUtils = (function () { - function DrawUtils() { - } - DrawUtils.getColorMatrix = function (color) { - var colorMatrix = [ - 1, 0, 0, 0, 0, - 0, 1, 0, 0, 0, - 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0 - ]; - colorMatrix[0] = Math.floor(color / 256 / 256) / 255; - colorMatrix[6] = Math.floor(color / 256 % 256) / 255; - colorMatrix[12] = color % 256 / 255; - return new egret.ColorMatrixFilter(colorMatrix); - }; - return DrawUtils; - }()); - es.DrawUtils = DrawUtils; -})(es || (es = {})); -var es; -(function (es) { - var EdgeExt = (function () { - function EdgeExt() { - } - EdgeExt.oppositeEdge = function (self) { - switch (self) { - case es.Edge.bottom: - return es.Edge.top; - case es.Edge.top: - return es.Edge.bottom; - case es.Edge.left: - return es.Edge.right; - case es.Edge.right: - return es.Edge.left; - } - }; - EdgeExt.isHorizontal = function (self) { - return self == es.Edge.right || self == es.Edge.left; - }; - EdgeExt.isVertical = function (self) { - return self == es.Edge.top || self == es.Edge.bottom; - }; - return EdgeExt; - }()); - es.EdgeExt = EdgeExt; -})(es || (es = {})); -var es; -(function (es) { - var FuncPack = (function () { - function FuncPack(func, context) { - this.func = func; - this.context = context; - } - return FuncPack; - }()); - es.FuncPack = FuncPack; - var Emitter = (function () { - function Emitter() { - this._messageTable = new Map(); - } - Emitter.prototype.addObserver = function (eventType, handler, context) { - var list = this._messageTable.get(eventType); - if (!list) { - list = []; - this._messageTable.set(eventType, list); - } - if (list.findIndex(function (funcPack) { return funcPack.func == handler; }) != -1) - console.warn("您试图添加相同的观察者两次"); - list.push(new FuncPack(handler, context)); - }; - Emitter.prototype.removeObserver = function (eventType, handler) { - var messageData = this._messageTable.get(eventType); - var index = messageData.findIndex(function (data) { return data.func == handler; }); - if (index != -1) - messageData.removeAt(index); - }; - Emitter.prototype.emit = function (eventType, data) { - var list = this._messageTable.get(eventType); - if (list) { - for (var i = list.length - 1; i >= 0; i--) - list[i].func.call(list[i].context, data); - } - }; - return Emitter; - }()); - es.Emitter = Emitter; -})(es || (es = {})); -var es; -(function (es) { - var Edge; - (function (Edge) { - Edge[Edge["top"] = 0] = "top"; - Edge[Edge["bottom"] = 1] = "bottom"; - Edge[Edge["left"] = 2] = "left"; - Edge[Edge["right"] = 3] = "right"; - })(Edge = es.Edge || (es.Edge = {})); -})(es || (es = {})); -var es; -(function (es) { - var Enumerable = (function () { - function Enumerable() { - } - Enumerable.repeat = function (element, count) { - var result = []; - while (count--) { - result.push(element); - } - return result; - }; - return Enumerable; - }()); - es.Enumerable = Enumerable; -})(es || (es = {})); -var es; -(function (es) { - var EqualityComparer = (function () { - function EqualityComparer() { - } - EqualityComparer.default = function () { - return new EqualityComparer(); - }; - EqualityComparer.prototype.equals = function (x, y) { - if (typeof x["equals"] == 'function') { - return x["equals"](y); - } - else { - return x === y; - } - }; - return EqualityComparer; - }()); - es.EqualityComparer = EqualityComparer; -})(es || (es = {})); -var es; -(function (es) { - var GlobalManager = (function () { - function GlobalManager() { - } - Object.defineProperty(GlobalManager.prototype, "enabled", { - get: function () { - return this._enabled; - }, - set: function (value) { - this.setEnabled(value); - }, - enumerable: true, - configurable: true - }); - GlobalManager.prototype.setEnabled = function (isEnabled) { - if (this._enabled != isEnabled) { - this._enabled = isEnabled; - if (this._enabled) { - this.onEnabled(); - } - else { - this.onDisabled(); - } - } - }; - GlobalManager.prototype.onEnabled = function () { - }; - GlobalManager.prototype.onDisabled = function () { - }; - GlobalManager.prototype.update = function () { - }; - return GlobalManager; - }()); - es.GlobalManager = GlobalManager; -})(es || (es = {})); -var es; -(function (es) { - var ListPool = (function () { - function ListPool() { - } - ListPool.warmCache = function (cacheCount) { - cacheCount -= this._objectQueue.length; - if (cacheCount > 0) { - for (var i = 0; i < cacheCount; i++) { - this._objectQueue.unshift([]); - } - } - }; - ListPool.trimCache = function (cacheCount) { - while (cacheCount > this._objectQueue.length) - this._objectQueue.shift(); - }; - ListPool.clearCache = function () { - this._objectQueue.length = 0; - }; - ListPool.obtain = function () { - if (this._objectQueue.length > 0) - return this._objectQueue.shift(); - return []; - }; - ListPool.free = function (obj) { - this._objectQueue.unshift(obj); - obj.length = 0; - }; - ListPool._objectQueue = []; - return ListPool; - }()); - es.ListPool = ListPool; -})(es || (es = {})); -var es; -(function (es) { - var NumberExtension = (function () { - function NumberExtension() { - } - NumberExtension.toNumber = function (value) { - if (value == undefined) - return 0; - return Number(value); - }; - return NumberExtension; - }()); - es.NumberExtension = NumberExtension; -})(es || (es = {})); -var es; -(function (es) { - var Pair = (function () { - function Pair(first, second) { - this.first = first; - this.second = second; - } - Pair.prototype.clear = function () { - this.first = this.second = null; - }; - Pair.prototype.equals = function (other) { - return this.first == other.first && this.second == other.second; - }; - return Pair; - }()); - es.Pair = Pair; -})(es || (es = {})); -var es; -(function (es) { - var Pool = (function () { - function Pool() { - } - Pool.warmCache = function (type, cacheCount) { - cacheCount -= this._objectQueue.length; - if (cacheCount > 0) { - for (var i = 0; i < cacheCount; i++) { - this._objectQueue.unshift(new type()); - } - } - }; - Pool.trimCache = function (cacheCount) { - while (cacheCount > this._objectQueue.length) - this._objectQueue.shift(); - }; - Pool.clearCache = function () { - this._objectQueue.length = 0; - }; - Pool.obtain = function (type) { - if (this._objectQueue.length > 0) - return this._objectQueue.shift(); - return new type(); - }; - Pool.free = function (obj) { - this._objectQueue.unshift(obj); - if (egret.is(obj, "IPoolable")) { - obj["reset"](); - } - }; - Pool._objectQueue = []; - return Pool; - }()); - es.Pool = Pool; -})(es || (es = {})); -var RandomUtils = (function () { - function RandomUtils() { - } - RandomUtils.randrange = function (start, stop, step) { - if (step === void 0) { step = 1; } - if (step == 0) - throw new Error('step 不能为 0'); - var width = stop - start; - if (width == 0) - throw new Error('没有可用的范围(' + start + ',' + stop + ')'); - if (width < 0) - width = start - stop; - var n = Math.floor((width + step - 1) / step); - return Math.floor(this.random() * n) * step + Math.min(start, stop); - }; - RandomUtils.randint = function (a, b) { - a = Math.floor(a); - b = Math.floor(b); - if (a > b) - a++; - else - b++; - return this.randrange(a, b); - }; - RandomUtils.randnum = function (a, b) { - return this.random() * (b - a) + a; - }; - RandomUtils.shuffle = function (array) { - array.sort(this._randomCompare); - return array; - }; - RandomUtils.choice = function (sequence) { - if (!sequence.hasOwnProperty("length")) - throw new Error('无法对此对象执行此操作'); - var index = Math.floor(this.random() * sequence.length); - if (sequence instanceof String) - return String(sequence).charAt(index); - else - return sequence[index]; - }; - RandomUtils.sample = function (sequence, num) { - var len = sequence.length; - if (num <= 0 || len < num) - throw new Error("采样数量不够"); - var selected = []; - var indices = []; - for (var i = 0; i < num; i++) { - var index = Math.floor(this.random() * len); - while (indices.indexOf(index) >= 0) - index = Math.floor(this.random() * len); - selected.push(sequence[index]); - indices.push(index); - } - return selected; - }; - RandomUtils.random = function () { - return Math.random(); - }; - RandomUtils.boolean = function (chance) { - if (chance === void 0) { chance = .5; } - return (this.random() < chance) ? true : false; - }; - RandomUtils._randomCompare = function (a, b) { - return (this.random() > .5) ? 1 : -1; - }; - return RandomUtils; -}()); -var es; -(function (es) { - var RectangleExt = (function () { - function RectangleExt() { - } - RectangleExt.getSide = function (rect, edge) { - switch (edge) { - case es.Edge.top: - return rect.top; - case es.Edge.bottom: - return rect.bottom; - case es.Edge.left: - return rect.left; - case es.Edge.right: - return rect.right; - } - }; - RectangleExt.union = function (first, point) { - var rect = new es.Rectangle(point.x, point.y, 0, 0); - var result = new es.Rectangle(); - result.x = Math.min(first.x, rect.x); - result.y = Math.min(first.y, rect.y); - result.width = Math.max(first.right, rect.right) - result.x; - result.height = Math.max(first.bottom, result.bottom) - result.y; - return result; - }; - RectangleExt.getHalfRect = function (rect, edge) { - switch (edge) { - case es.Edge.top: - return new es.Rectangle(rect.x, rect.y, rect.width, rect.height / 2); - case es.Edge.bottom: - return new es.Rectangle(rect.x, rect.y + rect.height / 2, rect.width, rect.height / 2); - case es.Edge.left: - return new es.Rectangle(rect.x, rect.y, rect.width / 2, rect.height); - case es.Edge.right: - return new es.Rectangle(rect.x + rect.width / 2, rect.y, rect.width / 2, rect.height); - } - }; - RectangleExt.getRectEdgePortion = function (rect, edge, size) { - if (size === void 0) { size = 1; } - switch (edge) { - case es.Edge.top: - return new es.Rectangle(rect.x, rect.y, rect.width, size); - case es.Edge.bottom: - return new es.Rectangle(rect.x, rect.y + rect.height - size, rect.width, size); - case es.Edge.left: - return new es.Rectangle(rect.x, rect.y, size, rect.height); - case es.Edge.right: - return new es.Rectangle(rect.x + rect.width - size, rect.y, size, rect.height); - } - }; - RectangleExt.expandSide = function (rect, edge, amount) { - amount = Math.abs(amount); - switch (edge) { - case es.Edge.top: - rect.y -= amount; - rect.height += amount; - break; - case es.Edge.bottom: - rect.height += amount; - break; - case es.Edge.left: - rect.x -= amount; - rect.width += amount; - break; - case es.Edge.right: - rect.width += amount; - break; - } - }; - RectangleExt.contract = function (rect, horizontalAmount, verticalAmount) { - rect.x += horizontalAmount; - rect.y += verticalAmount; - rect.width -= horizontalAmount * 2; - rect.height -= verticalAmount * 2; - }; - return RectangleExt; - }()); - es.RectangleExt = RectangleExt; -})(es || (es = {})); -var es; -(function (es) { - var Ref = (function () { - function Ref(value) { - this.value = value; - } - return Ref; - }()); - es.Ref = Ref; -})(es || (es = {})); -var es; -(function (es) { - var SubpixelNumber = (function () { - function SubpixelNumber() { - } - SubpixelNumber.prototype.update = function (amount) { - this.remainder += amount; - var motion = Math.trunc(this.remainder); - this.remainder -= motion; - return motion; - }; - SubpixelNumber.prototype.reset = function () { - this.remainder = 0; - }; - return SubpixelNumber; - }()); - es.SubpixelNumber = SubpixelNumber; -})(es || (es = {})); -var es; -(function (es) { - var Triangulator = (function () { - function Triangulator() { - this.triangleIndices = []; - this._triPrev = new Array(12); - this._triNext = new Array(12); - } - Triangulator.testPointTriangle = function (point, a, b, c) { - if (es.Vector2Ext.cross(es.Vector2.subtract(point, a), es.Vector2.subtract(b, a)) < 0) - return false; - if (es.Vector2Ext.cross(es.Vector2.subtract(point, b), es.Vector2.subtract(c, b)) < 0) - return false; - if (es.Vector2Ext.cross(es.Vector2.subtract(point, c), es.Vector2.subtract(a, c)) < 0) - return false; - return true; - }; - Triangulator.prototype.triangulate = function (points, arePointsCCW) { - if (arePointsCCW === void 0) { arePointsCCW = true; } - var count = points.length; - this.initialize(count); - var iterations = 0; - var index = 0; - while (count > 3 && iterations < 500) { - iterations++; - var isEar = true; - var a = points[this._triPrev[index]]; - var b = points[index]; - var c = points[this._triNext[index]]; - if (es.Vector2Ext.isTriangleCCW(a, b, c)) { - var k = this._triNext[this._triNext[index]]; - do { - if (Triangulator.testPointTriangle(points[k], a, b, c)) { - isEar = false; - break; - } - k = this._triNext[k]; - } while (k != this._triPrev[index]); - } - else { - isEar = false; - } - if (isEar) { - this.triangleIndices.push(this._triPrev[index]); - this.triangleIndices.push(index); - this.triangleIndices.push(this._triNext[index]); - this._triNext[this._triPrev[index]] = this._triNext[index]; - this._triPrev[this._triNext[index]] = this._triPrev[index]; - count--; - index = this._triPrev[index]; - } - else { - index = this._triNext[index]; - } - } - this.triangleIndices.push(this._triPrev[index]); - this.triangleIndices.push(index); - this.triangleIndices.push(this._triNext[index]); - if (!arePointsCCW) - this.triangleIndices.reverse(); - }; - Triangulator.prototype.initialize = function (count) { - this.triangleIndices.length = 0; - if (this._triNext.length < count) { - this._triNext.reverse(); - this._triNext = new Array(Math.max(this._triNext.length * 2, count)); - } - if (this._triPrev.length < count) { - this._triPrev.reverse(); - this._triPrev = new Array(Math.max(this._triPrev.length * 2, count)); - } - for (var i = 0; i < count; i++) { - this._triPrev[i] = i - 1; - this._triNext[i] = i + 1; - } - this._triPrev[0] = count - 1; - this._triNext[count - 1] = 0; - }; - return Triangulator; - }()); - es.Triangulator = Triangulator; -})(es || (es = {})); -var es; -(function (es) { - var Vector2Ext = (function () { - function Vector2Ext() { - } - Vector2Ext.isTriangleCCW = function (a, center, c) { - return this.cross(es.Vector2.subtract(center, a), es.Vector2.subtract(c, center)) < 0; - }; - Vector2Ext.halfVector = function () { - return new es.Vector2(0.5, 0.5); - }; - Vector2Ext.cross = function (u, v) { - return u.y * v.x - u.x * v.y; - }; - Vector2Ext.perpendicular = function (first, second) { - return new es.Vector2(-1 * (second.y - first.y), second.x - first.x); - }; - Vector2Ext.normalize = function (vec) { - var magnitude = Math.sqrt((vec.x * vec.x) + (vec.y * vec.y)); - if (magnitude > es.MathHelper.Epsilon) { - vec.divide(new es.Vector2(magnitude)); - } - else { - vec.x = vec.y = 0; - } - }; - Vector2Ext.transformA = function (sourceArray, sourceIndex, matrix, destinationArray, destinationIndex, length) { - for (var i = 0; i < length; i++) { - var position = sourceArray[sourceIndex + i]; - var destination = destinationArray[destinationIndex + i]; - destination.x = (position.x * matrix.m11) + (position.y * matrix.m21) + matrix.m31; - destination.y = (position.x * matrix.m12) + (position.y * matrix.m22) + matrix.m32; - destinationArray[destinationIndex + i] = destination; - } - }; - Vector2Ext.transformR = function (position, matrix, result) { - var x = (position.x * matrix.m11) + (position.y * matrix.m21) + matrix.m31; - var y = (position.x * matrix.m12) + (position.y * matrix.m22) + matrix.m32; - result.x = x; - result.y = y; - }; - Vector2Ext.transform = function (sourceArray, matrix, destinationArray) { - this.transformA(sourceArray, 0, matrix, destinationArray, 0, sourceArray.length); - }; - Vector2Ext.round = function (vec) { - return new es.Vector2(Math.round(vec.x), Math.round(vec.y)); - }; - return Vector2Ext; - }()); - es.Vector2Ext = Vector2Ext; -})(es || (es = {})); -var WebGLUtils = (function () { - function WebGLUtils() { - } - WebGLUtils.getContext = function () { - var canvas = document.getElementsByTagName('canvas')[0]; - return canvas.getContext('2d'); - }; - return WebGLUtils; -}()); -var es; -(function (es) { - var Layout = (function () { - function Layout() { - this.clientArea = new es.Rectangle(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this.safeArea = this.clientArea; - } - Layout.prototype.place = function (size, horizontalMargin, verticalMargine, alignment) { - var rc = new es.Rectangle(0, 0, size.x, size.y); - if ((alignment & Alignment.left) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width * horizontalMargin); - } - else if ((alignment & Alignment.right) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width * (1 - horizontalMargin)) - rc.width; - } - else if ((alignment & Alignment.horizontalCenter) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width - rc.width) / 2 + (horizontalMargin * this.clientArea.width); - } - else { - } - if ((alignment & Alignment.top) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height * verticalMargine); - } - else if ((alignment & Alignment.bottom) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height * (1 - verticalMargine)) - rc.height; - } - else if ((alignment & Alignment.verticalCenter) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height - rc.height) / 2 + (verticalMargine * this.clientArea.height); - } - else { - } - if (rc.left < this.safeArea.left) - rc.x = this.safeArea.left; - if (rc.right > this.safeArea.right) - rc.x = this.safeArea.right - rc.width; - if (rc.top < this.safeArea.top) - rc.y = this.safeArea.top; - if (rc.bottom > this.safeArea.bottom) - rc.y = this.safeArea.bottom - rc.height; - return rc; - }; - return Layout; - }()); - es.Layout = Layout; - var Alignment; - (function (Alignment) { - Alignment[Alignment["none"] = 0] = "none"; - Alignment[Alignment["left"] = 1] = "left"; - Alignment[Alignment["right"] = 2] = "right"; - Alignment[Alignment["horizontalCenter"] = 4] = "horizontalCenter"; - Alignment[Alignment["top"] = 8] = "top"; - Alignment[Alignment["bottom"] = 16] = "bottom"; - Alignment[Alignment["verticalCenter"] = 32] = "verticalCenter"; - Alignment[Alignment["topLeft"] = 9] = "topLeft"; - Alignment[Alignment["topRight"] = 10] = "topRight"; - Alignment[Alignment["topCenter"] = 12] = "topCenter"; - Alignment[Alignment["bottomLeft"] = 17] = "bottomLeft"; - Alignment[Alignment["bottomRight"] = 18] = "bottomRight"; - Alignment[Alignment["bottomCenter"] = 20] = "bottomCenter"; - Alignment[Alignment["centerLeft"] = 33] = "centerLeft"; - Alignment[Alignment["centerRight"] = 34] = "centerRight"; - Alignment[Alignment["center"] = 36] = "center"; - })(Alignment = es.Alignment || (es.Alignment = {})); -})(es || (es = {})); -var stopwatch; -(function (stopwatch) { - var Stopwatch = (function () { - function Stopwatch(getSystemTime) { - if (getSystemTime === void 0) { getSystemTime = _defaultSystemTimeGetter; } - this.getSystemTime = getSystemTime; - this._stopDuration = 0; - this._completeSlices = []; - } - Stopwatch.prototype.getState = function () { - if (this._startSystemTime === undefined) { - return State.IDLE; - } - else if (this._stopSystemTime === undefined) { - return State.RUNNING; - } - else { - return State.STOPPED; - } - }; - Stopwatch.prototype.isIdle = function () { - return this.getState() === State.IDLE; - }; - Stopwatch.prototype.isRunning = function () { - return this.getState() === State.RUNNING; - }; - Stopwatch.prototype.isStopped = function () { - return this.getState() === State.STOPPED; - }; - Stopwatch.prototype.slice = function () { - return this.recordPendingSlice(); - }; - Stopwatch.prototype.getCompletedSlices = function () { - return Array.from(this._completeSlices); - }; - Stopwatch.prototype.getCompletedAndPendingSlices = function () { - return this._completeSlices.concat([this.getPendingSlice()]); - }; - Stopwatch.prototype.getPendingSlice = function () { - return this.calculatePendingSlice(); - }; - Stopwatch.prototype.getTime = function () { - return this.caculateStopwatchTime(); - }; - Stopwatch.prototype.reset = function () { - this._startSystemTime = this._pendingSliceStartStopwatchTime = this._stopSystemTime = undefined; - this._stopDuration = 0; - this._completeSlices = []; - }; - Stopwatch.prototype.start = function (forceReset) { - if (forceReset === void 0) { forceReset = false; } - if (forceReset) { - this.reset(); - } - if (this._stopSystemTime !== undefined) { - var systemNow = this.getSystemTime(); - var stopDuration = systemNow - this._stopSystemTime; - this._stopDuration += stopDuration; - this._stopSystemTime = undefined; - } - else if (this._startSystemTime === undefined) { - var systemNow = this.getSystemTime(); - this._startSystemTime = systemNow; - this._pendingSliceStartStopwatchTime = 0; - } - }; - Stopwatch.prototype.stop = function (recordPendingSlice) { - if (recordPendingSlice === void 0) { recordPendingSlice = false; } - if (this._startSystemTime === undefined) { - return 0; - } - var systemTimeOfStopwatchTime = this.getSystemTimeOfCurrentStopwatchTime(); - if (recordPendingSlice) { - this.recordPendingSlice(this.caculateStopwatchTime(systemTimeOfStopwatchTime)); - } - this._stopSystemTime = systemTimeOfStopwatchTime; - return this.getTime(); - }; - Stopwatch.prototype.calculatePendingSlice = function (endStopwatchTime) { - if (this._pendingSliceStartStopwatchTime === undefined) { - return Object.freeze({ startTime: 0, endTime: 0, duration: 0 }); - } - if (endStopwatchTime === undefined) { - endStopwatchTime = this.getTime(); - } - return Object.freeze({ - startTime: this._pendingSliceStartStopwatchTime, - endTime: endStopwatchTime, - duration: endStopwatchTime - this._pendingSliceStartStopwatchTime - }); - }; - Stopwatch.prototype.caculateStopwatchTime = function (endSystemTime) { - if (this._startSystemTime === undefined) - return 0; - if (endSystemTime === undefined) - endSystemTime = this.getSystemTimeOfCurrentStopwatchTime(); - return endSystemTime - this._startSystemTime - this._stopDuration; - }; - Stopwatch.prototype.getSystemTimeOfCurrentStopwatchTime = function () { - return this._stopSystemTime === undefined ? this.getSystemTime() : this._stopSystemTime; - }; - Stopwatch.prototype.recordPendingSlice = function (endStopwatchTime) { - if (this._pendingSliceStartStopwatchTime !== undefined) { - if (endStopwatchTime === undefined) { - endStopwatchTime = this.getTime(); - } - var slice = this.calculatePendingSlice(endStopwatchTime); - this._pendingSliceStartStopwatchTime = slice.endTime; - this._completeSlices.push(slice); - return slice; - } - else { - return this.calculatePendingSlice(); - } - }; - return Stopwatch; - }()); - stopwatch.Stopwatch = Stopwatch; - var State; - (function (State) { - State["IDLE"] = "IDLE"; - State["RUNNING"] = "RUNNING"; - State["STOPPED"] = "STOPPED"; - })(State || (State = {})); - function setDefaultSystemTimeGetter(systemTimeGetter) { - if (systemTimeGetter === void 0) { systemTimeGetter = Date.now; } - _defaultSystemTimeGetter = systemTimeGetter; - } - stopwatch.setDefaultSystemTimeGetter = setDefaultSystemTimeGetter; - var _defaultSystemTimeGetter = Date.now; -})(stopwatch || (stopwatch = {})); -var es; -(function (es) { - var TimeRuler = (function () { - function TimeRuler() { - this.showLog = false; - this.markers = []; - this.stopwacth = new stopwatch.Stopwatch(); - this._markerNameToIdMap = new Map(); - this._rectShape1 = new egret.Shape(); - this._rectShape2 = new egret.Shape(); - this._rectShape3 = new egret.Shape(); - this._rectShape4 = new egret.Shape(); - this._rectShape5 = new egret.Shape(); - this._rectShape6 = new egret.Shape(); - this.logs = new Array(2); - for (var i = 0; i < this.logs.length; ++i) - this.logs[i] = new FrameLog(); - this.sampleFrames = this.targetSampleFrames = 1; - this.width = Math.floor(es.Core.graphicsDevice.viewport.width * 0.8); - es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); - this.onGraphicsDeviceReset(); - es.Core.Instance.stage.addChild(this._rectShape1); - es.Core.Instance.stage.addChild(this._rectShape2); - es.Core.Instance.stage.addChild(this._rectShape3); - es.Core.Instance.stage.addChild(this._rectShape4); - es.Core.Instance.stage.addChild(this._rectShape5); - es.Core.Instance.stage.addChild(this._rectShape6); - } - Object.defineProperty(TimeRuler, "Instance", { - get: function () { - if (!this._instance) - this._instance = new TimeRuler(); - return this._instance; - }, - enumerable: true, - configurable: true - }); - TimeRuler.prototype.startFrame = function () { - if (isNaN(this._updateCount)) - this._updateCount = 0; - var count = this._updateCount++; - if (this.enabled && (1 < count && count < TimeRuler.maxSampleFrames)) - return; - this.prevLog = this.logs[this.frameCount++ & 0x1]; - this.curLog = this.logs[this.frameCount & 0x1]; - var endFrameTime = this.stopwacth.getTime(); - for (var barIdx = 0; barIdx < this.prevLog.bars.length; ++barIdx) { - var prevBar = this.prevLog.bars[barIdx]; - var nextBar = this.curLog.bars[barIdx]; - for (var nest = 0; nest < prevBar.nestCount; ++nest) { - var markerIdx = prevBar.markerNests[nest]; - prevBar.markers[markerIdx].endTime = endFrameTime; - nextBar.markerNests[nest] = nest; - nextBar.markers[nest].markerId = prevBar.markers[markerIdx].markerId; - nextBar.markers[nest].beginTime = 0; - nextBar.markers[nest].endTime = -1; - nextBar.markers[nest].color = prevBar.markers[markerIdx].color; - } - for (var markerIdx = 0; markerIdx < prevBar.markCount; ++markerIdx) { - var duration = prevBar.markers[markerIdx].endTime - prevBar.markers[markerIdx].beginTime; - var markerId = prevBar.markers[markerIdx].markerId; - var m = this.markers[markerId]; - m.logs[barIdx].color = prevBar.markers[markerIdx].color; - if (!m.logs[barIdx].initialized) { - m.logs[barIdx].min = duration; - m.logs[barIdx].max = duration; - m.logs[barIdx].avg = duration; - m.logs[barIdx].initialized = true; - } - else { - m.logs[barIdx].min = Math.min(m.logs[barIdx].min, duration); - m.logs[barIdx].max = Math.min(m.logs[barIdx].max, duration); - m.logs[barIdx].avg += duration; - m.logs[barIdx].avg *= 0.5; - if (m.logs[barIdx].samples++ >= TimeRuler.logSnapDuration) { - m.logs[barIdx].snapMin = m.logs[barIdx].min; - m.logs[barIdx].snapMax = m.logs[barIdx].max; - m.logs[barIdx].snapAvg = m.logs[barIdx].avg; - m.logs[barIdx].samples = 0; - } - } - } - nextBar.markCount = prevBar.nestCount; - nextBar.nestCount = prevBar.nestCount; - } - this.stopwacth.reset(); - this.stopwacth.start(); - }; - TimeRuler.prototype.beginMark = function (markerName, color, barIndex) { - if (barIndex === void 0) { barIndex = 0; } - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) - throw new Error("barIndex argument out of range"); - var bar = this.curLog.bars[barIndex]; - if (bar.markCount >= TimeRuler.maxSamples) { - throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数"); - } - if (bar.nestCount >= TimeRuler.maxNestCall) { - throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数"); - } - var markerId = this._markerNameToIdMap.get(markerName); - if (isNaN(markerId)) { - markerId = this.markers.length; - this._markerNameToIdMap.set(markerName, markerId); - this.markers.push(new MarkerInfo(markerName)); - } - bar.markerNests[bar.nestCount++] = bar.markCount; - bar.markers[bar.markCount].markerId = markerId; - bar.markers[bar.markCount].color = color; - bar.markers[bar.markCount].beginTime = this.stopwacth.getTime(); - bar.markers[bar.markCount].endTime = -1; - bar.markCount++; - }; - TimeRuler.prototype.endMark = function (markerName, barIndex) { - if (barIndex === void 0) { barIndex = 0; } - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) - throw new Error("barIndex参数超出范围"); - var bar = this.curLog.bars[barIndex]; - if (bar.nestCount <= 0) { - throw new Error("先调用beginMark方法,再调用endMark方法"); - } - var markerId = this._markerNameToIdMap.get(markerName); - if (isNaN(markerId)) { - throw new Error("\u6807\u8BB0 " + markerName + " \u672A\u6CE8\u518C\u3002\u8BF7\u786E\u8BA4\u60A8\u6307\u5B9A\u7684\u540D\u79F0\u4E0E beginMark \u65B9\u6CD5\u4F7F\u7528\u7684\u540D\u79F0\u76F8\u540C"); - } - var markerIdx = bar.markerNests[--bar.nestCount]; - if (bar.markers[markerIdx].markerId != markerId) { - throw new Error("beginMark/endMark方法的调用顺序不正确,beginMark(A),beginMark(B),endMark(B),endMark(A),但你不能像beginMark(A),beginMark(B),endMark(A),endMark(B)这样调用。"); - } - bar.markers[markerIdx].endTime = this.stopwacth.getTime(); - }; - TimeRuler.prototype.getAverageTime = function (barIndex, markerName) { - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) { - throw new Error("barIndex参数超出范围"); - } - var result = 0; - var markerId = this._markerNameToIdMap.get(markerName); - if (markerId) { - result = this.markers[markerId].logs[barIndex].avg; - } - return result; - }; - TimeRuler.prototype.resetLog = function () { - this.markers.forEach(function (markerInfo) { - for (var i = 0; i < markerInfo.logs.length; ++i) { - markerInfo.logs[i].initialized = false; - markerInfo.logs[i].snapMin = 0; - markerInfo.logs[i].snapMax = 0; - markerInfo.logs[i].snapAvg = 0; - markerInfo.logs[i].min = 0; - markerInfo.logs[i].max = 0; - markerInfo.logs[i].avg = 0; - markerInfo.logs[i].samples = 0; - } - }); - }; - TimeRuler.prototype.render = function (position, width) { - if (position === void 0) { position = this._position; } - if (width === void 0) { width = this.width; } - if (!this.showLog) - return; - var height = 0; - var maxTime = 0; - this.prevLog.bars.forEach(function (bar) { - if (bar.markCount > 0) { - height += TimeRuler.barHeight + TimeRuler.barPadding * 2; - maxTime = Math.max(maxTime, bar.markers[bar.markCount - 1].endTime); - } - }); - var frameSpan = 1 / 60 * 1000; - var sampleSpan = this.sampleFrames * frameSpan; - if (maxTime > sampleSpan) { - this._frameAdjust = Math.max(0, this._frameAdjust) + 1; - } - else { - this._frameAdjust = Math.min(0, this._frameAdjust) - 1; - } - if (Math.max(this._frameAdjust) > TimeRuler.autoAdjustDelay) { - this.sampleFrames = Math.min(TimeRuler.maxSampleFrames, this.sampleFrames); - this.sampleFrames = Math.max(this.targetSampleFrames, Math.floor(maxTime / frameSpan) + 1); - this._frameAdjust = 0; - } - var msToPs = width / sampleSpan; - var startY = position.y - (height - TimeRuler.barHeight); - var y = startY; - var rc = new es.Rectangle(position.x, y, width, height); - this._rectShape1.graphics.clear(); - this._rectShape1.graphics.beginFill(0x000000, 128 / 255); - this._rectShape1.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape1.graphics.endFill(); - rc.height = TimeRuler.barHeight; - this._rectShape2.graphics.clear(); - for (var _i = 0, _a = this.prevLog.bars; _i < _a.length; _i++) { - var bar = _a[_i]; - rc.y = y + TimeRuler.barPadding; - if (bar.markCount > 0) { - for (var j = 0; j < bar.markCount; ++j) { - var bt = bar.markers[j].beginTime; - var et = bar.markers[j].endTime; - var sx = Math.floor(position.x + bt * msToPs); - var ex = Math.floor(position.x + et * msToPs); - rc.x = sx; - rc.width = Math.max(ex - sx, 1); - this._rectShape2.graphics.beginFill(bar.markers[j].color); - this._rectShape2.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape2.graphics.endFill(); - } - } - y += TimeRuler.barHeight + TimeRuler.barPadding; - } - rc = new es.Rectangle(position.x, startY, 1, height); - this._rectShape3.graphics.clear(); - for (var t = 1; t < sampleSpan; t += 1) { - rc.x = Math.floor(position.x + t * msToPs); - this._rectShape3.graphics.beginFill(0x808080); - this._rectShape3.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape3.graphics.endFill(); - } - this._rectShape4.graphics.clear(); - for (var i = 0; i <= this.sampleFrames; ++i) { - rc.x = Math.floor(position.x + frameSpan * i * msToPs); - this._rectShape4.graphics.beginFill(0xFFFFFF); - this._rectShape4.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape4.graphics.endFill(); - } - }; - TimeRuler.prototype.onGraphicsDeviceReset = function () { - var layout = new es.Layout(); - this._position = layout.place(new es.Vector2(this.width, TimeRuler.barHeight), 0, 0.01, es.Alignment.bottomCenter).location; - }; - TimeRuler.maxBars = 8; - TimeRuler.maxSamples = 256; - TimeRuler.maxNestCall = 32; - TimeRuler.barHeight = 8; - TimeRuler.maxSampleFrames = 4; - TimeRuler.logSnapDuration = 120; - TimeRuler.barPadding = 2; - TimeRuler.autoAdjustDelay = 30; - return TimeRuler; - }()); - es.TimeRuler = TimeRuler; - var FrameLog = (function () { - function FrameLog() { - this.bars = new Array(TimeRuler.maxBars); - this.bars.fill(new MarkerCollection(), 0, TimeRuler.maxBars); - } - return FrameLog; - }()); - es.FrameLog = FrameLog; - var MarkerCollection = (function () { - function MarkerCollection() { - this.markers = new Array(TimeRuler.maxSamples); - this.markCount = 0; - this.markerNests = new Array(TimeRuler.maxNestCall); - this.nestCount = 0; - this.markers.fill(new Marker(), 0, TimeRuler.maxSamples); - this.markerNests.fill(0, 0, TimeRuler.maxNestCall); - } - return MarkerCollection; - }()); - es.MarkerCollection = MarkerCollection; - var Marker = (function () { - function Marker() { - this.markerId = 0; - this.beginTime = 0; - this.endTime = 0; - this.color = 0x000000; - } - return Marker; - }()); - es.Marker = Marker; - var MarkerInfo = (function () { - function MarkerInfo(name) { - this.logs = new Array(TimeRuler.maxBars); - this.name = name; - this.logs.fill(new MarkerLog(), 0, TimeRuler.maxBars); - } - return MarkerInfo; - }()); - es.MarkerInfo = MarkerInfo; - var MarkerLog = (function () { - function MarkerLog() { - this.snapMin = 0; - this.snapMax = 0; - this.snapAvg = 0; - this.min = 0; - this.max = 0; - this.avg = 0; - this.samples = 0; - this.color = 0x000000; - this.initialized = false; - } - return MarkerLog; - }()); - es.MarkerLog = MarkerLog; -})(es || (es = {})); -var es; -(function (es) { - var Coroutine = (function () { - function Coroutine() { - } - Coroutine.waitForSeconds = function (seconds) { - return WaitForSeconds.waiter.wait(seconds); - }; - return Coroutine; - }()); - es.Coroutine = Coroutine; - var WaitForSeconds = (function () { - function WaitForSeconds() { - } - WaitForSeconds.prototype.wait = function (seconds) { - WaitForSeconds.waiter.waitTime = seconds; - return WaitForSeconds.waiter; - }; - WaitForSeconds.waiter = new WaitForSeconds(); - return WaitForSeconds; - }()); - es.WaitForSeconds = WaitForSeconds; -})(es || (es = {})); -var es; -(function (es) { - var CoroutineImpl = (function () { - function CoroutineImpl() { - this.useUnscaledDeltaTime = false; - } - CoroutineImpl.prototype.stop = function () { - this.isDone = true; - }; - CoroutineImpl.prototype.setUseUnscaledDeltaTime = function (useUnscaledDeltaTime) { - this.useUnscaledDeltaTime = useUnscaledDeltaTime; - return this; - }; - CoroutineImpl.prototype.prepareForuse = function () { - this.isDone = false; - }; - CoroutineImpl.prototype.reset = function () { - this.isDone = true; - this.waitTimer = 0; - this.waitForCoroutine = null; - this.enumerator = null; - this.useUnscaledDeltaTime = false; - }; - return CoroutineImpl; - }()); - es.CoroutineImpl = CoroutineImpl; - var CoroutineManager = (function (_super) { - __extends(CoroutineManager, _super); - function CoroutineManager() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._unblockedCoroutines = []; - _this._shouldRunNextFrame = []; - return _this; - } - CoroutineManager.prototype.startCoroutine = function (enumerator) { - var coroutine = es.Pool.obtain(CoroutineImpl); - coroutine.prepareForuse(); - coroutine.enumerator = enumerator; - var shouldContinueCoroutine = this.tickCoroutine(coroutine); - if (!shouldContinueCoroutine) - return null; - if (this._isInUpdate) - this._shouldRunNextFrame.push(coroutine); - else - this._unblockedCoroutines.push(coroutine); - return coroutine; - }; - CoroutineManager.prototype.update = function () { - this._isInUpdate = true; - for (var i = 0; i < this._unblockedCoroutines.length; i++) { - var coroutine = this._unblockedCoroutines[i]; - if (coroutine.isDone) { - es.Pool.free(coroutine); - continue; - } - if (coroutine.waitForCoroutine != null) { - if (coroutine.waitForCoroutine.isDone) { - coroutine.waitForCoroutine = null; - } - else { - this._shouldRunNextFrame.push(coroutine); - continue; - } - } - if (coroutine.waitTimer > 0) { - coroutine.waitTimer -= coroutine.useUnscaledDeltaTime ? es.Time.unscaledDeltaTime : es.Time.deltaTime; - this._shouldRunNextFrame.push(coroutine); - continue; - } - if (this.tickCoroutine(coroutine)) - this._shouldRunNextFrame.push(coroutine); - } - this._unblockedCoroutines.length = 0; - this._unblockedCoroutines.concat(this._shouldRunNextFrame); - this._shouldRunNextFrame.length = 0; - this._isInUpdate = false; - }; - CoroutineManager.prototype.tickCoroutine = function (coroutine) { - var current = coroutine.enumerator.next(); - if (!current.value || current.done) { - es.Pool.free(coroutine); - return false; - } - if (!current.value) { - return true; - } - if (current.value instanceof es.WaitForSeconds) { - coroutine.waitTimer = current.value.waitTime; - return true; - } - if (current.value instanceof Number) { - console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"); - coroutine.waitTimer = Number(current); - return true; - } - if (current.value instanceof CoroutineImpl) { - coroutine.waitForCoroutine = current.value; - return true; - } - else { - return true; - } - }; - return CoroutineManager; - }(es.GlobalManager)); - es.CoroutineManager = CoroutineManager; -})(es || (es = {})); -var es; -(function (es) { - var TouchState = (function () { - function TouchState() { - this.x = 0; - this.y = 0; - this.touchPoint = -1; - this.touchDown = false; - } - Object.defineProperty(TouchState.prototype, "position", { - get: function () { - return new es.Vector2(this.x, this.y); - }, - enumerable: true, - configurable: true - }); - TouchState.prototype.reset = function () { - this.x = 0; - this.y = 0; - this.touchDown = false; - this.touchPoint = -1; - }; - return TouchState; - }()); - es.TouchState = TouchState; - var Input = (function () { - function Input() { - } - Object.defineProperty(Input, "gameTouchs", { - get: function () { - return this._gameTouchs; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "resolutionScale", { - get: function () { - return this._resolutionScale; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "totalTouchCount", { - get: function () { - return this._totalTouchCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "touchPosition", { - get: function () { - if (!this._gameTouchs[0]) - return es.Vector2.zero; - return this._gameTouchs[0].position; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "maxSupportedTouch", { - get: function () { - return es.Core._instance.stage.maxTouches; - }, - set: function (value) { - es.Core._instance.stage.maxTouches = value; - this.initTouchCache(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "touchPositionDelta", { - get: function () { - var delta = es.Vector2.subtract(this.touchPosition, this._previousTouchState.position); - if (delta.length() > 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - return delta; - }, - enumerable: true, - configurable: true - }); - Input.initialize = function () { - if (this._init) - return; - this._init = true; - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this); - this.initTouchCache(); - }; - Input.update = function () { - KeyboardUtils.update(); - for (var i = 0; i < this._virtualInputs.length; i++) - this._virtualInputs[i].update(); - }; - Input.scaledPosition = function (position) { - var scaledPos = new es.Vector2(position.x - this._resolutionOffset.x, position.y - this._resolutionOffset.y); - return es.Vector2.multiply(scaledPos, this.resolutionScale); - }; - Input.isKeyPressed = function (key) { - return KeyboardUtils.currentKeys.contains(key) && !KeyboardUtils.previousKeys.contains(key); - }; - Input.isKeyPressedBoth = function (keyA, keyB) { - return this.isKeyPressed(keyA) || this.isKeyPressed(keyB); - }; - Input.isKeyDown = function (key) { - return KeyboardUtils.currentKeys.contains(key); - }; - Input.isKeyDownBoth = function (keyA, keyB) { - return this.isKeyDown(keyA) || this.isKeyDown(keyB); - }; - Input.isKeyReleased = function (key) { - return !KeyboardUtils.currentKeys.contains(key) && KeyboardUtils.previousKeys.contains(key); - }; - Input.isKeyReleasedBoth = function (keyA, keyB) { - return this.isKeyReleased(keyA) || this.isKeyReleased(keyB); - }; - Input.initTouchCache = function () { - this._totalTouchCount = 0; - this._touchIndex = 0; - this._gameTouchs.length = 0; - for (var i = 0; i < this.maxSupportedTouch; i++) { - this._gameTouchs.push(new TouchState()); - } - }; - Input.touchBegin = function (evt) { - if (this._touchIndex < this.maxSupportedTouch) { - this._gameTouchs[this._touchIndex].touchPoint = evt.touchPointID; - this._gameTouchs[this._touchIndex].touchDown = evt.touchDown; - this._gameTouchs[this._touchIndex].x = evt.stageX; - this._gameTouchs[this._touchIndex].y = evt.stageY; - if (this._touchIndex == 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - this._touchIndex++; - this._totalTouchCount++; - } - }; - Input.touchMove = function (evt) { - if (evt.touchPointID == this._gameTouchs[0].touchPoint) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); - if (touchIndex != -1) { - var touchData = this._gameTouchs[touchIndex]; - touchData.x = evt.stageX; - touchData.y = evt.stageY; - } - }; - Input.touchEnd = function (evt) { - var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); - if (touchIndex != -1) { - var touchData = this._gameTouchs[touchIndex]; - touchData.reset(); - if (touchIndex == 0) - this._previousTouchState.reset(); - this._totalTouchCount--; - if (this.totalTouchCount == 0) { - this._touchIndex = 0; - } - } - }; - Input.setpreviousTouchState = function (touchState) { - this._previousTouchState = new TouchState(); - this._previousTouchState.x = touchState.position.x; - this._previousTouchState.y = touchState.position.y; - this._previousTouchState.touchPoint = touchState.touchPoint; - this._previousTouchState.touchDown = touchState.touchDown; - }; - Input._init = false; - Input._previousTouchState = new TouchState(); - Input._resolutionOffset = new es.Vector2(); - Input._touchIndex = 0; - Input._gameTouchs = []; - Input._resolutionScale = es.Vector2.one; - Input._totalTouchCount = 0; - Input._virtualInputs = []; - return Input; - }()); - es.Input = Input; -})(es || (es = {})); -var Keys = es.Keys; -var KeyboardUtils = (function () { - function KeyboardUtils() { - } - KeyboardUtils.init = function () { - document.addEventListener("keydown", KeyboardUtils.onKeyDownHandler); - document.addEventListener("keyup", KeyboardUtils.onKeyUpHandler); - }; - KeyboardUtils.update = function () { - KeyboardUtils.previousKeys.length = 0; - for (var _i = 0, _a = KeyboardUtils.currentKeys; _i < _a.length; _i++) { - var key = _a[_i]; - KeyboardUtils.previousKeys.push(key); - KeyboardUtils.currentKeys.remove(key); - } - KeyboardUtils.currentKeys.length = 0; - for (var _b = 0, _c = KeyboardUtils.keyStatusKeys; _b < _c.length; _b++) { - var key = _c[_b]; - KeyboardUtils.currentKeys.push(key); - } - }; - KeyboardUtils.destroy = function () { - KeyboardUtils.currentKeys.length = 0; - document.removeEventListener("keyup", KeyboardUtils.onKeyUpHandler); - document.removeEventListener("keypress", KeyboardUtils.onKeyDownHandler); - }; - KeyboardUtils.onKeyDownHandler = function (event) { - if (!KeyboardUtils.keyStatusKeys.contains(event.keyCode)) - KeyboardUtils.keyStatusKeys.push(event.keyCode); - }; - KeyboardUtils.onKeyUpHandler = function (event) { - if (KeyboardUtils.keyStatusKeys.contains(event.keyCode)) - KeyboardUtils.keyStatusKeys.remove(event.keyCode); - }; - KeyboardUtils.currentKeys = []; - KeyboardUtils.previousKeys = []; - KeyboardUtils.keyStatusKeys = []; - return KeyboardUtils; -}()); -var es; -(function (es) { - var Keys; - (function (Keys) { - Keys[Keys["none"] = 0] = "none"; - Keys[Keys["back"] = 8] = "back"; - Keys[Keys["tab"] = 9] = "tab"; - Keys[Keys["enter"] = 13] = "enter"; - Keys[Keys["capsLock"] = 20] = "capsLock"; - Keys[Keys["escape"] = 27] = "escape"; - Keys[Keys["space"] = 32] = "space"; - Keys[Keys["pageUp"] = 33] = "pageUp"; - Keys[Keys["pageDown"] = 34] = "pageDown"; - Keys[Keys["end"] = 35] = "end"; - Keys[Keys["home"] = 36] = "home"; - Keys[Keys["left"] = 37] = "left"; - Keys[Keys["up"] = 38] = "up"; - Keys[Keys["right"] = 39] = "right"; - Keys[Keys["down"] = 40] = "down"; - Keys[Keys["select"] = 41] = "select"; - Keys[Keys["print"] = 42] = "print"; - Keys[Keys["execute"] = 43] = "execute"; - Keys[Keys["printScreen"] = 44] = "printScreen"; - Keys[Keys["insert"] = 45] = "insert"; - Keys[Keys["delete"] = 46] = "delete"; - Keys[Keys["help"] = 47] = "help"; - Keys[Keys["d0"] = 48] = "d0"; - Keys[Keys["d1"] = 49] = "d1"; - Keys[Keys["d2"] = 50] = "d2"; - Keys[Keys["d3"] = 51] = "d3"; - Keys[Keys["d4"] = 52] = "d4"; - Keys[Keys["d5"] = 53] = "d5"; - Keys[Keys["d6"] = 54] = "d6"; - Keys[Keys["d7"] = 55] = "d7"; - Keys[Keys["d8"] = 56] = "d8"; - Keys[Keys["d9"] = 57] = "d9"; - Keys[Keys["a"] = 65] = "a"; - Keys[Keys["b"] = 66] = "b"; - Keys[Keys["c"] = 67] = "c"; - Keys[Keys["d"] = 68] = "d"; - Keys[Keys["e"] = 69] = "e"; - Keys[Keys["f"] = 70] = "f"; - Keys[Keys["g"] = 71] = "g"; - Keys[Keys["h"] = 72] = "h"; - Keys[Keys["i"] = 73] = "i"; - Keys[Keys["j"] = 74] = "j"; - Keys[Keys["k"] = 75] = "k"; - Keys[Keys["l"] = 76] = "l"; - Keys[Keys["m"] = 77] = "m"; - Keys[Keys["n"] = 78] = "n"; - Keys[Keys["o"] = 79] = "o"; - Keys[Keys["p"] = 80] = "p"; - Keys[Keys["q"] = 81] = "q"; - Keys[Keys["r"] = 82] = "r"; - Keys[Keys["s"] = 83] = "s"; - Keys[Keys["t"] = 84] = "t"; - Keys[Keys["u"] = 85] = "u"; - Keys[Keys["v"] = 86] = "v"; - Keys[Keys["w"] = 87] = "w"; - Keys[Keys["x"] = 88] = "x"; - Keys[Keys["y"] = 89] = "y"; - Keys[Keys["z"] = 90] = "z"; - Keys[Keys["leftWindows"] = 91] = "leftWindows"; - Keys[Keys["rightWindows"] = 92] = "rightWindows"; - Keys[Keys["apps"] = 93] = "apps"; - Keys[Keys["sleep"] = 95] = "sleep"; - Keys[Keys["numPad0"] = 96] = "numPad0"; - Keys[Keys["numPad1"] = 97] = "numPad1"; - Keys[Keys["numPad2"] = 98] = "numPad2"; - Keys[Keys["numPad3"] = 99] = "numPad3"; - Keys[Keys["numPad4"] = 100] = "numPad4"; - Keys[Keys["numPad5"] = 101] = "numPad5"; - Keys[Keys["numPad6"] = 102] = "numPad6"; - Keys[Keys["numPad7"] = 103] = "numPad7"; - Keys[Keys["numPad8"] = 104] = "numPad8"; - Keys[Keys["numPad9"] = 105] = "numPad9"; - Keys[Keys["multiply"] = 106] = "multiply"; - Keys[Keys["add"] = 107] = "add"; - Keys[Keys["seperator"] = 108] = "seperator"; - Keys[Keys["subtract"] = 109] = "subtract"; - Keys[Keys["decimal"] = 110] = "decimal"; - Keys[Keys["divide"] = 111] = "divide"; - Keys[Keys["f1"] = 112] = "f1"; - Keys[Keys["f2"] = 113] = "f2"; - Keys[Keys["f3"] = 114] = "f3"; - Keys[Keys["f4"] = 115] = "f4"; - Keys[Keys["f5"] = 116] = "f5"; - Keys[Keys["f6"] = 117] = "f6"; - Keys[Keys["f7"] = 118] = "f7"; - Keys[Keys["f8"] = 119] = "f8"; - Keys[Keys["f9"] = 120] = "f9"; - Keys[Keys["f10"] = 121] = "f10"; - Keys[Keys["f11"] = 122] = "f11"; - Keys[Keys["f12"] = 123] = "f12"; - Keys[Keys["f13"] = 124] = "f13"; - Keys[Keys["f14"] = 125] = "f14"; - Keys[Keys["f15"] = 126] = "f15"; - Keys[Keys["f16"] = 127] = "f16"; - Keys[Keys["f17"] = 128] = "f17"; - Keys[Keys["f18"] = 129] = "f18"; - Keys[Keys["f19"] = 130] = "f19"; - Keys[Keys["f20"] = 131] = "f20"; - Keys[Keys["f21"] = 132] = "f21"; - Keys[Keys["f22"] = 133] = "f22"; - Keys[Keys["f23"] = 134] = "f23"; - Keys[Keys["f24"] = 135] = "f24"; - Keys[Keys["numLock"] = 144] = "numLock"; - Keys[Keys["scroll"] = 145] = "scroll"; - Keys[Keys["leftShift"] = 160] = "leftShift"; - Keys[Keys["rightShift"] = 161] = "rightShift"; - Keys[Keys["leftControl"] = 162] = "leftControl"; - Keys[Keys["rightControl"] = 163] = "rightControl"; - Keys[Keys["leftAlt"] = 164] = "leftAlt"; - Keys[Keys["rightAlt"] = 165] = "rightAlt"; - Keys[Keys["browserBack"] = 166] = "browserBack"; - Keys[Keys["browserForward"] = 167] = "browserForward"; - })(Keys = es.Keys || (es.Keys = {})); -})(es || (es = {})); -var es; -(function (es) { - var OverlapBehavior; - (function (OverlapBehavior) { - OverlapBehavior[OverlapBehavior["cancelOut"] = 0] = "cancelOut"; - OverlapBehavior[OverlapBehavior["takeOlder"] = 1] = "takeOlder"; - OverlapBehavior[OverlapBehavior["takeNewer"] = 2] = "takeNewer"; - })(OverlapBehavior = es.OverlapBehavior || (es.OverlapBehavior = {})); - var VirtualInput = (function () { - function VirtualInput() { - es.Input._virtualInputs.push(this); - } - VirtualInput.prototype.deregister = function () { - es.Input._virtualInputs.remove(this); - }; - return VirtualInput; - }()); - es.VirtualInput = VirtualInput; - var VirtualInputNode = (function () { - function VirtualInputNode() { - } - VirtualInputNode.prototype.update = function () { }; - return VirtualInputNode; - }()); - es.VirtualInputNode = VirtualInputNode; -})(es || (es = {})); -var es; -(function (es) { - var VirtualIntegerAxis = (function (_super) { - __extends(VirtualIntegerAxis, _super); - function VirtualIntegerAxis() { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i] = arguments[_i]; - } - var _this = _super.call(this) || this; - _this.nodes = []; - _this.nodes.concat(nodes); - return _this; - } - Object.defineProperty(VirtualIntegerAxis.prototype, "value", { - get: function () { - for (var i = 0; i < this.nodes.length; i++) { - var val = this.nodes[i].value; - if (val != 0) - return Math.sign(val); - } - return 0; - }, - enumerable: true, - configurable: true - }); - VirtualIntegerAxis.prototype.update = function () { - for (var i = 0; i < this.nodes.length; i++) - this.nodes[i].update(); - }; - VirtualIntegerAxis.prototype.addKeyboardKeys = function (overlapBehavior, negative, positive) { - this.nodes.push(new es.KeyboardKeys(overlapBehavior, negative, positive)); - return this; - }; - return VirtualIntegerAxis; - }(es.VirtualInput)); - es.VirtualIntegerAxis = VirtualIntegerAxis; - var VirtualAxisNode = (function (_super) { - __extends(VirtualAxisNode, _super); - function VirtualAxisNode() { - return _super !== null && _super.apply(this, arguments) || this; - } - return VirtualAxisNode; - }(es.VirtualInputNode)); - es.VirtualAxisNode = VirtualAxisNode; -})(es || (es = {})); -var es; -(function (es) { - var VirtualAxis = (function (_super) { - __extends(VirtualAxis, _super); - function VirtualAxis() { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i] = arguments[_i]; - } - var _this = _super.call(this) || this; - _this.nodes = []; - _this.nodes.concat(nodes); - return _this; - } - Object.defineProperty(VirtualAxis.prototype, "value", { - get: function () { - for (var i = 0; i < this.nodes.length; i++) { - var val = this.nodes[i].value; - if (val != 0) - return val; - } - return 0; - }, - enumerable: true, - configurable: true - }); - VirtualAxis.prototype.update = function () { - for (var i = 0; i < this.nodes.length; i++) - this.nodes[i].update(); - }; - return VirtualAxis; - }(es.VirtualInput)); - es.VirtualAxis = VirtualAxis; - var KeyboardKeys = (function (_super) { - __extends(KeyboardKeys, _super); - function KeyboardKeys(overlapBehavior, negative, positive) { - var _this = _super.call(this) || this; - _this._value = 0; - _this.overlapBehavior = overlapBehavior; - _this.negative = negative; - _this.positive = positive; - return _this; - } - KeyboardKeys.prototype.update = function () { - if (es.Input.isKeyDown(this.positive)) { - if (es.Input.isKeyDown(this.negative)) { - switch (this.overlapBehavior) { - default: - case es.OverlapBehavior.cancelOut: - this._value = 0; - break; - case es.OverlapBehavior.takeNewer: - if (!this._turned) { - this._value *= -1; - this._turned = true; - } - break; - case es.OverlapBehavior.takeOlder: - break; - } - } - else { - this._turned = false; - this._value = 1; - } - } - else if (es.Input.isKeyDown(this.negative)) { - this._turned = false; - this._value = -1; - } - else { - this._turned = false; - this._value = 0; - } - }; - Object.defineProperty(KeyboardKeys.prototype, "value", { - get: function () { - return this._value; - }, - enumerable: true, - configurable: true - }); - return KeyboardKeys; - }(es.VirtualAxisNode)); - es.KeyboardKeys = KeyboardKeys; -})(es || (es = {})); -var es; -(function (es) { - var VirtualButton = (function (_super) { - __extends(VirtualButton, _super); - function VirtualButton(bufferTime) { - if (bufferTime === void 0) { bufferTime = 0; } - var nodes = []; - for (var _i = 1; _i < arguments.length; _i++) { - nodes[_i - 1] = arguments[_i]; - } - var _this = _super.call(this) || this; - _this.nodes = []; - _this.bufferTime = 0; - _this.firstRepeatTime = 0; - _this.mutiRepeatTime = 0; - _this._bufferCounter = 0; - _this._repeatCounter = 0; - _this.nodes = nodes; - _this.bufferTime = bufferTime; - return _this; - } - VirtualButton.prototype.setRepeat = function (firstRepeatTime, mutiRepeatTime) { - if (mutiRepeatTime === void 0) { mutiRepeatTime = firstRepeatTime; } - this.firstRepeatTime = firstRepeatTime; - this.mutiRepeatTime = mutiRepeatTime; - this._willRepeat = this.firstRepeatTime > 0; - if (!this._willRepeat) - this.isRepeating = false; - }; - VirtualButton.prototype.update = function () { - this._bufferCounter -= es.Time.unscaledDeltaTime; - this.isRepeating = false; - var check = false; - for (var i = 0; i < this.nodes.length; i++) { - this.nodes[i].update(); - if (this.nodes[i].isPressed) { - this._bufferCounter = this.bufferTime; - check = true; - } - else if (this.nodes[i].isDown) { - check = true; - } - } - if (!check) { - this._repeatCounter = 0; - this._bufferCounter = 0; - } - else if (this._willRepeat) { - if (this._repeatCounter == 0) { - this._repeatCounter = this.firstRepeatTime; - } - else { - this._repeatCounter -= es.Time.unscaledDeltaTime; - if (this._repeatCounter <= 0) { - this.isRepeating = true; - this._repeatCounter = this.mutiRepeatTime; - } - } - } - }; - Object.defineProperty(VirtualButton.prototype, "isDown", { - get: function () { - for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.isDown) - return true; - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(VirtualButton.prototype, "isPressed", { - get: function () { - if (this._bufferCounter > 0 || this.isRepeating) - return true; - for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.isPressed) - return true; - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(VirtualButton.prototype, "isReleased", { - get: function () { - for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.isReleased) - return true; - } - return false; - }, - enumerable: true, - configurable: true - }); - VirtualButton.prototype.consumeBuffer = function () { - this._bufferCounter = 0; - }; - VirtualButton.prototype.addKeyboardKey = function (key) { - this.nodes.push(new KeyboardKey(key)); - return this; - }; - return VirtualButton; - }(es.VirtualInput)); - es.VirtualButton = VirtualButton; - var Node = (function (_super) { - __extends(Node, _super); - function Node() { - return _super !== null && _super.apply(this, arguments) || this; - } - return Node; - }(es.VirtualInputNode)); - es.Node = Node; - var KeyboardKey = (function (_super) { - __extends(KeyboardKey, _super); - function KeyboardKey(key) { - var _this = _super.call(this) || this; - _this.key = key; - return _this; - } - Object.defineProperty(KeyboardKey.prototype, "isDown", { - get: function () { - return es.Input.isKeyDown(this.key); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(KeyboardKey.prototype, "isPressed", { - get: function () { - return es.Input.isKeyPressed(this.key); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(KeyboardKey.prototype, "isReleased", { - get: function () { - return es.Input.isKeyReleased(this.key); - }, - enumerable: true, - configurable: true - }); - return KeyboardKey; - }(Node)); - es.KeyboardKey = KeyboardKey; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var AssetPacker = (function () { - function AssetPacker() { - this.itemsToRaster = []; - this.useCache = false; - this.cacheName = ""; - this._sprites = new Map(); - this.allow4096Textures = false; - } - AssetPacker.prototype.addTextureToPack = function (texture, customID) { - this.itemsToRaster.push(new es.TextureToPack(texture, customID)); - }; - AssetPacker.prototype.process = function (allow4096Textures) { - if (allow4096Textures === void 0) { allow4096Textures = false; } - return __awaiter(this, void 0, void 0, function () { - var cacheExist; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - this.allow4096Textures = allow4096Textures; - if (!this.useCache) return [3, 2]; - if (this.cacheName == "") { - console.error("未指定缓存名称"); - return [2]; - } - return [4, RES.getResByUrl(this.cacheName)]; - case 1: - cacheExist = _a.sent(); - if (!cacheExist) - this.createPack(); - else - this.loadPack(); - return [3, 3]; - case 2: - this.createPack(); - _a.label = 3; - case 3: return [2]; - } - }); - }); - }; - AssetPacker.prototype.loadPack = function () { - return __awaiter(this, void 0, void 0, function () { - var loaderTexture; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, RES.getResByUrl(this.cacheName)]; - case 1: - loaderTexture = _a.sent(); - if (this.onProcessCompleted) - this.onProcessCompleted(); - return [2, loaderTexture]; - } - }); - }); - }; - AssetPacker.prototype.createPack = function () { - var textures = []; - var images = []; - for (var _i = 0, _a = this.itemsToRaster; _i < _a.length; _i++) { - var itemToRaster = _a[_i]; - textures.push(new Bitmap(itemToRaster.texture)); - images.push(itemToRaster.id); - } - var textureSize = this.allow4096Textures ? 4096 : 2048; - var rectangles = []; - for (var i = 0; i < textures.length; i++) { - if (textures[i].width > textureSize || textures[i].height > textureSize) { - throw new Error("一个纹理的大小比图集的大小大"); - } - else { - rectangles.push(new es.Rectangle(0, 0, textures[i].width, textures[i].height)); - } - } - var padding = 1; - var numSpriteSheet = 0; - while (rectangles.length > 0) { - var texture = new egret.RenderTexture(); - var packer = new es.RectanglePacker(textureSize, textureSize, padding); - for (var i = 0; i < rectangles.length; i++) - packer.insertRectangle(Math.floor(rectangles[i].width), Math.floor(rectangles[i].height), i); - packer.packRectangles(); - if (packer.rectangleCount > 0) { - var rect = new es.IntegerRectangle(); - var textureAssets = []; - var garbageRect = []; - var garabeTextures = []; - var garbageImages = []; - for (var j = 0; j < packer.rectangleCount; j++) { - rect = packer.getRectangle(j, rect); - var index = packer.getRectangleId(j); - texture.drawToTexture(textures[index], new es.Rectangle(rect.x, rect.y, rect.width, rect.height)); - var textureAsset = new es.TextureAsset(); - textureAsset.x = rect.x; - textureAsset.y = rect.y; - textureAsset.width = rect.width; - textureAsset.height = rect.height; - textureAsset.name = images[index]; - textureAssets.push(textureAsset); - garbageRect.push(rectangles[index]); - garabeTextures.push(textures[index].texture); - garbageImages.push(images[index]); - } - for (var _b = 0, garbageRect_1 = garbageRect; _b < garbageRect_1.length; _b++) { - var garbage = garbageRect_1[_b]; - rectangles.remove(garbage); - } - var _loop_8 = function (garbage) { - textures.removeAll(function (a) { return a.texture.hashCode == garbage.hashCode; }); - }; - for (var _c = 0, garabeTextures_1 = garabeTextures; _c < garabeTextures_1.length; _c++) { - var garbage = garabeTextures_1[_c]; - _loop_8(garbage); - } - for (var _d = 0, garbageImages_1 = garbageImages; _d < garbageImages_1.length; _d++) { - var garbage = garbageImages_1[_d]; - images.remove(garbage); - } - if (this.cacheName != "") { - texture.saveToFile("image/png", this.cacheName); - ++numSpriteSheet; - } - for (var _e = 0, textureAssets_1 = textureAssets; _e < textureAssets_1.length; _e++) { - var textureAsset = textureAssets_1[_e]; - this._sprites.set(textureAsset.name, texture); - } - } - } - if (this.onProcessCompleted) - this.onProcessCompleted(); - }; - AssetPacker.prototype.dispose = function () { - this._sprites.forEach(function (asset, name) { - asset.dispose(); - RES.destroyRes(name); - }); - this._sprites.clear(); - }; - AssetPacker.prototype.getTexture = function (id) { - return this._sprites.get(id); - }; - return AssetPacker; - }()); - es.AssetPacker = AssetPacker; -})(es || (es = {})); -var es; -(function (es) { - var IntegerRectangle = (function (_super) { - __extends(IntegerRectangle, _super); - function IntegerRectangle() { - return _super !== null && _super.apply(this, arguments) || this; - } - return IntegerRectangle; - }(es.Rectangle)); - es.IntegerRectangle = IntegerRectangle; -})(es || (es = {})); -var es; -(function (es) { - var RectanglePacker = (function () { - function RectanglePacker(width, height, padding) { - if (padding === void 0) { padding = 0; } - this._width = 0; - this._height = 0; - this._padding = 8; - this._packedWidth = 0; - this._packedHeight = 0; - this._insertList = []; - this._insertedRectangles = []; - this._freeAreas = []; - this._newFreeAreas = []; - this._sortableSizeStack = []; - this._rectangleStack = []; - this._outsideRectangle = new es.IntegerRectangle(width + 1, height + 1, 0, 0); - this.reset(width, height, padding); - } - Object.defineProperty(RectanglePacker.prototype, "rectangleCount", { - get: function () { - return this._insertedRectangles.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RectanglePacker.prototype, "packedWidth", { - get: function () { - return this._packedWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RectanglePacker.prototype, "packedHeight", { - get: function () { - return this._packedHeight; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RectanglePacker.prototype, "padding", { - get: function () { - return this._padding; - }, - enumerable: true, - configurable: true - }); - RectanglePacker.prototype.reset = function (width, height, padding) { - if (padding === void 0) { padding = 0; } - while (this._insertedRectangles.length > 0) - this.freeRectangle(this._insertedRectangles.pop()); - while (this._freeAreas.length > 0) - this.freeRectangle(this._freeAreas.pop()); - this._width = width; - this._height = height; - this._packedWidth = 0; - this._packedHeight = 0; - this._freeAreas.push(this.allocateRectangle(0, 0, this._width, this._height)); - while (this._insertedRectangles.length > 0) - this.freeSize(this._insertList.pop()); - this._padding = padding; - }; - RectanglePacker.prototype.insertRectangle = function (width, height, id) { - var sortableSize = this.allocateSize(width, height, id); - this._insertList.push(sortableSize); - }; - RectanglePacker.prototype.packRectangles = function (sort) { - if (sort === void 0) { sort = true; } - if (sort) - this._insertList.sort(function (emp1, emp2) { - return emp1.width - emp2.width; - }); - while (this._insertList.length > 0) { - var sortableSize = this._insertList.pop(); - var width = sortableSize.width; - var height = sortableSize.height; - var index = this.getFreeAreaIndex(width, height); - if (index >= 0) { - var freeArea = this._freeAreas[index]; - var target = this.allocateRectangle(freeArea.x, freeArea.y, width, height); - target.id = sortableSize.id; - this.generateNewFreeAreas(target, this._freeAreas, this._newFreeAreas); - while (this._newFreeAreas.length > 0) - this._freeAreas.push(this._newFreeAreas.pop()); - this._insertedRectangles.push(target); - if (target.right > this._packedWidth) - this._packedWidth = target.right; - if (target.bottom > this._packedHeight) - this._packedHeight = target.bottom; - } - this.freeSize(sortableSize); - } - return this.rectangleCount; - }; - RectanglePacker.prototype.getRectangle = function (index, rectangle) { - var inserted = this._insertedRectangles[index]; - rectangle.x = inserted.x; - rectangle.y = inserted.y; - rectangle.width = inserted.width; - rectangle.height = inserted.height; - return rectangle; - }; - RectanglePacker.prototype.getRectangleId = function (index) { - var inserted = this._insertedRectangles[index]; - return inserted.id; - }; - RectanglePacker.prototype.generateNewFreeAreas = function (target, areas, results) { - var x = target.x; - var y = target.y; - var right = target.right + 1 + this._padding; - var bottom = target.bottom + 1 + this._padding; - var targetWithPadding = null; - if (this._padding == 0) - targetWithPadding = target; - for (var i = areas.length - 1; i >= 0; i--) { - var area = areas[i]; - if (!(x >= area.right || right <= area.x || y >= area.bottom || bottom <= area.y)) { - if (targetWithPadding == null) - targetWithPadding = this.allocateRectangle(target.x, target.y, target.width + this._padding, target.height + this._padding); - this.generateDividedAreas(targetWithPadding, area, results); - var topOfStack = areas.pop(); - if (i < areas.length) { - areas[i] = topOfStack; - } - } - } - if (targetWithPadding != null && targetWithPadding != target) - this.freeRectangle(targetWithPadding); - this.filterSelfSubAreas(results); - }; - RectanglePacker.prototype.filterSelfSubAreas = function (areas) { - for (var i = areas.length - 1; i >= 0; i--) { - var filtered = areas[i]; - for (var j = areas.length - 1; j >= 0; j--) { - if (i != j) { - var area = areas[j]; - if (filtered.x >= area.x && filtered.y >= area.y && filtered.right <= area.right && filtered.bottom <= area.bottom) { - this.freeRectangle(filtered); - var topOfStack = areas.pop(); - if (i < areas.length) { - areas[i] = topOfStack; - } - break; - } - } - } - } - }; - RectanglePacker.prototype.generateDividedAreas = function (divider, area, results) { - var count = 0; - var rightDelta = area.right - divider.right; - if (rightDelta > 0) { - results.push(this.allocateRectangle(divider.right, area.y, rightDelta, area.height)); - count++; - } - var leftDelta = divider.x - area.x; - if (leftDelta > 0) { - results.push(this.allocateRectangle(area.x, area.y, leftDelta, area.height)); - count++; - } - var bottomDelta = area.bottom - divider.bottom; - if (bottomDelta > 0) { - results.push(this.allocateRectangle(area.x, divider.bottom, area.width, bottomDelta)); - count++; - } - var topDelta = divider.y - area.y; - if (topDelta > 0) { - results.push(this.allocateRectangle(area.x, area.y, area.width, topDelta)); - count++; - } - if (count == 0 && (divider.width < area.width || divider.height < area.height)) { - results.push(area); - } - else { - this.freeRectangle(area); - } - }; - RectanglePacker.prototype.getFreeAreaIndex = function (width, height) { - var best = this._outsideRectangle; - var index = -1; - var paddedWidth = width + this._padding; - var paddedHeight = height + this._padding; - var count = this._freeAreas.length; - for (var i = count - 1; i >= 0; i--) { - var free = this._freeAreas[i]; - if (free.x < this._packedWidth || free.y < this.packedHeight) { - if (free.x < best.x && paddedWidth <= free.width && paddedHeight <= free.height) { - index = i; - if ((paddedWidth == free.width && free.width <= free.height && free.right < this._width) || - (paddedHeight == free.height && free.height <= free.width)) { - break; - } - best = free; - } - } - else { - if (free.x < best.x && width <= free.width && height <= free.height) { - index = i; - if ((width == free.width && free.width <= free.height && free.right < this._width) || - (height == free.height && free.height <= free.width)) { - break; - } - best = free; - } - } - } - return index; - }; - RectanglePacker.prototype.allocateSize = function (width, height, id) { - if (this._sortableSizeStack.length > 0) { - var size = this._sortableSizeStack.pop(); - size.width = width; - size.height = height; - size.id = id; - return size; - } - return new es.SortableSize(width, height, id); - }; - RectanglePacker.prototype.freeSize = function (size) { - this._sortableSizeStack.push(size); - }; - RectanglePacker.prototype.allocateRectangle = function (x, y, width, height) { - if (this._rectangleStack.length > 0) { - var rectangle = this._rectangleStack.pop(); - rectangle.x = x; - rectangle.y = y; - rectangle.width = width; - rectangle.height = height; - rectangle.right = x + width; - rectangle.bottom = y + height; - return rectangle; - } - return new es.IntegerRectangle(x, y, width, height); - }; - RectanglePacker.prototype.freeRectangle = function (rectangle) { - this._rectangleStack.push(rectangle); - }; - return RectanglePacker; - }()); - es.RectanglePacker = RectanglePacker; -})(es || (es = {})); -var es; -(function (es) { - var SortableSize = (function () { - function SortableSize(width, height, id) { - this.width = width; - this.height = height; - this.id = id; - } - return SortableSize; - }()); - es.SortableSize = SortableSize; -})(es || (es = {})); -var es; -(function (es) { - var TextureAssets = (function () { - function TextureAssets(assets) { - this.assets = assets; - } - return TextureAssets; - }()); - es.TextureAssets = TextureAssets; - var TextureAsset = (function () { - function TextureAsset() { - } - return TextureAsset; - }()); - es.TextureAsset = TextureAsset; -})(es || (es = {})); -var es; -(function (es) { - var TextureToPack = (function () { - function TextureToPack(texture, id) { - this.texture = texture; - this.id = id; - } - return TextureToPack; - }()); - es.TextureToPack = TextureToPack; -})(es || (es = {})); -var es; -(function (es) { - var Timer = (function () { - function Timer() { - this._timeInSeconds = 0; - this._repeats = false; - this._isDone = false; - this._elapsedTime = 0; - } - Timer.prototype.getContext = function () { - return this.context; - }; - Timer.prototype.reset = function () { - this._elapsedTime = 0; - }; - Timer.prototype.stop = function () { - this._isDone = true; - }; - Timer.prototype.tick = function () { - if (!this._isDone && this._elapsedTime > this._timeInSeconds) { - this._elapsedTime -= this._timeInSeconds; - this._onTime(this); - if (!this._isDone && !this._repeats) - this._isDone = true; - } - this._elapsedTime += es.Time.deltaTime; - return this._isDone; - }; - Timer.prototype.initialize = function (timeInsSeconds, repeats, context, onTime) { - this._timeInSeconds = timeInsSeconds; - this._repeats = repeats; - this.context = context; - this._onTime = onTime; - }; - Timer.prototype.unload = function () { - this.context = null; - this._onTime = null; - }; - return Timer; - }()); - es.Timer = Timer; -})(es || (es = {})); -var es; -(function (es) { - var TimerManager = (function (_super) { - __extends(TimerManager, _super); - function TimerManager() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._timers = []; - return _this; - } - TimerManager.prototype.update = function () { - for (var i = this._timers.length - 1; i >= 0; i--) { - if (this._timers[i].tick()) { - this._timers[i].unload(); - this._timers.removeAt(i); - } - } - }; - TimerManager.prototype.schedule = function (timeInSeconds, repeats, context, onTime) { - var timer = new es.Timer(); - timer.initialize(timeInSeconds, repeats, context, onTime); - this._timers.push(timer); - return timer; - }; - return TimerManager; - }(es.GlobalManager)); - es.TimerManager = TimerManager; -})(es || (es = {})); diff --git a/demo/libs/framework/framework.min.js b/demo/libs/framework/framework.min.js deleted file mode 100644 index 7e1100f6..00000000 --- a/demo/libs/framework/framework.min.js +++ /dev/null @@ -1 +0,0 @@ -window.es={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(s,a)}h((n=n.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,e){var i=t.findIndex(e);return-1==i?null:t[i]}(this,t)},Array.prototype.find=function(t){return function(t,e){return t.firstOrDefault(e)}(this,t)},Array.prototype.where=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return e.call(arguments[2],n,r,t)&&i.push(n),i},[]);for(var i=[],n=0,r=t.length;n=0&&t.splice(i,1)}while(i>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var i=t.findIndex(function(t){return t===e});return i>=0&&(t.splice(i,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,e){t.splice(e,1)}(this,t)},Array.prototype.removeRange=function(t,e){return function(t,e,i){t.splice(e,i)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return i.push(e.call(arguments[2],n,r,t)),i},[]);for(var i=[],n=0,r=t.length;no?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?-i(r,o):r0;){if("break"===u())break}return s?this.recontructPath(a,n,r):null},e.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},e.hasKey=function(e,i){for(var n,r=e.keys();!(n=r.next()).done;){if(n.value instanceof t.Vector2&&i instanceof t.Vector2&&n.value.equals(i))return!0;if(n.value==i)return!0}return!1},e.getKey=function(e,i){for(var n,r,o=e.keys(),s=e.values();n=o.next(),r=s.next(),!n.done;){if(n.value instanceof t.Vector2&&i instanceof t.Vector2&&n.value.equals(i))return r.value;if(n.value==i)return r.value}return null},e}();t.AStarPathfinder=e;var i=function(t){function e(e){var i=t.call(this)||this;return i.data=e,i}return __extends(e,t),e}(t.PriorityQueueNode)}(es||(es={})),function(t){var e=function(){function e(e,i){this.dirs=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,1)],this.walls=[],this.weightedNodes=[],this.defaultWeight=1,this.weightedNodeWeight=5,this._neighbors=new Array(4),this._width=e,this._height=i}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x=this._nodes.length?(console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"),!1):this._nodes[t.queueIndex]==t:(console.error("node cannot be null"),!1)},t.prototype.enqueue=function(t,e){t.priority=e,this._numNodes++,this._nodes[this._numNodes]=t,t.queueIndex=this._numNodes,t.insertionIndex=this._numNodesEverEnqueued++,this.cascadeUp(this._nodes[this._numNodes])},t.prototype.dequeue=function(){var t=this._nodes[1];return this.remove(t),t},t.prototype.remove=function(t){if(t.queueIndex==this._numNodes)return this._nodes[this._numNodes]=null,void this._numNodes--;var e=this._nodes[this._numNodes];this.swap(t,e),delete this._nodes[this._numNodes],this._numNodes--,this.onNodeUpdated(e)},t.prototype.isValidQueue=function(){for(var t=1;t0&&this.hasHigherPriority(t,i)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,i=t.queueIndex;;){e=t;var n=2*i;if(n>this._numNodes){t.queueIndex=i,this._nodes[i]=t;break}var r=this._nodes[n];this.hasHigherPriority(r,e)&&(e=r);var o=n+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=i,this._nodes[i]=t;break}this._nodes[i]=e;var a=e.queueIndex;e.queueIndex=i,i=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var i=this._nodes[e];if(this.hasHigherPriority(i,t))break;this.swap(t,i),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var i=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=i},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===h())break}return o?t.AStarPathfinder.recontructPath(a,i,n):null},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},e}();t.BreadthFirstPathfinder=e}(es||(es={})),function(t){var e=function(){function t(){this.edges=new Map}return t.prototype.addEdgesForNode=function(t,e){return this.edges.set(t,e),this},t.prototype.getNeighbors=function(t){return this.edges.get(t)},t}();t.UnweightedGraph=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.x=0,this.y=0,this.x=t||0,this.y=null!=e?e:this.x}return Object.defineProperty(e,"zero",{get:function(){return new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),e.add=function(t,i){var n=new e(0,0);return n.x=t.x+i.x,n.y=t.y+i.y,n},e.divide=function(t,i){var n=new e(0,0);return n.x=t.x/i.x,n.y=t.y/i.y,n},e.multiply=function(t,i){var n=new e(0,0);return n.x=t.x*i.x,n.y=t.y*i.y,n},e.subtract=function(t,i){var n=new e(0,0);return n.x=t.x-i.x,n.y=t.y-i.y,n},e.normalize=function(t){var i=new e(t.x,t.y),n=1/Math.sqrt(i.x*i.x+i.y*i.y);return i.x*=n,i.y*=n,i},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},e.clamp=function(i,n,r){return new e(t.MathHelper.clamp(i.x,n.x,r.x),t.MathHelper.clamp(i.y,n.y,r.y))},e.lerp=function(i,n,r){return new e(t.MathHelper.lerp(i.x,n.x,r),t.MathHelper.lerp(i.y,n.y,r))},e.transform=function(t,i){return new e(t.x*i.m11+t.y*i.m21+i.m31,t.x*i.m12+t.y*i.m22+i.m32)},e.distance=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},e.angle=function(i,n){return i=e.normalize(i),n=e.normalize(n),Math.acos(t.MathHelper.clamp(e.dot(i,n),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){return t.x=-t.x,t.y=-t.y,t},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.prototype.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);this.x*=t,this.y*=t},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.round=function(){return new e(Math.round(this.x),Math.round(this.y))},e.prototype.equals=function(t){return t instanceof e&&(t.x==this.x&&t.y==this.y)},e}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,i,n){void 0===n&&(n=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=i,this._dirs=n?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===u())break}return s?this.recontructPath(a,n,r):null},i.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},i.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},i.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},i}();t.WeightedPathfinder=i}(es||(es={})),function(t){var e=function(){function e(){this._opened=new Array(e.MAX_NODES),this._closed=new Array(e.MAX_NODES)}return e.prototype.clear=function(){for(var e=0;e0},e.prototype.removeOpened=function(t){this._numOpened>0&&(this._opened[this._lastFoundOpened]=this._opened[this._numOpened-1]),this._numOpened--},e.prototype.removeClosed=function(t){this._numClosed>0&&(this._closed[this._lastFoundClosed]=this._closed[this._numClosed-1]),this._numClosed--},e.prototype.isOpen=function(t){return this._opened.indexOf(t)>-1},e.prototype.isClosed=function(t){return this._closed.indexOf(t)>-1},e.prototype.addToOpenList=function(t){this._opened[this._numOpened++]=t},e.prototype.addToClosedList=function(t){this._closed[this._numClosed++]=t},e.prototype.removeCheapestOpenNode=function(){var t=Number.MAX_VALUE;this._lastFoundOpened=-1;for(var e=0;e-1?e:(this._actions.push(t),this._actions.length-1)},e.MAX_CONDITIONS=64,e}();t.ActionPlanner=e}(es||(es={})),function(t){var e=function(){function e(){this._planner=new t.ActionPlanner}return e.prototype.plan=function(e){void 0===e&&(e=!1);var i=null;if(e&&(i=[]),this.actions=this._planner.plan(this.getWorldState(),this.getGoalState(),i),null!=i&&i.length>0){console.log("---- ActionPlanner plan ----"),console.log("plan cost = "+i[i.length-1].costSoFar),console.log(" start\t"+this.getWorldState().describe(this._planner));for(var n=0;n0},e}();t.Agent=e}(es||(es={})),function(t){var e=function(){function e(t,e,i){this.planner=t,this.values=e,this.dontCare=i}return e.create=function(t){return new e(t,0,-1)},e.prototype.set=function(t,e){return"string"==typeof t?this.set(this.planner.findConditionNameIndex(t),e):(this.values=e?this.values|1<0&&(i+=", "),i+=o?r.toUpperCase():r}return i},e}();t.WorldState=e}(es||(es={})),function(t){var e=function(e){function i(){var n=e.call(this)||this;return n._globalManagers=[],n._coroutineManager=new t.CoroutineManager,n._timerManager=new t.TimerManager,n._frameCounterElapsedTime=0,n._frameCounter=0,i._instance=n,i.emitter=new t.Emitter,i.content=new t.ContentManager,n.addEventListener(egret.Event.ADDED_TO_STAGE,n.onAddToStage,n),i.registerGlobalManager(n._coroutineManager),i.registerGlobalManager(n._timerManager),n}return __extends(i,e),Object.defineProperty(i,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(i,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance.addChild(t),this._instance._scene=t,this._instance._scene.begin(),i.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),i.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},i.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},i.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},i.getGlobalManager=function(t){for(var e=0;e=1&&(this._frameCounter=0,this._frameCounterElapsedTime-=1)},i.prototype.endDebugDraw=function(){t.TimeRuler.Instance.endMark("draw"),t.TimeRuler.Instance.render()},i.prototype.onSceneChanged=function(){i.emitter.emit(t.CoreEvents.SceneChanged),t.Time.sceneChanged()},i.prototype.onGraphicsDeviceReset=function(){i.emitter.emit(t.CoreEvents.GraphicsDeviceReset)},i.prototype.initialize=function(){t.Graphics.Instance=new t.Graphics},i.prototype.update=function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(i){switch(i.label){case 0:if(t.Time.update(egret.getTimer()),t.Input.update(),!this._scene)return[3,2];for(e=this._globalManagers.length-1;e>=0;e--)this._globalManagers[e].enabled&&this._globalManagers[e].update();return this._sceneTransition&&(!this._sceneTransition||this._sceneTransition.loadsNewScene&&!this._sceneTransition.isNewSceneLoaded)||this._scene.update(),this._nextScene?(this._scene.parent&&this._scene.parent.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),[4,this._scene.begin()]):[3,2];case 1:i.sent(),this.addChild(this._scene),i.label=2;case 2:return[4,this.draw()];case 3:return i.sent(),[2]}})})},i.prototype.onAddToStage=function(){i.graphicsDevice=new t.GraphicsDevice,this.addEventListener(egret.Event.RESIZE,this.onGraphicsDeviceReset,this),this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE,this.onOrientationChanged,this),this.addEventListener(egret.Event.ENTER_FRAME,this.update,this),t.Input.initialize(),KeyboardUtils.init(),this.initialize()},i.debugRenderEndabled=!1,i}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){var e=function(){function t(){}return t.renderableBounds=16776960,t.renderableCenter=10040012,t.colliderBounds=5592405,t.colliderEdge=9109504,t.colliderPosition=16776960,t.colliderCenter=16711680,t}();t.Colors=e;var i=function(){function e(){}return Object.defineProperty(e,"lineSizeMultiplier",{get:function(){return Math.max(Math.ceil(t.Core.scene.x/t.Core.scene.width),1)},enumerable:!0,configurable:!0}),e}();t.Size=i;var n=function(){function e(){}return e.drawHollowRect=function(e,i,n){void 0===n&&(n=0),this._debugDrawItems.push(new t.DebugDrawItem(e,i,n))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var i=this._debugDrawItems.length-1;i>=0;i--){this._debugDrawItems[i].draw(e)&&this._debugDrawItems.removeAt(i)}}},e._debugDrawItems=[],e}();t.Debug=n}(es||(es={})),function(t){var e=function(){function t(){}return t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefaults=e}(es||(es={})),function(t){var e;!function(t){t[t.line=0]="line",t[t.hollowRectangle=1]="hollowRectangle",t[t.pixel=2]="pixel",t[t.text=3]="text"}(e=t.DebugDrawType||(t.DebugDrawType={}));var i=function(){function i(t,i,n){this.rectangle=t,this.color=i,this.duration=n,this.drawType=e.hollowRectangle}return i.prototype.draw=function(i){switch(this.drawType){case e.line:case e.hollowRectangle:case e.pixel:case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},i}();t.DebugDrawItem=i}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e.debugDisplayObject=new egret.DisplayObjectContainer,e._enabled=!0,e._updateOrder=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"transform",{get:function(){return this.entity.transform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this.entity?this.entity.enabled&&this._enabled:this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onAddedToEntity=function(){},e.prototype.onRemovedFromEntity=function(){},e.prototype.onEntityTransformChanged=function(t){},e.prototype.debugRender=function(t){},e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},e.prototype.setUpdateOrder=function(t){return this._updateOrder!=t&&(this._updateOrder=t),this},e}(egret.HashObject);t.Component=e}(es||(es={})),function(t){!function(t){t[t.GraphicsDeviceReset=0]="GraphicsDeviceReset",t[t.SceneChanged=1]="SceneChanged",t[t.OrientationChanged=2]="OrientationChanged"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function e(i){this.updateInterval=1,this._tag=0,this._enabled=!0,this._updateOrder=0,this.components=new t.ComponentList(this),this.transform=new t.Transform(this),this.name=i,this.id=e._idGenerator++,this.componentBits=new t.BitSet}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),e.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},e.prototype.setTag=function(t){return this._tag!=t&&(this.scene&&this.scene.entities.removeFromTagList(this),this._tag=t,this.scene&&this.scene.entities.addToTagList(this)),this},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},e.prototype.setUpdateOrder=function(t){if(this._updateOrder!=t)return this._updateOrder=t,this.scene&&(this.scene.entities.markEntityListUnsorted(),this.scene.entities.markTagUnsorted(this.tag)),this},e.prototype.destroy=function(){this._isDestroyed=!0,this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destroy()}},e.prototype.detachFromScene=function(){this.scene.entities.remove(this),this.components.deregisterAllComponents();for(var t=0;t=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),this.entityProcessors&&this.entityProcessors.lateUpdate(),this.renderableComponents.updateList()},i.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,n=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=i*Math.acos(t.Vector2.dot(n,t.Vector2.unitY))},n.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},n.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},n.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},n.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},n.prototype.roundPosition=function(){this.position=this._position.round()},n.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(this._translationMatrix=t.Matrix2D.create().translate(this._localPosition.x,this._localPosition.y),this._localPositionDirty=!1),this._localRotationDirty&&(this._rotationMatrix=t.Matrix2D.create().rotate(this._localRotation),this._localRotationDirty=!1),this._localScaleDirty&&(this._scaleMatrix=t.Matrix2D.create().scale(this._localScale.x,this._localScale.y),this._localScaleDirty=!1),this._localTransform=this._scaleMatrix.multiply(this._rotationMatrix),this._localTransform=this._localTransform.multiply(this._translationMatrix),this.parent||(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),this.parent&&(this._worldTransform=this._localTransform.multiply(this.parent._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=t.Vector2.multiply(this.parent._scale,this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},n.prototype.setDirty=function(e){if(0==(this.hierarchyDirty&e)){switch(this.hierarchyDirty|=e,e){case t.DirtyType.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case t.DirtyType.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case t.DirtyType.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}this._children||(this._children=[]);for(var i=0;it&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},i.prototype.forceMatrixUpdate=function(){this._areMatrixedDirty=!0},i.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},i.prototype.zoomIn=function(t){this.zoom+=t},i.prototype.zoomOut=function(t){this.zoom-=t},i.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),t.Vector2Ext.transformR(e,this._transformMatrix,e),e},i.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),t.Vector2Ext.transformR(e,this._inverseTransformMatrix,e),e},i.prototype.onSceneRenderTargetSizeChanged=function(e,i){this._isProjectionMatrixDirty=!0;var n=this._origin;this.origin=new t.Vector2(e/2,i/2),this.entity.transform.position.add(t.Vector2.subtract(this._origin,n))},i.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},i.prototype.updateMatrixes=function(){var e;this._areMatrixedDirty&&(this._transformMatrix=t.Matrix2D.create().translate(-this.entity.transform.position.x,-this.entity.transform.position.y),1!=this._zoom&&(e=t.Matrix2D.create().scale(this._zoom,this._zoom),this._transformMatrix=this._transformMatrix.multiply(e)),0!=this.entity.transform.rotation&&(e=t.Matrix2D.create().rotate(this.entity.transform.rotation),this._transformMatrix=this._transformMatrix.multiply(e)),e=t.Matrix2D.create().translate(Math.floor(this._origin.x),Math.floor(this._origin.y)),this._transformMatrix=this._transformMatrix.multiply(e),this._inverseTransformMatrix=this._transformMatrix.invert(),this._areBoundsDirty=!0,this._areMatrixedDirty=!1)},i}(t.Component);t.Camera=e}(es||(es={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._shakeDirection=t.Vector2.zero,i._shakeOffset=t.Vector2.zero,i._shakeIntensity=0,i._shakeDegredation=.95,i}return __extends(i,e),i.prototype.shake=function(e,i,n){void 0===e&&(e=15),void 0===i&&(i=.9),void 0===n&&(n=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(i=.95),this._shakeDegredation=i)},i.prototype.update=function(){Math.abs(this._shakeIntensity)>0&&(this._shakeOffset=this._shakeDirection,0!=this._shakeOffset.x||0!=this._shakeOffset.y?this._shakeOffset.normalize():(this._shakeOffset.x=this._shakeOffset.x+Math.random()-.5,this._shakeOffset.y=this._shakeOffset.y+Math.random()-.5),this._shakeOffset.multiply(new t.Vector2(this._shakeIntensity)),this._shakeIntensity*=-this._shakeDegredation,Math.abs(this._shakeIntensity)<=.01&&(this._shakeIntensity=0,this.enabled=!1)),this.entity.scene.camera.position.add(this._shakeOffset)},i}(t.Component);t.CameraShake=e}(es||(es={})),function(t){var e=function(){function t(t){this._type=t,this._cache=[]}return t.prototype.obtain=function(){try{return this._cache.length>0?this._cache.shift():new this._type}catch(t){throw new Error(this._type+t)}},t.prototype.free=function(t){t.reset(),this._cache.push(t)},t}();t.ComponentPool=e}(es||(es={})),function(t){var e;!function(t){t[t.lockOn=0]="lockOn",t[t.cameraWindow=1]="cameraWindow"}(e=t.CameraStyle||(t.CameraStyle={}));var i=function(i){function n(n,r,o){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=e.lockOn);var s=i.call(this)||this;return s.followLerp=.1,s.deadzone=new t.Rectangle,s.focusOffset=t.Vector2.zero,s.mapLockEnabled=!1,s.mapSize=new t.Rectangle,s._desiredPositionDelta=new t.Vector2,s._worldSpaceDeadZone=new t.Rectangle,s.rectShape=new egret.Shape,s._targetEntity=n,s._cameraStyle=o,s.camera=r,s}return __extends(n,i),n.prototype.onAddedToEntity=function(){this.camera||(this.camera=this.entity.scene.camera),this.follow(this._targetEntity,this._cameraStyle),t.Core.emitter.addObserver(t.CoreEvents.GraphicsDeviceReset,this.onGraphicsDeviceReset,this)},n.prototype.onGraphicsDeviceReset=function(){t.Core.schedule(0,!1,this,function(t){var e=t.context;e.follow(e._targetEntity,e._cameraStyle)})},n.prototype.update=function(){var e=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5));this._worldSpaceDeadZone.x=this.camera.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.camera.position.y-e.y*t.Core.scene.scaleY+this.deadzone.y+this.focusOffset.y,this._worldSpaceDeadZone.width=this.deadzone.width,this._worldSpaceDeadZone.height=this.deadzone.height,this._targetEntity&&this.updateFollow(),this.camera.position=t.Vector2.lerp(this.camera.position,t.Vector2.add(this.camera.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.camera.position=this.clampToMapSize(this.camera.position),this.entity.transform.roundPosition())},n.prototype.debugRender=function(t){this.rectShape||this.debugDisplayObject.addChild(this.rectShape),this.rectShape.graphics.clear(),this._cameraStyle==e.lockOn?(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x-5-t.bounds.x,this._worldSpaceDeadZone.y-5-t.bounds.y,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill()):(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x-t.bounds.x,this._worldSpaceDeadZone.y-t.bounds.y,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill())},n.prototype.clampToMapSize=function(e){var i=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),n=new t.Vector2(this.mapSize.width-i.x,this.mapSize.height-i.y);return t.Vector2.clamp(e,i,n)},n.prototype.follow=function(i,n){void 0===n&&(n=e.cameraWindow),this._targetEntity=i,this._cameraStyle=n;var r=this.camera.bounds;switch(this._cameraStyle){case e.cameraWindow:var o=r.width/6,s=r.height/3;this.deadzone=new t.Rectangle((r.width-o)/2,(r.height-s)/2,o,s);break;case e.lockOn:this.deadzone=new t.Rectangle(r.width/2,r.height/2,10,10)}},n.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var i=this._targetEntity.transform.position.x,n=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>i?this._desiredPositionDelta.x=i-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xn&&(this._desiredPositionDelta.y=n-this._worldSpaceDeadZone.y)}else{if(!this._targetCollider&&(this._targetCollider=this._targetEntity.getComponent(t.Collider),!this._targetCollider))return;var r=this._targetEntity.getComponent(t.Collider).bounds;this._worldSpaceDeadZone.containsRect(r)||(this._worldSpaceDeadZone.left>r.left?this._desiredPositionDelta.x=r.left-this._worldSpaceDeadZone.left:this._worldSpaceDeadZone.rightr.top&&(this._desiredPositionDelta.y=r.top-this._worldSpaceDeadZone.top))}},n.prototype.setCenteredDeadzone=function(e,i){if(this.camera){var n=this.camera.bounds;this.deadzone=new t.Rectangle((n.width-e)/2,(n.height-i)/2,e,i)}else console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后")},n}(t.Component);t.FollowCamera=i}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Component);t.PooledComponent=e}(es||(es={})),function(t){var e=function(){function e(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.onRemovedFromScene=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled),this},e.prototype.setUpdateOrder=function(e){return this.updateOrder!=e&&(this.updateOrder=e,t.Core.scene._sceneComponents.sort(this.compareTo)),this},e.prototype.compareTo=function(t){return this.updateOrder-t.updateOrder},e}();t.SceneComponent=e}(es||(es={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToEntity=function(){this._triggerHelper=new t.ColliderTriggerHelper(this.entity)},i.prototype.calculateMovement=function(e,i){if(!this.entity.getComponent(t.Collider)||!this._triggerHelper)return!1;for(var n=this.entity.getComponents(t.Collider),r=0;r=2){this.polygonShape.graphics.beginFill(t.Colors.colliderEdge,0),this.polygonShape.graphics.lineStyle(t.Size.lineSizeMultiplier,t.Colors.colliderEdge);for(var n=0;no||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=i.completed,this._elapsedTime=0,this.currentFrame=0,void(this.displayObject.texture=n.sprites[this.currentFrame].texture2D);var a=Math.floor(s/r),h=n.sprites.length;if(h>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var c=h-1;this.currentFrame=c-Math.abs(c-a%(2*c))}else this.currentFrame=a%h;this.displayObject.texture=n.sprites[this.currentFrame].texture2D}},r.prototype.addAnimation=function(t,e){return!this.sprite&&e.sprites.length>0&&this.setSprite(e.sprites[0]),this._animations[t]=e,this},r.prototype.play=function(t,n){void 0===n&&(n=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=i.running,this.displayObject.texture=this.currentAnimation.sprites[0].texture2D,this._elapsedTime=0,this._loopMode=n||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=i.paused},r.prototype.unPause=function(){this.animationState=i.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=i.none},r}(t.SpriteRenderer);t.SpriteAnimator=n}(es||(es={})),function(t){var e=egret.Bitmap,i=function(i){function n(e){void 0===e&&(e=null);var n=i.call(this)||this;n.displayObject=new egret.DisplayObjectContainer,n.displayObjectCache=new Map;for(var r=0,o=e;r>6;0!=(e&t.LONG_MASK)&&i++,this._bits=new Array(i)}return t.prototype.and=function(t){for(var e,i=Math.min(this._bits.length,t._bits.length),n=0;n=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var i=this._bits[e];if(0!=i)if(-1!=i){var n=((i=((i=(i>>1&0x5555555555555400)+(0x5555555555555400&i))>>2&0x3333333333333400)+(0x3333333333333400&i))>>32)+i;t+=((n=((n=(n>>4&252645135)+(252645135&n))>>8&16711935)+(16711935&n))>>16&65535)+(65535&n)}else t+=64}return t},t.prototype.clear=function(t){if(null!=t){var e=t>>6;this.ensure(e),this._bits[e]&=~(1<>6;return!(e>=this._bits.length)&&0!=(this._bits[e]&1<=0;)if(0!=(this._bits[e]&t._bits[e]))return!0;return!1},t.prototype.isEmpty=function(){for(var t=this._bits.length-1;t>=0;t--)if(this._bits[t])return!1;return!0},t.prototype.nextSetBit=function(t){for(var e=t>>6,i=1<>6;this.ensure(i),this._bits[i]|=1<=this._bits.length){var e=new Number[t+1];e=this._bits.copyWithin(0,0,this._bits.length),this._bits=e}},t.LONG_MASK=63,t}();t.BitSet=e}(es||(es={})),function(t){var e=function(){function e(e){this._components=new t.FastList,this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=e}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components.buffer},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(t){this._componentsToRemove.contains(t)&&console.warn("您正在尝试删除一个您已经删除的组件("+t+")"),this._componentsToAdd.contains(t)?this._componentsToAdd.remove(t):this._componentsToRemove.push(t)},e.prototype.removeAllComponents=function(){for(var t=0;t0){for(var i=0;i0){i=0;for(var n=this._componentsToAdd.length;i0){for(var e=0,i=this._entitiesToRemove;e0;){(n=this._addToSceneEntityList.shift()).onAddedToScene()}if(this._entitiesToAdded.length>0)if(this.frameAllocate&&this._entitiesToAdded.length>this.maxAllocate){for(var r=0;r0;)this.perEntityAddToScene();this._isEntityListUnsorted=!0}this._isEntityListUnsorted&&(this._entities.sort(function(t,e){return t.compareTo(e)}),this._isEntityListUnsorted=!1),0==this._addToSceneEntityList.length&&this._unsortedTags.size>0&&(this._unsortedTags.forEach(function(e){t._entityDict.get(e).sort(function(t,e){return t.compareTo(e)})}),this._unsortedTags.clear())},e.prototype.perEntityAddToScene=function(){var t=this._entitiesToAdded.shift();this._addToSceneEntityList.push(t),-1==this._entities.findIndex(function(e){return e.id==t.id})&&(this._entities.push(t),t.scene=this.scene,this.addToTagList(t),this.scene.entityProcessors.onEntityAdded(t))},e.prototype.findEntity=function(t){for(var e=0;ethis._buckets.length){this._buckets=new Array(t.HashHelpers.expandPrime(this._collisions)),this._collisions=0;for(var l=0;l=e?t%e:t},e}();t.FasterDictionary=e;var i=function(){return function(t,e,i){void 0===i&&(i=-1),this.key=t,this.hashcode=e,this.previous=i,this.next=-1}}();t.FastNode=i}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=5),this.length=0,this.buffer=new Array(t)}return e.prototype.clear=function(){this.buffer.length=0,this.length=0},e.prototype.reset=function(){this.length=0},e.prototype.add=function(t){this.length==this.buffer.length&&(this.buffer.length=Math.max(this.buffer.length<<1,10)),this.buffer[this.length++]=t},e.prototype.remove=function(e){for(var i=t.EqualityComparer.default(),n=0;n=this.length)throw new Error("index超出范围!");this.length--,this.buffer.removeAt(t)},e.prototype.contains=function(e){for(var i=t.EqualityComparer.default(),n=0;n=this.buffer.length&&(this.buffer.length=Math.max(this.buffer.length<<1,this.length+t))},e.prototype.addRange=function(t){for(var e=0,i=t;e=t)return i}for(e=1|t;ethis.maxPrimeArrayLength&&this.maxPrimeArrayLength>t?this.maxPrimeArrayLength:this.getPrime(e)},t.getHashCode=function(t){var e,i=0;if(0==(e="object"==typeof t?JSON.stringify(t):t.toString()).length)return i;for(var n=0;n=0;e=this.allSet.nextSetBit(e+1))if(!t.componentBits.get(e))return!1;return!(!this.exclusionSet.isEmpty()&&this.exclusionSet.intersects(t.componentBits))&&!(!this.oneSet.isEmpty()&&!this.oneSet.intersects(t.componentBits))},e.prototype.all=function(){for(var e=this,i=[],n=0;n0){for(var t=0,i=this._unsortedRenderLayers.length;t=e)return t;var n=!1;"-"==t.substr(0,1)&&(n=!0,t=t.substr(1));for(var r=e-i,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,i,n){void 0===n&&(n=!0),e=Math.floor(e),i=Math.floor(i);var r=t.length;e>r&&(e=r);var o,s=e,a=e+i;return n?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-i)+i,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var i=0,n=e.length;i",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,i){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var n=e.$getTextureWidth(),r=e.$getTextureHeight();i||((i=egret.$TempRectangle).x=0,i.y=0,i.width=n,i.height=r),i.x=Math.min(i.x,n-1),i.y=Math.min(i.y,r-1),i.width=Math.min(i.width,n-i.x),i.height=Math.min(i.height,r-i.y);var o=Math.floor(i.width),s=Math.floor(i.height),a=this.sharedCanvas;if(a.style.width=o+"px",a.style.height=s+"px",this.sharedCanvas.width=o,this.sharedCanvas.height=s,"webgl"==egret.Capabilities.renderMode){var h=void 0;e.$renderBuffer?h=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(h=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var c=h.$renderBuffer.getPixels(i.x,i.y,o,s),u=0,l=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+i,success:function(t){}}),o},e.getPixel32=function(t,e,i){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,i)},e.getPixels=function(t,e,i,n,r){if(void 0===n&&(n=1),void 0===r&&(r=1),"webgl"==egret.Capabilities.renderMode){var o=void 0;return t.$renderBuffer?o=t:(o=new egret.RenderTexture).drawToTexture(new egret.Bitmap(t)),o.$renderBuffer.getPixels(e,i,n,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,i,n,r).data}catch(t){egret.$error(1039)}},e}();t.TextureUtils=e}(es||(es={})),function(t){var e=function(){function t(){}return t.update=function(t){var e=(t-this._lastTime)/1e3;this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this._timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this._timeSinceSceneLoad=0},t.checkEvery=function(t){return Math.floor(this._timeSinceSceneLoad/t)>Math.floor((this._timeSinceSceneLoad-this.deltaTime)/t)},t.deltaTime=0,t.timeScale=1,t.frameCount=0,t._lastTime=0,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),i=t.getMonth()+1;return parseInt(e+(i<10?"0":"")+i)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,i=e<10?"0":"",n=t.getDate(),r=n<10?"0":"";return parseInt(t.getFullYear()+i+e+r+n)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var i=new Date;i.setTime(t.getTime()),i.setDate(1),i.setMonth(0);var n=i.getFullYear(),r=i.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,i.setDate(i.getDate()-(r-1))):i.setDate(i.getDate()+7-r+1);var s=this.diffDay(t,i,!1);if(s<0)return i.setDate(1),i.setMonth(0),i.setDate(i.getDate()-1),this.weekId(i,!1);var a=s/7,h=Math.floor(a)+1;if(53==h){i.setTime(t.getTime()),i.setDate(i.getDate()-1);var c=i.getDay();if(0==c&&(c=7),e&&(!o||c<4))return i.setFullYear(i.getFullYear()+1),i.setDate(1),i.setMonth(0),this.weekId(i,!1)}return parseInt(n+"00"+(h>9?"":"0")+h)},t.diffDay=function(t,e,i){void 0===i&&(i=!1);var n=(t.getTime()-e.getTime())/864e5;return i?Math.ceil(n):Math.floor(n)},t.getFirstDayOfWeek=function(t){var e=(t=t||new Date).getDay()||7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1-e,0,0,0,0)},t.getFirstOfDay=function(t){return(t=t||new Date).setHours(0,0,0,0),t},t.getNextFirstOfDay=function(t){return new Date(this.getFirstOfDay(t).getTime()+864e5)},t.formatDate=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();return e+"-"+i+"-"+(n=n<10?"0"+n:n)},t.formatDateTime=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();n=n<10?"0"+n:n;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+i+"-"+n+" "+r+":"+o+":"+(s=s<10?"0"+s:s)},t.parseDate=function(t){var e=Date.parse(t);return isNaN(e)?new Date:new Date(Date.parse(t.replace(/-/g,"/")))},t.secondToTime=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===i&&(i=!0);var n=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=n.toString(),a=r.toString(),h=o.toString();return n<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(h="0"+h),i?s+e+a+e+h:a+e+h},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var i=t.split(e),n=0,r=i.length,o=0;o-1?this.os="iOS":n.indexOf("android")>-1&&(this.os="Android");var r=i.language;r=r.indexOf("zh")>-1?"zh-CN":"en-US",this.language=r}},e}(egret.Capabilities);t.GraphicsCapabilities=e}(es||(es={})),function(t){var e=function(){function e(){this.setup(),this.graphicsCapabilities=new t.GraphicsCapabilities,this.graphicsCapabilities.initialize(this)}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this._viewport},enumerable:!0,configurable:!0}),e.prototype.setup=function(){this._viewport=new t.Viewport(0,0,t.Core._instance.stage.stageWidth,t.Core._instance.stage.stageHeight)},e}();t.GraphicsDevice=e}(es||(es={})),function(t){var e=function(){function e(t,e,i,n){this._x=t,this._y=e,this._width=i,this._height=n,this._minDepth=0,this._maxDepth=1}return Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return 0!=this._height&&0!=this._width?this._width/this._height:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bounds",{get:function(){return new t.Rectangle(this._x,this._y,this._width,this._height)},set:function(t){this._x=t.x,this._y=t.y,this._width=t.width,this._height=t.height},enumerable:!0,configurable:!0}),e}();t.Viewport=e}(es||(es={})),function(t){var e=function(e){function i(){return e.call(this,t.PostProcessor.default_vert,i.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(i,e),i.blur_frag="precision mediump float;\nuniform sampler2D uSampler;\nuniform float screenWidth;\nuniform float screenHeight;\nfloat normpdf(in float x, in float sigma)\n{\nreturn 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n}\nvoid main()\n{\nvec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\nconst int mSize = 11;\nconst int kSize = (mSize - 1)/2;\nfloat kernel[mSize];\nvec3 final_colour = vec3(0.0);\nfloat sigma = 7.0;\nfloat z = 0.0;\nfor (int j = 0; j <= kSize; ++j)\n{\nkernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n}\nfor (int j = 0; j < mSize; ++j)\n{\nz += kernel[j];\n}\nfor (int i = -kSize; i <= kSize; ++i)\n{\nfor (int j = -kSize; j <= kSize; ++j)\n{\nfinal_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n}\n}\ngl_FragColor = vec4(final_colour/(z*z), 1.0);\n}",i}(egret.CustomFilter);t.GaussianBlurEffect=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,e.vertSrc,e.fragmentSrc)||this}return __extends(e,t),e.vertSrc="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e.fragmentSrc="precision lowp float;\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n#define SAMPLE_COUNT 15\nuniform vec2 _sampleOffsets[SAMPLE_COUNT];\nuniform float _sampleWeights[SAMPLE_COUNT];\nvoid main(void) {\nvec4 c = vec4(0, 0, 0, 0);\nfor( int i = 0; i < SAMPLE_COUNT; i++ )\n c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\ngl_FragColor = c;\n}",e}(egret.CustomFilter);t.PolygonLightEffect=e}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=null),this.enabled=!0,this.effect=t}return e.prototype.onAddedToScene=function(e){this.scene=e,this.shape=new egret.Shape,this.shape.graphics.beginFill(16777215,1),this.shape.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this.shape.graphics.endFill(),e.addChild(this.shape)},e.prototype.process=function(){this.drawFullscreenQuad()},e.prototype.onSceneBackBufferSizeChanged=function(t,e){},e.prototype.unload=function(){this.effect&&(this.effect=null),this.scene.removeChild(this.shape),this.scene=null},e.prototype.drawFullscreenQuad=function(){this.scene.filters=[this.effect]},e.default_vert="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec2 aColor;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\ngl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\nvTextureCoord = aTextureCoord;\nvColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n}",e}();t.PostProcessor=e}(es||(es={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToScene=function(i){e.prototype.onAddedToScene.call(this,i),this.effect=new t.GaussianBlurEffect},i}(t.PostProcessor);t.GaussianBlurPostProcessor=e}(es||(es={})),function(t){var e=function(){function t(t,e){void 0===e&&(e=null),this.renderOrder=0,this.shouldDebugRender=!0,this.camera=e,this.renderOrder=t}return Object.defineProperty(t.prototype,"wantsToRenderToSceneRenderTarget",{get:function(){return!!this.renderTexture},enumerable:!0,configurable:!0}),t.prototype.onAddedToScene=function(t){},t.prototype.unload=function(){},t.prototype.onSceneBackBufferSizeChanged=function(t,e){},t.prototype.compareTo=function(t){return this.renderOrder-t.renderOrder},t.prototype.beginRender=function(t){},t.prototype.renderAfterStateCheck=function(t,e){t.render(e)},t.prototype.debugRender=function(t,e){for(var i=0;i=0&&h=0&&ci?i:t},e.pointOnCirlce=function(i,n,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+i.x,Math.sin(o)*o+i.y)},e.isEven=function(t){return t%2==0},e.clamp01=function(t){return t<0?0:t>1?1:t},e.angleBetweenVectors=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.approach=function(t,e,i){return tn&&(n=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,i,n,r)},i.prototype.intersects=function(t){return t.leftthis.x+this.width)return!1}else{var n=1/t.direction.x,r=(this.x-t.start.x)*n,o=(this.x+this.width-t.start.x)*n;if(r>o){var s=r;r=o,o=s}if(e.value=Math.max(r,e.value),i=Math.min(o,i),e.value>i)return!1}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return!1}else{var a=1/t.direction.y,h=(this.y-t.start.y)*a,c=(this.y+this.height-t.start.y)*a;if(h>c){var u=h;h=c,c=u}if(e.value=Math.max(h,e.value),i=Math.max(c,i),e.value>i)return!1}return!0},i.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var u=(h.x*o.y-h.y*o.x)/a;return!(u<0||u>1)},i.lineToLineIntersection=function(e,i,n,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(i,e),a=t.Vector2.subtract(r,n),h=s.x*a.y-s.y*a.x;if(0==h)return o;var c=t.Vector2.subtract(n,e),u=(c.x*a.y-c.y*a.x)/h;if(u<0||u>1)return o;var l=(c.x*s.y-c.y*s.x)/h;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y))},i.closestPointOnLine=function(e,i,n){var r=t.Vector2.subtract(i,e),o=t.Vector2.subtract(n,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,new t.Vector2(r.x*s,r.y*s))},i.circleToCircle=function(e,i,n,r){return t.Vector2.distanceSquared(e,n)<(i+r)*(i+r)},i.circleToLine=function(e,i,n,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(n,r,e))=t&&r.y>=e&&r.x=t+n&&(s|=e.right),o.y=i+r&&(s|=e.bottom),s},i}();t.Collisions=i}(es||(es={})),function(t){var e=function(){function e(e,i,n,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=i,this.distance=n,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,i,n){this.collider=t,this.fraction=e,this.distance=i,this.point=n},e.prototype.setValuesNonCollider=function(t,e,i,n){this.fraction=t,this.distance=e,this.point=i,this.normal=n},e.prototype.reset=function(){this.collider=null,this.fraction=this.distance=0},e.prototype.toString=function(){return"[RaycastHit] fraction: "+this.fraction+", distance: "+this.distance+", normal: "+this.normal+", centroid: "+this.centroid+", point: "+this.point},e}();t.RaycastHit=e}(es||(es={})),function(t){var e=function(){function e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,i,n){if(void 0===n&&(n=-1),0!=i.length)return this._spatialHash.overlapCircle(t,e,i,n);console.error("An empty results array was passed in. No results will ever be returned.")},e.boxcastBroadphase=function(t,e){return void 0===e&&(e=this.allLayers),this._spatialHash.aabbBroadphase(t,null,e)},e.boxcastBroadphaseExcludingSelf=function(t,e,i){return void 0===i&&(i=this.allLayers),this._spatialHash.aabbBroadphase(e,t,i)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.linecast=function(t,i,n){return void 0===n&&(n=e.allLayers),this._hitArray[0].reset(),this.linecastAll(t,i,this._hitArray,n),this._hitArray[0]},e.linecastAll=function(t,i,n,r){return void 0===r&&(r=e.allLayers),0==n.length?(console.warn("传入了一个空的hits数组。没有点击会被返回"),0):this._spatialHash.linecast(t,i,n,r)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,i){this.start=e,this.end=i,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestCircle=new t.Circle(0),this._cellDict=new i,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new n}return e.prototype.register=function(e){var i=e.bounds;e.registeredPhysicsBounds=i;var n=this.cellCoords(i.x,i.y),r=this.cellCoords(i.right,i.bottom);this.gridBounds.contains(n.x,n.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,n)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=n.x;o<=r.x;o++)for(var s=n.y;s<=r.y;s++){var a=this.cellAtPosition(o,s,!0);a.firstOrDefault(function(t){return t.hashCode==e.hashCode})||a.push(e)}},e.prototype.remove=function(t){for(var e=t.registeredPhysicsBounds,i=this.cellCoords(e.x,e.y),n=this.cellCoords(e.right,e.bottom),r=i.x;r<=n.x;r++)for(var o=i.y;o<=n.y;o++){var s=this.cellAtPosition(r,o);s?s.remove(t):console.log("从不存在碰撞器的单元格中移除碰撞器: ["+t+"]")}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.debugDraw=function(t,e){void 0===e&&(e=1);for(var i=this.gridBounds.x;i<=this.gridBounds.right;i++)for(var n=this.gridBounds.y;n<=this.gridBounds.bottom;n++){var r=this.cellAtPosition(i,n);r&&r.length>0&&this.debugDrawCellDetails(i,n,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,i,n){this._tempHashSet.length=0;for(var r=this.cellCoords(e.x,e.y),o=this.cellCoords(e.right,e.bottom),s=r.x;s<=o.x;s++)for(var a=r.y;a<=o.y;a++){var h=this.cellAtPosition(s,a);if(h)for(var c=function(r){var o=h[r];if(o==i||!t.Flags.isFlagSet(n,o.physicsLayer.value))return"continue";e.intersects(o.bounds)&&(u._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||u._tempHashSet.push(o))},u=this,l=0;l=this.points.length?this.points[0]:this.points[n+1];var o=t.Vector2Ext.perpendicular(r,e);t.Vector2Ext.normalize(o),this._edgeNormals[n]=o}},i.buildSymmetricalPolygon=function(e,i){for(var n=new Array(e),r=0;rr&&(r=s,n=o)}return e[n]},i.getClosestPointOnPolygonToPoint=function(e,i,n,r){n.value=Number.MAX_VALUE,r.x=0,r.y=0;for(var o=new t.Vector2(0,0),s=0,a=0;at.y!=this.points[n].y>t.y&&t.x<(this.points[n].x-this.points[i].x)*(t.y-this.points[i].y)/(this.points[n].y-this.points[i].y)+this.points[i].x&&(e=!e);return e},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisions.pointToPoly(e,this,i)},i}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function i(t,n){var r=e.call(this,i.buildBox(t,n),!0)||this;return r.width=t,r.height=n,r}return __extends(i,e),i.buildBox=function(e,i){var n=e/2,r=i/2,o=new Array(4);return o[0]=new t.Vector2(-n,-r),o[1]=new t.Vector2(n,-r),o[2]=new t.Vector2(n,r),o[3]=new t.Vector2(-n,r),o},i.prototype.updateBox=function(e,i){this.width=e,this.height=i;var n=e/2,r=i/2;this.points[0]=new t.Vector2(-n,-r),this.points[1]=new t.Vector2(n,-r),this.points[2]=new t.Vector2(n,r),this.points[3]=new t.Vector2(-n,r);for(var o=0;o1)return!1;var a,h=t.Vector2.add(s.start,t.Vector2.add(s.direction,new t.Vector2(r.value))),c=0;h.xi.bounds.right&&(c|=1),h.yi.bounds.bottom&&(c|=2);var u=a+c;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),!0},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,i,n){for(var r,o=!0,s=e.edgeNormals,a=i.edgeNormals,h=Number.POSITIVE_INFINITY,c=new t.Vector2,u=t.Vector2.subtract(e.position,i.position),l=0;l0&&(o=!1),!o)return!1;(g=Math.abs(g))r&&(r=o);return{min:n,max:r}},e.circleToPolygon=function(e,i,n){var r,o=t.Vector2.subtract(e.position,i.position),s=new t.Ref(0),a=t.Polygon.getClosestPointOnPolygonToPoint(i.points,o,s,n.normal),h=i.containsPoint(e.position);if(s.value>e.radius*e.radius&&!h)return!1;if(h)r=t.Vector2.multiply(n.normal,new t.Vector2(Math.sqrt(s.value)-e.radius));else if(0==s.value)r=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else{var c=Math.sqrt(s.value);r=t.Vector2.multiply(new t.Vector2(-t.Vector2.subtract(o,a)),new t.Vector2((e.radius-s.value)/c))}return n.minimumTranslationVector=r,n.point=t.Vector2.add(a,i.position),!0},e.circleToBox=function(e,i,n){var r=i.bounds.getClosestPointOnRectangleBorderToPoint(e.position,n.normal);if(i.containsPoint(e.position)){n.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(n.normal,new t.Vector2(e.radius)));return n.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)n.minimumTranslationVector=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){n.normal=t.Vector2.subtract(e.position,r);var a=n.normal.length()-e.radius;return n.point=r,t.Vector2Ext.normalize(n.normal),n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),n.normal),!0}return!1},e.pointToCircle=function(e,i,n){var r=t.Vector2.distanceSquared(e,i.position),o=1+i.radius;if(r1)return!1;var l=(c.x*s.y-c.y*s.x)/h;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),s)),!0)},e.lineToCircle=function(e,i,n,r){var o=t.Vector2.distance(e,i),s=t.Vector2.divide(t.Vector2.subtract(i,e),new t.Vector2(o)),a=t.Vector2.subtract(e,n.position),h=t.Vector2.dot(a,s),c=t.Vector2.dot(a,a)-n.radius*n.radius;if(c>0&&h>0)return!1;var u=h*h-c;return!(u<0)&&(r.fraction=-h-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,n.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,i,n,r){var o=this.minkowskiDifference(e,i);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-n.x)),h=new t.Ref(0);return!!(o.rayIntersects(a,h)&&h.value<=1)&&(r.fraction=h.value,r.distance=n.length()*h.value,r.normal=new t.Vector2(-n.x,-n.y),r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(n,new t.Vector2(h.value))),!0)},e}();t.ShapeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){this.mass=1,this.radius=0,this.collidesWithColliders=!0}return e.prototype.applyForce=function(e){this.acceleration.add(t.Vector2.divide(e,new t.Vector2(this.mass)))},e}();t.Particle=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=null),this.gravity=new t.Vector2(0,980),this.constraintIterations=3,this.maximumStepIterations=5,this.allowDragging=!0,this._composites=[],this._tempCircle=new t.Circle(1),this._leftOverTime=0,this._fixedDeltaTime=1/60,this._iterationSteps=0,this._fixedDeltaTimeSq=0,this.simulationBounds=e,this._fixedDeltaTimeSq=Math.pow(this._fixedDeltaTimeSq,2)}return e.prototype.update=function(){this.updateTiming(),this.allowDragging&&this.handleDragging();for(var t=1;t<=this._iterationSteps;t++)for(var e=this._composites.length-1;e>=0;e--){for(var i=this._composites[e],n=0;ni.height?e.y=i.height:e.yi.width&&(e.x=i.width)):(e.yi.height-t.radius&&(e.y=2*(i.height-t.radius)-e.y),e.x>i.width-t.radius&&(e.x=2*(i.width-t.radius)-e.x),e.x=0;t--)this._constraints[t].solve()},e.prototype.updateParticles=function(e,i){for(var n=0;n=0;t--)this._constraints[t].collidesWithColliders&&this._constraints[t].handleCollisions(this.collidesWithLayers)},e.prototype.debugRender=function(t){},e}();t.Composite=e}(es||(es={})),function(t){var e=function(){function t(){this.collidesWithColliders=!0}return t.prototype.handleCollisions=function(t){},t}();t.Constraint=e}(es||(es={}));var ArrayUtils=function(){function t(){}return t.bubbleSort=function(t){for(var e=!1,i=0;ii;n--)if(t[n]0&&t[r-1]>n;r--)t[r]=t[r-1];t[r]=n}},t.binarySearch=function(t,e){for(var i=0,n=t.length,r=i+n>>1;i=t[r]&&(i=r+1),r=i+n>>1;return t[i]==e?i:-1},t.findElementIndex=function(t,e){for(var i=t.length,n=0;nt[e]&&(e=n);return e},t.getMinElementIndex=function(t){for(var e=0,i=t.length,n=1;n=0;--r)i.unshift(e[r]);return i},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var i=t.concat(e),n={},r=[],o=i.length,s=0;s=0;e-=1)t.splice(e,1)},t.cloneList=function(t){return t?t.slice(0,t.length):null},t.equals=function(t,e){if(t==e)return!0;var i=t.length;if(i!=e.length)return!1;for(;i--;)if(t[i]!=e[i])return!1;return!0},t.insert=function(t,e,i){if(!t)return null;var n=t.length;if(e>n&&(e=n),e<0&&(e=0),e==n)t.push(i);else if(0==e)t.unshift(i);else{for(var r=n-1;r>=e;r-=1)t[r+1]=t[r];t[e]=i}return i},t}();!function(t){var e=function(){function t(){}return Object.defineProperty(t,"nativeBase64",{get:function(){return"function"==typeof window.atob},enumerable:!0,configurable:!0}),t.decode=function(t){if(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),this.nativeBase64)return window.atob(t);for(var e,i,n,r,o,s,a=[],h=0;h>4,i=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(h++)))>>2,n=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(h++))),a.push(String.fromCharCode(e)),64!==o&&a.push(String.fromCharCode(i)),64!==s&&a.push(String.fromCharCode(n));return a=a.join("")},t.encode=function(t){if(t=t.replace(/\r\n/g,"\n"),!this.nativeBase64){for(var e,i,n,r,o,s,a,h=[],c=0;c>2,o=(3&e)<<4|(i=t.charCodeAt(c++))>>4,s=(15&i)<<2|(n=t.charCodeAt(c++))>>6,a=63&n,isNaN(i)?s=a=64:isNaN(n)&&(a=64),h.push(this._keyStr.charAt(r)),h.push(this._keyStr.charAt(o)),h.push(this._keyStr.charAt(s)),h.push(this._keyStr.charAt(a));return h=h.join("")}window.btoa(t)},t.decodeBase64AsArray=function(e,i){i=i||1;var n,r,o,s=t.decode(e),a=new Uint32Array(s.length/i);for(n=0,o=s.length/i;n=0;--r)a[n]+=s.charCodeAt(n*i+r)<<(r<<3);return a},t.decompress=function(t,e,i){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},t.decodeCSV=function(t){for(var e=t.replace("\n","").trim().split(","),i=[],n=0;n>16},set:function(t){this._packedValue=4278255615&this._packedValue|t<<16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this._packedValue>>8},set:function(t){this._packedValue=4294902015&this._packedValue|t<<8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"r",{get:function(){return this._packedValue},set:function(t){this._packedValue=4294967040&this._packedValue|t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a",{get:function(){return this._packedValue>>24},set:function(t){this._packedValue=16777215&this._packedValue|t<<24},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"packedValue",{get:function(){return this._packedValue},set:function(t){this._packedValue=t},enumerable:!0,configurable:!0}),e.prototype.equals=function(t){return this._packedValue==t._packedValue},e}();t.Color=e}(es||(es={})),function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var i=this;return void 0===e&&(e=!0),new Promise(function(n,r){var o=i.loadedAssets.get(t);o?n(o):e?RES.getResAsync(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){var e=t;RES.destroyRes(e)&&e.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.getColorMatrix=function(t){var e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];return e[0]=Math.floor(t/256/256)/255,e[6]=Math.floor(t/256%256)/255,e[12]=t%256/255,new egret.ColorMatrixFilter(e)},t}();t.DrawUtils=e}(es||(es={})),function(t){var e=function(){function e(){}return e.oppositeEdge=function(e){switch(e){case t.Edge.bottom:return t.Edge.top;case t.Edge.top:return t.Edge.bottom;case t.Edge.left:return t.Edge.right;case t.Edge.right:return t.Edge.left}},e.isHorizontal=function(e){return e==t.Edge.right||e==t.Edge.left},e.isVertical=function(e){return e==t.Edge.top||e==t.Edge.bottom},e}();t.EdgeExt=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var i=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,i,n){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==i})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(i,n))},t.prototype.removeObserver=function(t,e){var i=this._messageTable.get(t),n=i.findIndex(function(t){return t.func==e});-1!=n&&i.removeAt(n)},t.prototype.emit=function(t,e){var i=this._messageTable.get(t);if(i)for(var n=i.length-1;n>=0;n--)i[n].func.call(i[n].context,e)},t}();t.Emitter=i}(es||(es={})),function(t){!function(t){t[t.top=0]="top",t[t.bottom=1]="bottom",t[t.left=2]="left",t[t.right=3]="right"}(t.Edge||(t.Edge={}))}(es||(es={})),function(t){var e=function(){function t(){}return t.repeat=function(t,e){for(var i=[];e--;)i.push(t);return i},t}();t.Enumerable=e}(es||(es={})),function(t){var e=function(){function t(){}return t.default=function(){return new t},t.prototype.equals=function(t,e){return"function"==typeof t.equals?t.equals(e):t===e},t}();t.EqualityComparer=e}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.setEnabled=function(t){this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled())},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.update=function(){},t}();t.GlobalManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.warmCache=function(t){if((t-=this._objectQueue.length)>0)for(var e=0;ethis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.toNumber=function(t){return null==t?0:Number(t)},t}();t.NumberExtension=e}(es||(es={})),function(t){var e=function(){function t(t,e){this.first=t,this.second=e}return t.prototype.clear=function(){this.first=this.second=null},t.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},t}();t.Pair=e}(es||(es={})),function(t){var e=function(){function t(){}return t.warmCache=function(t,e){if((e-=this._objectQueue.length)>0)for(var i=0;ithis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(t){return this._objectQueue.length>0?this._objectQueue.shift():new t},t.free=function(t){this._objectQueue.unshift(t),egret.is(t,"IPoolable")&&t.reset()},t._objectQueue=[],t}();t.Pool=e}(es||(es={}));var RandomUtils=function(){function t(){}return t.randrange=function(t,e,i){if(void 0===i&&(i=1),0==i)throw new Error("step 不能为 0");var n=e-t;if(0==n)throw new Error("没有可用的范围("+t+","+e+")");n<0&&(n=t-e);var r=Math.floor((n+i-1)/i);return Math.floor(this.random()*r)*i+Math.min(t,e)},t.randint=function(t,e){return(t=Math.floor(t))>(e=Math.floor(e))?t++:e++,this.randrange(t,e)},t.randnum=function(t,e){return this.random()*(e-t)+t},t.shuffle=function(t){return t.sort(this._randomCompare),t},t.choice=function(t){if(!t.hasOwnProperty("length"))throw new Error("无法对此对象执行此操作");var e=Math.floor(this.random()*t.length);return t instanceof String?String(t).charAt(e):t[e]},t.sample=function(t,e){var i=t.length;if(e<=0||i=0;)s=Math.floor(this.random()*i);n.push(t[s]),r.push(s)}return n},t.random=function(){return Math.random()},t.boolean=function(t){return void 0===t&&(t=.5),this.random().5?1:-1},t}();!function(t){var e=function(){function e(){}return e.getSide=function(e,i){switch(i){case t.Edge.top:return e.top;case t.Edge.bottom:return e.bottom;case t.Edge.left:return e.left;case t.Edge.right:return e.right}},e.union=function(e,i){var n=new t.Rectangle(i.x,i.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,n.x),r.y=Math.min(e.y,n.y),r.width=Math.max(e.right,n.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,i){switch(i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,e.height/2);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height/2,e.width,e.height/2);case t.Edge.left:return new t.Rectangle(e.x,e.y,e.width/2,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width/2,e.y,e.width/2,e.height)}},e.getRectEdgePortion=function(e,i,n){switch(void 0===n&&(n=1),i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,n);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-n,e.width,n);case t.Edge.left:return new t.Rectangle(e.x,e.y,n,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-n,e.y,n,e.height)}},e.expandSide=function(e,i,n){switch(n=Math.abs(n),i){case t.Edge.top:e.y-=n,e.height+=n;break;case t.Edge.bottom:e.height+=n;break;case t.Edge.left:e.x-=n,e.width+=n;break;case t.Edge.right:e.width+=n}},e.contract=function(t,e,i){t.x+=e,t.y+=i,t.width-=2*e,t.height-=2*i},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.update=function(t){this.remainder+=t;var e=Math.trunc(this.remainder);return this.remainder-=e,e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelNumber=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,i,n,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(n,i))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(r,n))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(i,r))<0))},e.prototype.triangulate=function(i,n){void 0===n&&(n=!0);var r=i.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,h=i[this._triPrev[s]],c=i[s],u=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(h,c,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[l],h,c,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),n||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e.divide(new t.Vector2(i)):e.x=e.y=0},e.transformA=function(t,e,i,n,r,o){for(var s=0;sthis.safeArea.right&&(s.x=this.safeArea.right-s.width),s.topthis.safeArea.bottom&&(s.y=this.safeArea.bottom-s.height),s},i}();t.Layout=i,function(t){t[t.none=0]="none",t[t.left=1]="left",t[t.right=2]="right",t[t.horizontalCenter=4]="horizontalCenter",t[t.top=8]="top",t[t.bottom=16]="bottom",t[t.verticalCenter=32]="verticalCenter",t[t.topLeft=9]="topLeft",t[t.topRight=10]="topRight",t[t.topCenter=12]="topCenter",t[t.bottomLeft=17]="bottomLeft",t[t.bottomRight=18]="bottomRight",t[t.bottomCenter=20]="bottomCenter",t[t.centerLeft=33]="centerLeft",t[t.centerRight=34]="centerRight",t[t.center=36]="center"}(e=t.Alignment||(t.Alignment={}))}(es||(es={})),function(t){var e,i=function(){function t(t){void 0===t&&(t=n),this.getSystemTime=t,this._stopDuration=0,this._completeSlices=[]}return t.prototype.getState=function(){return void 0===this._startSystemTime?e.IDLE:void 0===this._stopSystemTime?e.RUNNING:e.STOPPED},t.prototype.isIdle=function(){return this.getState()===e.IDLE},t.prototype.isRunning=function(){return this.getState()===e.RUNNING},t.prototype.isStopped=function(){return this.getState()===e.STOPPED},t.prototype.slice=function(){return this.recordPendingSlice()},t.prototype.getCompletedSlices=function(){return Array.from(this._completeSlices)},t.prototype.getCompletedAndPendingSlices=function(){return this._completeSlices.concat([this.getPendingSlice()])},t.prototype.getPendingSlice=function(){return this.calculatePendingSlice()},t.prototype.getTime=function(){return this.caculateStopwatchTime()},t.prototype.reset=function(){this._startSystemTime=this._pendingSliceStartStopwatchTime=this._stopSystemTime=void 0,this._stopDuration=0,this._completeSlices=[]},t.prototype.start=function(t){if(void 0===t&&(t=!1),t&&this.reset(),void 0!==this._stopSystemTime){var e=(i=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var i=this.getSystemTime();this._startSystemTime=i,this._pendingSliceStartStopwatchTime=0}},t.prototype.stop=function(t){if(void 0===t&&(t=!1),void 0===this._startSystemTime)return 0;var e=this.getSystemTimeOfCurrentStopwatchTime();return t&&this.recordPendingSlice(this.caculateStopwatchTime(e)),this._stopSystemTime=e,this.getTime()},t.prototype.calculatePendingSlice=function(t){return void 0===this._pendingSliceStartStopwatchTime?Object.freeze({startTime:0,endTime:0,duration:0}):(void 0===t&&(t=this.getTime()),Object.freeze({startTime:this._pendingSliceStartStopwatchTime,endTime:t,duration:t-this._pendingSliceStartStopwatchTime}))},t.prototype.caculateStopwatchTime=function(t){return void 0===this._startSystemTime?0:(void 0===t&&(t=this.getSystemTimeOfCurrentStopwatchTime()),t-this._startSystemTime-this._stopDuration)},t.prototype.getSystemTimeOfCurrentStopwatchTime=function(){return void 0===this._stopSystemTime?this.getSystemTime():this._stopSystemTime},t.prototype.recordPendingSlice=function(t){if(void 0!==this._pendingSliceStartStopwatchTime){void 0===t&&(t=this.getTime());var e=this.calculatePendingSlice(t);return this._pendingSliceStartStopwatchTime=e.endTime,this._completeSlices.push(e),e}return this.calculatePendingSlice()},t}();t.Stopwatch=i,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),n=t};var n=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._rectShape1=new egret.Shape,this._rectShape2=new egret.Shape,this._rectShape3=new egret.Shape,this._rectShape4=new egret.Shape,this._rectShape5=new egret.Shape,this._rectShape6=new egret.Shape,this.logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(u.logs[n].snapMin=u.logs[n].min,u.logs[n].snapMax=u.logs[n].max,u.logs[n].snapAvg=u.logs[n].avg,u.logs[n].samples=0)):(u.logs[n].min=h,u.logs[n].max=h,u.logs[n].avg=h,u.logs[n].initialized=!0)}o.markCount=r.nestCount,o.nestCount=r.nestCount}this.stopwacth.reset(),this.stopwacth.start()}},e.prototype.beginMark=function(t,i,n){if(void 0===n&&(n=0),n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=this.curLog.bars[n];if(r.markCount>=e.maxSamples)throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数");if(r.nestCount>=e.maxNestCall)throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数");var s=this._markerNameToIdMap.get(t);isNaN(s)&&(s=this.markers.length,this._markerNameToIdMap.set(t,s),this.markers.push(new o(t))),r.markerNests[r.nestCount++]=r.markCount,r.markers[r.markCount].markerId=s,r.markers[r.markCount].color=i,r.markers[r.markCount].beginTime=this.stopwacth.getTime(),r.markers[r.markCount].endTime=-1,r.markCount++},e.prototype.endMark=function(t,i){if(void 0===i&&(i=0),i<0||i>=e.maxBars)throw new Error("barIndex参数超出范围");var n=this.curLog.bars[i];if(n.nestCount<=0)throw new Error("先调用beginMark方法,再调用endMark方法");var r=this._markerNameToIdMap.get(t);if(isNaN(r))throw new Error("标记 "+t+" 未注册。请确认您指定的名称与 beginMark 方法使用的名称相同");var o=n.markerNests[--n.nestCount];if(n.markers[o].markerId!=r)throw new Error("beginMark/endMark方法的调用顺序不正确,beginMark(A),beginMark(B),endMark(B),endMark(A),但你不能像beginMark(A),beginMark(B),endMark(A),endMark(B)这样调用。");n.markers[o].endTime=this.stopwacth.getTime()},e.prototype.getAverageTime=function(t,i){if(t<0||t>=e.maxBars)throw new Error("barIndex参数超出范围");var n=0,r=this._markerNameToIdMap.get(i);return r&&(n=this.markers[r].logs[t].avg),n},e.prototype.resetLog=function(){this.markers.forEach(function(t){for(var e=0;e0&&(r+=e.barHeight+2*e.barPadding,o=Math.max(o,t.markers[t.markCount-1].endTime))});var s=this.sampleFrames*(1/60*1e3);this._frameAdjust=o>s?Math.max(0,this._frameAdjust)+1:Math.min(0,this._frameAdjust)-1,Math.max(this._frameAdjust)>e.autoAdjustDelay&&(this.sampleFrames=Math.min(e.maxSampleFrames,this.sampleFrames),this.sampleFrames=Math.max(this.targetSampleFrames,Math.floor(o/(1/60*1e3))+1),this._frameAdjust=0);var a=n/s,h=i.y-(r-e.barHeight),c=h,u=new t.Rectangle(i.x,c,n,r);this._rectShape1.graphics.clear(),this._rectShape1.graphics.beginFill(0,128/255),this._rectShape1.graphics.drawRect(u.x,u.y,u.width,u.height),this._rectShape1.graphics.endFill(),u.height=e.barHeight,this._rectShape2.graphics.clear();for(var l=0,p=this.prevLog.bars;l0)for(var f=0;f0?(i.waitTimer-=i.useUnscaledDeltaTime?t.Time.unscaledDeltaTime:t.Time.deltaTime,this._shouldRunNextFrame.push(i)):this.tickCoroutine(i)&&this._shouldRunNextFrame.push(i)}}this._unblockedCoroutines.length=0,this._unblockedCoroutines.concat(this._shouldRunNextFrame),this._shouldRunNextFrame.length=0,this._isInUpdate=!1},n.prototype.tickCoroutine=function(i){var n=i.enumerator.next();return!n.value||n.done?(t.Pool.free(i),!1):!n.value||(n.value instanceof t.WaitForSeconds?(i.waitTimer=n.value.waitTime,!0):n.value instanceof Number?(console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"),i.waitTimer=Number(n),!0):!(n.value instanceof e)||(i.waitForCoroutine=n.value,!0))},n}(t.GlobalManager);t.CoroutineManager=i}(es||(es={})),function(t){var e=function(){function e(){this.x=0,this.y=0,this.touchPoint=-1,this.touchDown=!1}return Object.defineProperty(e.prototype,"position",{get:function(){return new t.Vector2(this.x,this.y)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.x=0,this.y=0,this.touchDown=!1,this.touchPoint=-1},e}();t.TouchState=e;var i=function(){function i(){}return Object.defineProperty(i,"gameTouchs",{get:function(){return this._gameTouchs},enumerable:!0,configurable:!0}),Object.defineProperty(i,"resolutionScale",{get:function(){return this._resolutionScale},enumerable:!0,configurable:!0}),Object.defineProperty(i,"totalTouchCount",{get:function(){return this._totalTouchCount},enumerable:!0,configurable:!0}),Object.defineProperty(i,"touchPosition",{get:function(){return this._gameTouchs[0]?this._gameTouchs[0].position:t.Vector2.zero},enumerable:!0,configurable:!0}),Object.defineProperty(i,"maxSupportedTouch",{get:function(){return t.Core._instance.stage.maxTouches},set:function(e){t.Core._instance.stage.maxTouches=e,this.initTouchCache()},enumerable:!0,configurable:!0}),Object.defineProperty(i,"touchPositionDelta",{get:function(){var e=t.Vector2.subtract(this.touchPosition,this._previousTouchState.position);return e.length()>0&&this.setpreviousTouchState(this._gameTouchs[0]),e},enumerable:!0,configurable:!0}),i.initialize=function(){this._init||(this._init=!0,t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.touchBegin,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.touchMove,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.touchEnd,this),this.initTouchCache())},i.update=function(){KeyboardUtils.update();for(var t=0;t0,this._willRepeat||(this.isRepeating=!1)},i.prototype.update=function(){this._bufferCounter-=t.Time.unscaledDeltaTime,this.isRepeating=!1;for(var e=!1,i=0;i0||this.isRepeating)return!0;for(var t=0,e=this.nodes;ta||i[c].height>a)throw new Error("一个纹理的大小比图集的大小大");h.push(new t.Rectangle(0,0,i[c].width,i[c].height))}for(;h.length>0;){var u=new egret.RenderTexture,l=new t.RectanglePacker(a,a,1);for(c=0;c0){for(var p=new t.IntegerRectangle,d=[],f=[],y=[],g=[],m=0;m0;)this.freeRectangle(this._insertedRectangles.pop());for(;this._freeAreas.length>0;)this.freeRectangle(this._freeAreas.pop());for(this._width=t,this._height=e,this._packedWidth=0,this._packedHeight=0,this._freeAreas.push(this.allocateRectangle(0,0,this._width,this._height));this._insertedRectangles.length>0;)this.freeSize(this._insertList.pop());this._padding=i},e.prototype.insertRectangle=function(t,e,i){var n=this.allocateSize(t,e,i);this._insertList.push(n)},e.prototype.packRectangles=function(t){for(void 0===t&&(t=!0),t&&this._insertList.sort(function(t,e){return t.width-e.width});this._insertList.length>0;){var e=this._insertList.pop(),i=e.width,n=e.height,r=this.getFreeAreaIndex(i,n);if(r>=0){var o=this._freeAreas[r],s=this.allocateRectangle(o.x,o.y,i,n);for(s.id=e.id,this.generateNewFreeAreas(s,this._freeAreas,this._newFreeAreas);this._newFreeAreas.length>0;)this._freeAreas.push(this._newFreeAreas.pop());this._insertedRectangles.push(s),s.right>this._packedWidth&&(this._packedWidth=s.right),s.bottom>this._packedHeight&&(this._packedHeight=s.bottom)}this.freeSize(e)}return this.rectangleCount},e.prototype.getRectangle=function(t,e){var i=this._insertedRectangles[t];return e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height,e},e.prototype.getRectangleId=function(t){return this._insertedRectangles[t].id},e.prototype.generateNewFreeAreas=function(t,e,i){var n=t.x,r=t.y,o=t.right+1+this._padding,s=t.bottom+1+this._padding,a=null;0==this._padding&&(a=t);for(var h=e.length-1;h>=0;h--){var c=e[h];if(!(n>=c.right||o<=c.x||r>=c.bottom||s<=c.y)){null==a&&(a=this.allocateRectangle(t.x,t.y,t.width+this._padding,t.height+this._padding)),this.generateDividedAreas(a,c,i);var u=e.pop();h=0;e--)for(var i=t[e],n=t.length-1;n>=0;n--)if(e!=n){var r=t[n];if(i.x>=r.x&&i.y>=r.y&&i.right<=r.right&&i.bottom<=r.bottom){this.freeRectangle(i);var o=t.pop();e0&&(i.push(this.allocateRectangle(t.right,e.y,r,e.height)),n++);var o=t.x-e.x;o>0&&(i.push(this.allocateRectangle(e.x,e.y,o,e.height)),n++);var s=e.bottom-t.bottom;s>0&&(i.push(this.allocateRectangle(e.x,t.bottom,e.width,s)),n++);var a=t.y-e.y;a>0&&(i.push(this.allocateRectangle(e.x,e.y,e.width,a)),n++),0==n&&(t.width=0;s--){var a=this._freeAreas[s];if(a.x0){var r=this._sortableSizeStack.pop();return r.width=e,r.height=i,r.id=n,r}return new t.SortableSize(e,i,n)},e.prototype.freeSize=function(t){this._sortableSizeStack.push(t)},e.prototype.allocateRectangle=function(e,i,n,r){if(this._rectangleStack.length>0){var o=this._rectangleStack.pop();return o.x=e,o.y=i,o.width=n,o.height=r,o.right=e+n,o.bottom=i+r,o}return new t.IntegerRectangle(e,i,n,r)},e.prototype.freeRectangle=function(t){this._rectangleStack.push(t)},e}();t.RectanglePacker=e}(es||(es={})),function(t){var e=function(){return function(t,e,i){this.width=t,this.height=e,this.id=i}}();t.SortableSize=e}(es||(es={})),function(t){var e=function(){return function(t){this.assets=t}}();t.TextureAssets=e;var i=function(){return function(){}}();t.TextureAsset=i}(es||(es={})),function(t){var e=function(){return function(t,e){this.texture=t,this.id=e}}();t.TextureToPack=e}(es||(es={})),function(t){var e=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}return e.prototype.getContext=function(){return this.context},e.prototype.reset=function(){this._elapsedTime=0},e.prototype.stop=function(){this._isDone=!0},e.prototype.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,i,n){this._timeInSeconds=t,this._repeats=e,this.context=i,this._onTime=n},e.prototype.unload=function(){this.context=null,this._onTime=null},e}();t.Timer=e}(es||(es={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._timers=[],t}return __extends(i,e),i.prototype.update=function(){for(var t=this._timers.length-1;t>=0;t--)this._timers[t].tick()&&(this._timers[t].unload(),this._timers.removeAt(t))},i.prototype.schedule=function(e,i,n,r){var o=new t.Timer;return o.initialize(e,i,n,r),this._timers.push(o),o},i}(t.GlobalManager);t.TimerManager=e}(es||(es={})); \ No newline at end of file diff --git a/demo/libs/framework_tiled/framework_tiled.d.ts b/demo/libs/framework_tiled/framework_tiled.d.ts deleted file mode 100644 index 5edd3974..00000000 --- a/demo/libs/framework_tiled/framework_tiled.d.ts +++ /dev/null @@ -1,357 +0,0 @@ -declare module es { - class TiledMapRenderer extends RenderableComponent { - tiledMap: TmxMap; - physicsLayer: Ref; - layerIndicesToRender: number[]; - private toContainer; - readonly width: number; - readonly height: number; - collisionLayer: TmxLayer; - _shouldCreateColliders: boolean; - _colliders: Collider[]; - constructor(tiledMap: TmxMap, collisionLayerName?: string, shouldCreateColliders?: boolean); - setLayerToRender(layerName: string): void; - setLayersToRender(...layerNames: string[]): void; - private getLayerIndex; - getRowAtWorldPosition(yPos: number): number; - getColumnAtWorldPosition(xPos: number): number; - onEntityTransformChanged(comp: transform.Component): void; - onAddedToEntity(): void; - onRemovedFromEntity(): void; - update(): void; - render(camera: es.Camera): void; - addColliders(): void; - removeColliders(): void; - } -} -declare module es { - class TmxGroup implements ITmxLayer { - map: TmxMap; - offsetX: number; - offsetY: number; - opacity: number; - properties: Map; - visible: boolean; - name: string; - layers: ITmxLayer[]; - tileLayers: TmxLayer[]; - objectGroups: TmxObjectGroup[]; - imageLayers: TmxImageLayer[]; - groups: TmxGroup[]; - } -} -declare module es { - interface ITmxLayer { - offsetX: number; - offsetY: number; - opacity: number; - visible: boolean; - properties: Map; - } -} -declare module es { - class TmxImageLayer implements ITmxLayer { - map: TmxMap; - name: string; - offsetX: number; - offsetY: number; - opacity: number; - properties: Map; - visible: boolean; - width?: number; - height?: number; - image: TmxImage; - } -} -declare module es { - class TmxLayer implements ITmxLayer { - map: TmxMap; - name: string; - opacity: number; - offsetX: number; - offsetY: number; - properties: Map; - visible: boolean; - readonly offset: Vector2; - width: number; - height: number; - tiles: TmxLayerTile[]; - getTileWithGid(gid: number): TmxLayerTile; - getTile(x: number, y: number): TmxLayerTile; - getCollisionRectangles(): Rectangle[]; - findBoundsRect(startX: number, endX: number, startY: number, checkedIndexes?: boolean[]): Rectangle; - } - class TmxLayerTile { - static readonly FLIPPED_HORIZONTALLY_FLAG: number; - static readonly FLIPPED_VERTICALLY_FLAG: number; - tileset: TmxTileset; - gid: number; - x: number; - y: number; - readonly position: Vector2; - horizontalFlip: boolean; - verticalFlip: boolean; - _tilesetTileIndex?: number; - readonly tilesetTile: TmxTilesetTile; - constructor(map: TmxMap, id: number, x: number, y: number); - } -} -declare module es { - class TmxDocument { - tmxDirectory: string; - constructor(); - } - interface ITmxElement { - name: string; - } - class TmxImage { - texture: egret.Bitmap; - bitmap: egret.SpriteSheet; - source: string; - format: string; - data: any; - trans: number; - width: number; - height: number; - dispose(): void; - } -} -declare module es { - class TmxMap extends TmxDocument { - version: string; - tiledVersion: string; - width: number; - height: number; - readonly worldWidth: number; - readonly worldHeight: number; - tileWidth: number; - tileHeight: number; - hexSideLength?: number; - orientation: OrientationType; - staggerAxis: StaggerAxisType; - staggerIndex: StaggerIndexType; - renderOrder: RenderOrderType; - backgroundColor: number; - nextObjectID?: number; - layers: ITmxLayer[]; - tilesets: TmxTileset[]; - tileLayers: TmxLayer[]; - objectGroups: TmxObjectGroup[]; - imageLayers: TmxImageLayer[]; - groups: TmxGroup[]; - properties: Map; - maxTileWidth: number; - maxTileHeight: number; - readonly requiresLargeTileCulling: boolean; - getTilesetForTileGid(gid: number): TmxTileset; - worldToTilePositionX(x: number, clampToTilemapBounds?: boolean): number; - worldToTilePositionY(y: number, clampToTilemapBounds?: boolean): number; - getLayer(name: string): ITmxLayer; - update(): void; - _isDisposed: any; - dispose(disposing?: boolean): void; - } - enum OrientationType { - unknown = 0, - orthogonal = 1, - isometric = 2, - staggered = 3, - hexagonal = 4 - } - enum StaggerAxisType { - x = 0, - y = 1 - } - enum StaggerIndexType { - odd = 0, - even = 1 - } - enum RenderOrderType { - rightDown = 0, - rightUp = 1, - leftDown = 2, - leftUp = 3 - } -} -declare module es { - class TmxObjectGroup implements ITmxLayer { - map: TmxMap; - name: string; - opacity: number; - visible: boolean; - offsetX: number; - offsetY: number; - color: number; - drawOrder: DrawOrderType; - objects: TmxObject[]; - properties: Map; - } - class TmxObject implements ITmxElement { - id: number; - name: string; - shape: egret.Shape; - textField: egret.TextField; - objectType: TmxObjectType; - type: string; - x: number; - y: number; - width: number; - height: number; - rotation: number; - tile: TmxLayerTile; - visible: boolean; - text: TmxText; - points: Vector2[]; - properties: Map; - constructor(); - } - class TmxText { - fontFamily: string; - pixelSize: number; - wrap: boolean; - color: number; - bold: boolean; - italic: boolean; - underline: boolean; - strikeout: boolean; - kerning: boolean; - alignment: TmxAlignment; - value: string; - } - class TmxAlignment { - horizontal: TmxHorizontalAlignment; - vertical: TmxVerticalAlignment; - } - enum TmxObjectType { - basic = 0, - point = 1, - tile = 2, - ellipse = 3, - polygon = 4, - polyline = 5, - text = 6 - } - enum DrawOrderType { - unkownOrder = -1, - TopDown = 0, - IndexOrder = 1 - } - enum TmxHorizontalAlignment { - left = 0, - center = 1, - right = 2, - justify = 3 - } - enum TmxVerticalAlignment { - top = 0, - center = 1, - bottom = 2 - } -} -declare module es { - class TiledMapLoader { - static loadTmxMap(map: TmxMap, filePath: string): Promise; - static loadTmxMapData(map: TmxMap, xMap: any, info: any): Promise; - static parseLayers(container: any, xEle: any, map: TmxMap, width: number, height: number, tmxDirectory: string): Promise; - static loadTmxGroup(group: TmxGroup, map: TmxMap, xGroup: any, width: number, height: number, tmxDirectory: string): Promise; - static loadTmxImageLayer(layer: TmxImageLayer, map: TmxMap, xImageLayer: any, tmxDirectory: string): Promise; - static loadTmxLayer(layer: TmxLayer, map: TmxMap, xLayer: any, width: number, height: number): TmxLayer; - private static updateMaxTileSizes; - static parseOrientationType(type: string): OrientationType; - static parseStaggerAxisType(type: string): StaggerAxisType; - static parseStaggerIndexType(type: string): StaggerIndexType; - static parseRenderOrderType(type: string): RenderOrderType; - static parsePropertyDict(prop: any): Map; - static parseTmxTileset(map: TmxMap, xTileset: any): Promise; - static loadTmxTileset(tileset: TmxTileset, map: TmxMap, xTileset: any, firstGid: number): Promise; - static loadTmxTilesetTile(tile: TmxTilesetTile, tileset: TmxTileset, xTile: any, terrains: TmxTerrain[], tmxDirectory: string): Promise; - static loadTmxAnimationFrame(frame: TmxAnimationFrame, xFrame: any): TmxAnimationFrame; - static loadTmxObjectGroup(group: TmxObjectGroup, map: TmxMap, xObjectGroup: any): TmxObjectGroup; - static loadTmxObject(obj: TmxObject, map: TmxMap, xObject: any): TmxObject; - static loadTmxText(text: TmxText, xText: any): TmxText; - static loadTmxAlignment(alignment: TmxAlignment, xText: any): TmxAlignment; - static parsePoints(xPoints: any): any[]; - static parsePoint(pt: { - x: number; - y: number; - }): Vector2; - static parseTmxTerrain(xTerrain: any): TmxTerrain; - static parseTmxTileOffset(xTileOffset: any): TmxTileOffset; - static loadTmxImage(image: TmxImage, xImage: any, tmxDirectory: string): Promise; - } -} -declare module es { - class TiledRendering { - static renderMap(map: TmxMap, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void; - static renderLayer(layer: TmxLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void; - static renderLayerRenderCamera(layer: ITmxLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number, camerClipBounds: Rectangle): void; - static renderLayerCamera(layer: TmxLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number, camerClipBounds: Rectangle): void; - static renderImageLayer(layer: TmxImageLayer, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void; - static renderObjectGroup(objGroup: TmxObjectGroup, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void; - private static renderTilesetTile; - static renderGroup(group: TmxGroup, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, layerDepth: number): void; - static renderTile(tile: TmxLayerTile, container: egret.DisplayObjectContainer, position: Vector2, scale: Vector2, tileWidth: number, tileHeight: number, color: egret.ColorMatrixFilter, layerDepth: number): void; - } -} -declare module es { - class TmxTileset extends TmxDocument implements ITmxElement { - map: TmxMap; - firstGid: number; - name: any; - tileWidth: number; - tileHeight: number; - spacing: number; - margin: number; - columns?: number; - tileCount?: number; - tiles: Map; - tileOffset: TmxTileOffset; - properties: Map; - image: TmxImage; - terrains: TmxTerrain[]; - tileRegions: Map; - update(): void; - } - class TmxTileOffset { - x: number; - y: number; - } - class TmxTerrain implements ITmxElement { - name: any; - tile: number; - properties: Map; - } -} -declare module es { - class TmxTilesetTile { - tileset: TmxTileset; - id: number; - terrainEdges: TmxTerrain[]; - probability: number; - type: string; - properties: Map; - image: TmxImage; - objectGroups: TmxObjectGroup[]; - animationFrames: TmxAnimationFrame[]; - readonly currentAnimationFrameGid: number; - _animationElapsedTime: number; - _animationCurrentFrame: number; - isDestructable: boolean; - isSlope: boolean; - isOneWayPlatform: boolean; - slopeTopLeft: number; - slopeTopRight: number; - processProperties(): void; - updateAnimatedTiles(): void; - } - class TmxAnimationFrame { - gid: number; - duration: number; - } -} -declare module es { - class TmxUtils { - static decode(data: any, encoding: any, compression: string): Array; - static color16ToUnit($color: string): number; - } -} diff --git a/demo/libs/framework_tiled/framework_tiled.js b/demo/libs/framework_tiled/framework_tiled.js deleted file mode 100644 index 4290540b..00000000 --- a/demo/libs/framework_tiled/framework_tiled.js +++ /dev/null @@ -1,1575 +0,0 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var es; -(function (es) { - var TiledMapRenderer = (function (_super) { - __extends(TiledMapRenderer, _super); - function TiledMapRenderer(tiledMap, collisionLayerName, shouldCreateColliders) { - if (collisionLayerName === void 0) { collisionLayerName = null; } - if (shouldCreateColliders === void 0) { shouldCreateColliders = true; } - var _this = _super.call(this) || this; - _this.physicsLayer = new es.Ref(1 << 0); - _this.toContainer = false; - _this.tiledMap = tiledMap; - _this._shouldCreateColliders = shouldCreateColliders; - _this.displayObject = new egret.DisplayObjectContainer(); - if (collisionLayerName) { - _this.collisionLayer = tiledMap.tileLayers.find(function (layer) { return layer.name == collisionLayerName; }); - } - return _this; - } - Object.defineProperty(TiledMapRenderer.prototype, "width", { - get: function () { - return this.tiledMap.width * this.tiledMap.tileWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledMapRenderer.prototype, "height", { - get: function () { - return this.tiledMap.height * this.tiledMap.tileHeight; - }, - enumerable: true, - configurable: true - }); - TiledMapRenderer.prototype.setLayerToRender = function (layerName) { - this.layerIndicesToRender = []; - this.layerIndicesToRender[0] = this.getLayerIndex(layerName); - }; - TiledMapRenderer.prototype.setLayersToRender = function () { - var layerNames = []; - for (var _i = 0; _i < arguments.length; _i++) { - layerNames[_i] = arguments[_i]; - } - this.layerIndicesToRender = []; - for (var i = 0; i < layerNames.length; i++) - this.layerIndicesToRender[i] = this.getLayerIndex(layerNames[i]); - }; - TiledMapRenderer.prototype.getLayerIndex = function (layerName) { - var index = 0; - var layerType = this.tiledMap.getLayer(layerName); - for (var layer in this.tiledMap.layers) { - if (this.tiledMap.layers.hasOwnProperty(layer) && - this.tiledMap.layers[layer] == layerType) { - return index; - } - } - return -1; - }; - TiledMapRenderer.prototype.getRowAtWorldPosition = function (yPos) { - yPos -= this.entity.transform.position.y + this._localOffset.y; - return this.tiledMap.worldToTilePositionY(yPos); - }; - TiledMapRenderer.prototype.getColumnAtWorldPosition = function (xPos) { - xPos -= this.entity.transform.position.x + this._localOffset.x; - return this.tiledMap.worldToTilePositionX(xPos); - }; - TiledMapRenderer.prototype.onEntityTransformChanged = function (comp) { - if (this._shouldCreateColliders && comp == transform.Component.position) { - this.removeColliders(); - this.addColliders(); - } - }; - TiledMapRenderer.prototype.onAddedToEntity = function () { - this.addColliders(); - }; - TiledMapRenderer.prototype.onRemovedFromEntity = function () { - this.removeColliders(); - }; - TiledMapRenderer.prototype.update = function () { - this.tiledMap.update(); - }; - TiledMapRenderer.prototype.render = function (camera) { - this.sync(camera); - if (!this.layerIndicesToRender) { - es.TiledRendering.renderMap(this.tiledMap, !this.toContainer ? this.displayObject : null, es.Vector2.add(this.entity.transform.position, this._localOffset), this.transform.scale, this.renderLayer); - } - else { - for (var i = 0; i < this.tiledMap.layers.length; i++) { - if (this.tiledMap.layers[i].visible && this.layerIndicesToRender.contains(i)) - es.TiledRendering.renderLayerRenderCamera(this.tiledMap.layers[i], !this.toContainer ? this.displayObject : null, es.Vector2.add(this.entity.transform.position, this._localOffset), this.transform.scale, this.renderLayer, camera.bounds); - } - } - if (!this.toContainer) { - this.displayObject.cacheAsBitmap = true; - this.toContainer = true; - } - }; - TiledMapRenderer.prototype.addColliders = function () { - if (!this.collisionLayer || !this._shouldCreateColliders) - return; - var collisionRects = this.collisionLayer.getCollisionRectangles(); - this._colliders = []; - for (var i = 0; i < collisionRects.length; i++) { - var collider = new es.BoxCollider(collisionRects[i].x + this._localOffset.x, collisionRects[i].y + this._localOffset.y, collisionRects[i].width, collisionRects[i].height); - collider.physicsLayer = this.physicsLayer; - collider.entity = this.entity; - this._colliders[i] = collider; - es.Physics.addCollider(collider); - } - }; - TiledMapRenderer.prototype.removeColliders = function () { - if (this._colliders == null) - return; - for (var _i = 0, _a = this._colliders; _i < _a.length; _i++) { - var collider = _a[_i]; - es.Physics.removeCollider(collider); - } - this._colliders = null; - }; - return TiledMapRenderer; - }(es.RenderableComponent)); - es.TiledMapRenderer = TiledMapRenderer; -})(es || (es = {})); -var es; -(function (es) { - var TmxGroup = (function () { - function TmxGroup() { - } - return TmxGroup; - }()); - es.TmxGroup = TmxGroup; -})(es || (es = {})); -var es; -(function (es) { - var TmxImageLayer = (function () { - function TmxImageLayer() { - } - return TmxImageLayer; - }()); - es.TmxImageLayer = TmxImageLayer; -})(es || (es = {})); -var es; -(function (es) { - var TmxLayer = (function () { - function TmxLayer() { - } - Object.defineProperty(TmxLayer.prototype, "offset", { - get: function () { - return new es.Vector2(this.offsetX, this.offsetY); - }, - enumerable: true, - configurable: true - }); - TmxLayer.prototype.getTileWithGid = function (gid) { - for (var i = 0; i < this.tiles.length; i++) { - if (this.tiles[i] && this.tiles[i].gid == gid) - return this.tiles[i]; - } - return null; - }; - TmxLayer.prototype.getTile = function (x, y) { - return this.tiles[x + y * this.width]; - }; - TmxLayer.prototype.getCollisionRectangles = function () { - var checkedIndexes = new Array(this.tiles.length); - var rectangles = []; - var startCol = -1; - var index = -1; - for (var y = 0; y < this.map.height; y++) { - for (var x = 0; x < this.map.width; x++) { - index = y * this.map.width + x; - var tile = this.getTile(x, y); - if (tile && !checkedIndexes[index]) { - if (startCol < 0) - startCol = x; - checkedIndexes[index] = true; - } - else if (!tile || checkedIndexes[index] == true) { - if (startCol >= 0) { - rectangles.push(this.findBoundsRect(startCol, x, y, checkedIndexes)); - startCol = -1; - } - } - } - if (startCol >= 0) { - rectangles.push(this.findBoundsRect(startCol, this.map.width, y, checkedIndexes)); - startCol = -1; - } - } - return rectangles; - }; - TmxLayer.prototype.findBoundsRect = function (startX, endX, startY, checkedIndexes) { - var index = -1; - for (var y = startY + 1; y < this.map.height; y++) { - for (var x = startX; x < endX; x++) { - index = y * this.map.width + x; - var tile = this.getTile(x, y); - if (!tile || checkedIndexes[index]) { - for (var _x = startX; _x < x; _x++) { - index = y * this.map.width + _x; - checkedIndexes[index] = false; - } - return new es.Rectangle(startX * this.map.tileWidth, startY * this.map.tileHeight, (endX - startX) * this.map.tileWidth, (y - startY) * this.map.tileHeight); - } - checkedIndexes[index] = true; - } - } - return new es.Rectangle(startX * this.map.tileWidth, startY * this.map.tileHeight, (endX - startX) * this.map.tileWidth, (this.map.height - startY) * this.map.tileHeight); - }; - return TmxLayer; - }()); - es.TmxLayer = TmxLayer; - var TmxLayerTile = (function () { - function TmxLayerTile(map, id, x, y) { - this.x = x; - this.y = y; - var rawGid = id; - var flip; - flip = (rawGid & TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG) != 0; - this.horizontalFlip = flip; - flip = (rawGid & TmxLayerTile.FLIPPED_VERTICALLY_FLAG) != 0; - this.verticalFlip = flip; - rawGid &= ~(TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG | TmxLayerTile.FLIPPED_VERTICALLY_FLAG); - this.gid = Math.floor(rawGid); - this.tileset = map.getTilesetForTileGid(this.gid); - } - Object.defineProperty(TmxLayerTile.prototype, "position", { - get: function () { - return new es.Vector2(this.x, this.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TmxLayerTile.prototype, "tilesetTile", { - get: function () { - if (!this._tilesetTileIndex) { - this._tilesetTileIndex = -1; - if (this.tileset.firstGid <= this.gid) { - var tilesetTile = this.tileset.tiles.get(this.gid - this.tileset.firstGid); - if (tilesetTile) { - this._tilesetTileIndex = this.gid - this.tileset.firstGid; - } - } - } - if (this._tilesetTileIndex < 0) - return null; - return this.tileset.tiles.get(this._tilesetTileIndex); - }, - enumerable: true, - configurable: true - }); - TmxLayerTile.FLIPPED_HORIZONTALLY_FLAG = 0x80000000; - TmxLayerTile.FLIPPED_VERTICALLY_FLAG = 0x40000000; - return TmxLayerTile; - }()); - es.TmxLayerTile = TmxLayerTile; -})(es || (es = {})); -var es; -(function (es) { - var TmxDocument = (function () { - function TmxDocument() { - this.tmxDirectory = "resource/assets/"; - } - return TmxDocument; - }()); - es.TmxDocument = TmxDocument; - var TmxImage = (function () { - function TmxImage() { - } - TmxImage.prototype.dispose = function () { - if (this.bitmap) { - this.bitmap.dispose(); - this.bitmap = null; - } - }; - return TmxImage; - }()); - es.TmxImage = TmxImage; -})(es || (es = {})); -var es; -(function (es) { - var TmxMap = (function (_super) { - __extends(TmxMap, _super); - function TmxMap() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(TmxMap.prototype, "worldWidth", { - get: function () { - return this.width * this.tileWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TmxMap.prototype, "worldHeight", { - get: function () { - return this.height * this.tileHeight; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TmxMap.prototype, "requiresLargeTileCulling", { - get: function () { - return this.maxTileHeight > this.tileHeight || this.maxTileWidth > this.tileWidth; - }, - enumerable: true, - configurable: true - }); - TmxMap.prototype.getTilesetForTileGid = function (gid) { - if (gid == 0) - return null; - for (var i = this.tilesets.length - 1; i >= 0; i--) { - if (this.tilesets[i].firstGid <= gid) - return this.tilesets[i]; - } - console.error("tile gid" + gid + "\u672A\u5728\u4EFB\u4F55tileset\u4E2D\u627E\u5230"); - }; - TmxMap.prototype.worldToTilePositionX = function (x, clampToTilemapBounds) { - if (clampToTilemapBounds === void 0) { clampToTilemapBounds = true; } - var tileX = Math.floor(x / this.tileWidth); - if (!clampToTilemapBounds) - return tileX; - return es.MathHelper.clamp(tileX, 0, this.width - 1); - }; - TmxMap.prototype.worldToTilePositionY = function (y, clampToTilemapBounds) { - if (clampToTilemapBounds === void 0) { clampToTilemapBounds = true; } - var tileY = Math.floor(y / this.tileHeight); - if (!clampToTilemapBounds) - return tileY; - return es.MathHelper.clamp(tileY, 0, this.height - 1); - }; - TmxMap.prototype.getLayer = function (name) { - return this.layers[name]; - }; - TmxMap.prototype.update = function () { - this.tilesets.forEach(function (tileset) { tileset.update(); }); - }; - TmxMap.prototype.dispose = function (disposing) { - if (disposing === void 0) { disposing = true; } - if (!this._isDisposed) { - if (disposing) { - this.tilesets.forEach(function (tileset) { if (tileset.image) - tileset.image.dispose(); }); - this.imageLayers.forEach(function (layer) { if (layer.image) - layer.image.dispose(); }); - } - this._isDisposed = true; - } - }; - return TmxMap; - }(es.TmxDocument)); - es.TmxMap = TmxMap; - var OrientationType; - (function (OrientationType) { - OrientationType[OrientationType["unknown"] = 0] = "unknown"; - OrientationType[OrientationType["orthogonal"] = 1] = "orthogonal"; - OrientationType[OrientationType["isometric"] = 2] = "isometric"; - OrientationType[OrientationType["staggered"] = 3] = "staggered"; - OrientationType[OrientationType["hexagonal"] = 4] = "hexagonal"; - })(OrientationType = es.OrientationType || (es.OrientationType = {})); - var StaggerAxisType; - (function (StaggerAxisType) { - StaggerAxisType[StaggerAxisType["x"] = 0] = "x"; - StaggerAxisType[StaggerAxisType["y"] = 1] = "y"; - })(StaggerAxisType = es.StaggerAxisType || (es.StaggerAxisType = {})); - var StaggerIndexType; - (function (StaggerIndexType) { - StaggerIndexType[StaggerIndexType["odd"] = 0] = "odd"; - StaggerIndexType[StaggerIndexType["even"] = 1] = "even"; - })(StaggerIndexType = es.StaggerIndexType || (es.StaggerIndexType = {})); - var RenderOrderType; - (function (RenderOrderType) { - RenderOrderType[RenderOrderType["rightDown"] = 0] = "rightDown"; - RenderOrderType[RenderOrderType["rightUp"] = 1] = "rightUp"; - RenderOrderType[RenderOrderType["leftDown"] = 2] = "leftDown"; - RenderOrderType[RenderOrderType["leftUp"] = 3] = "leftUp"; - })(RenderOrderType = es.RenderOrderType || (es.RenderOrderType = {})); -})(es || (es = {})); -var es; -(function (es) { - var TmxObjectGroup = (function () { - function TmxObjectGroup() { - } - return TmxObjectGroup; - }()); - es.TmxObjectGroup = TmxObjectGroup; - var TmxObject = (function () { - function TmxObject() { - this.shape = new egret.Shape(); - this.textField = new egret.TextField(); - } - return TmxObject; - }()); - es.TmxObject = TmxObject; - var TmxText = (function () { - function TmxText() { - } - return TmxText; - }()); - es.TmxText = TmxText; - var TmxAlignment = (function () { - function TmxAlignment() { - } - return TmxAlignment; - }()); - es.TmxAlignment = TmxAlignment; - var TmxObjectType; - (function (TmxObjectType) { - TmxObjectType[TmxObjectType["basic"] = 0] = "basic"; - TmxObjectType[TmxObjectType["point"] = 1] = "point"; - TmxObjectType[TmxObjectType["tile"] = 2] = "tile"; - TmxObjectType[TmxObjectType["ellipse"] = 3] = "ellipse"; - TmxObjectType[TmxObjectType["polygon"] = 4] = "polygon"; - TmxObjectType[TmxObjectType["polyline"] = 5] = "polyline"; - TmxObjectType[TmxObjectType["text"] = 6] = "text"; - })(TmxObjectType = es.TmxObjectType || (es.TmxObjectType = {})); - var DrawOrderType; - (function (DrawOrderType) { - DrawOrderType[DrawOrderType["unkownOrder"] = -1] = "unkownOrder"; - DrawOrderType[DrawOrderType["TopDown"] = 0] = "TopDown"; - DrawOrderType[DrawOrderType["IndexOrder"] = 1] = "IndexOrder"; - })(DrawOrderType = es.DrawOrderType || (es.DrawOrderType = {})); - var TmxHorizontalAlignment; - (function (TmxHorizontalAlignment) { - TmxHorizontalAlignment[TmxHorizontalAlignment["left"] = 0] = "left"; - TmxHorizontalAlignment[TmxHorizontalAlignment["center"] = 1] = "center"; - TmxHorizontalAlignment[TmxHorizontalAlignment["right"] = 2] = "right"; - TmxHorizontalAlignment[TmxHorizontalAlignment["justify"] = 3] = "justify"; - })(TmxHorizontalAlignment = es.TmxHorizontalAlignment || (es.TmxHorizontalAlignment = {})); - var TmxVerticalAlignment; - (function (TmxVerticalAlignment) { - TmxVerticalAlignment[TmxVerticalAlignment["top"] = 0] = "top"; - TmxVerticalAlignment[TmxVerticalAlignment["center"] = 1] = "center"; - TmxVerticalAlignment[TmxVerticalAlignment["bottom"] = 2] = "bottom"; - })(TmxVerticalAlignment = es.TmxVerticalAlignment || (es.TmxVerticalAlignment = {})); -})(es || (es = {})); -var es; -(function (es) { - var TiledMapLoader = (function () { - function TiledMapLoader() { - } - TiledMapLoader.loadTmxMap = function (map, filePath) { - var xMap = RES.getRes(filePath); - return this.loadTmxMapData(map, xMap, RES.getResourceInfo(filePath)); - }; - TiledMapLoader.loadTmxMapData = function (map, xMap, info) { - return __awaiter(this, void 0, void 0, function () { - var _i, _a, e, tileset; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - map.version = xMap["version"]; - map.tiledVersion = xMap["tiledversion"]; - map.width = xMap["width"]; - map.height = xMap["height"]; - map.tileWidth = xMap["tilewidth"]; - map.tileHeight = xMap["tileheight"]; - map.hexSideLength = xMap["hexsidelength"]; - map.orientation = this.parseOrientationType(xMap["orientation"]); - map.staggerAxis = this.parseStaggerAxisType(xMap["staggeraxis"]); - map.staggerIndex = this.parseStaggerIndexType(xMap["staggerindex"]); - map.renderOrder = this.parseRenderOrderType(xMap["renderorder"]); - map.nextObjectID = xMap["nextobjectid"]; - map.backgroundColor = es.TmxUtils.color16ToUnit(xMap["color"]); - map.properties = this.parsePropertyDict(xMap["properties"]); - map.maxTileWidth = map.tileWidth; - map.maxTileHeight = map.tileHeight; - map.tmxDirectory = info.root + info.url.replace(".", "_").replace(info.name, ""); - map.tilesets = []; - _i = 0, _a = xMap["tilesets"]; - _b.label = 1; - case 1: - if (!(_i < _a.length)) return [3, 4]; - e = _a[_i]; - return [4, this.parseTmxTileset(map, e)]; - case 2: - tileset = _b.sent(); - map.tilesets.push(tileset); - this.updateMaxTileSizes(tileset); - _b.label = 3; - case 3: - _i++; - return [3, 1]; - case 4: - map.layers = []; - map.tileLayers = []; - map.objectGroups = []; - map.imageLayers = []; - map.groups = []; - this.parseLayers(map, xMap, map, map.width, map.height, map.tmxDirectory); - return [2, map]; - } - }); - }); - }; - TiledMapLoader.parseLayers = function (container, xEle, map, width, height, tmxDirectory) { - return __awaiter(this, void 0, void 0, function () { - var _i, _a, e, layer, _b, tileLayer, objectgroup, imagelayer, newGroup; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - _i = 0, _a = ObjectUtils.elements(xEle).where(function (x) { - return x.type == "tilelayer" || x.type == "objectgroup" || x.type == "imagelayer" || x.type == "group"; - }); - _c.label = 1; - case 1: - if (!(_i < _a.length)) return [3, 11]; - e = _a[_i]; - layer = void 0; - _b = e.type; - switch (_b) { - case "tilelayer": return [3, 2]; - case "objectgroup": return [3, 3]; - case "imagelayer": return [3, 4]; - case "group": return [3, 6]; - } - return [3, 8]; - case 2: - tileLayer = this.loadTmxLayer(new es.TmxLayer(), map, e, width, height); - layer = tileLayer; - if (container instanceof es.TmxMap || container instanceof es.TmxGroup) - container.tileLayers.push(tileLayer); - return [3, 9]; - case 3: - objectgroup = this.loadTmxObjectGroup(new es.TmxObjectGroup(), map, e); - layer = objectgroup; - if (container instanceof es.TmxMap || container instanceof es.TmxGroup) - container.objectGroups.push(objectgroup); - return [3, 9]; - case 4: return [4, this.loadTmxImageLayer(new es.TmxImageLayer(), map, e, tmxDirectory)]; - case 5: - imagelayer = _c.sent(); - layer = imagelayer; - if (container instanceof es.TmxMap || container instanceof es.TmxGroup) - container.imageLayers.push(imagelayer); - return [3, 9]; - case 6: return [4, this.loadTmxGroup(new es.TmxGroup(), map, e, width, height, tmxDirectory)]; - case 7: - newGroup = _c.sent(); - layer = newGroup; - if (container instanceof es.TmxMap || container instanceof es.TmxGroup) - container.groups.push(newGroup); - return [3, 9]; - case 8: throw new Error("无效的操作"); - case 9: - if (container instanceof es.TmxMap || container instanceof es.TmxGroup) - container.layers.push(layer); - _c.label = 10; - case 10: - _i++; - return [3, 1]; - case 11: return [2]; - } - }); - }); - }; - TiledMapLoader.loadTmxGroup = function (group, map, xGroup, width, height, tmxDirectory) { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - group.map = map; - group.name = xGroup["name"] != undefined ? xGroup["name"] : ""; - group.opacity = xGroup["opacity"] != undefined ? xGroup["opacity"] : 1; - group.visible = xGroup["visible"] != undefined ? xGroup["visible"] : true; - group.offsetX = xGroup["offsetx"] != undefined ? xGroup["offsetx"] : 0; - group.offsetY = xGroup["offsety"] != undefined ? xGroup["offsety"] : 0; - group.properties = this.parsePropertyDict(xGroup["properties"]); - group.layers = []; - group.tileLayers = []; - group.objectGroups = []; - group.imageLayers = []; - group.groups = []; - return [4, this.parseLayers(group, xGroup, map, width, height, tmxDirectory)]; - case 1: - _a.sent(); - return [2, group]; - } - }); - }); - }; - TiledMapLoader.loadTmxImageLayer = function (layer, map, xImageLayer, tmxDirectory) { - return __awaiter(this, void 0, void 0, function () { - var xImage, _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - layer.map = map; - layer.name = xImageLayer["name"]; - layer.width = xImageLayer["width"]; - layer.height = xImageLayer["height"]; - layer.visible = xImageLayer["visible"] != undefined ? xImageLayer["visible"] : true; - layer.opacity = xImageLayer["opacity"] != undefined ? xImageLayer["opacity"] : 1; - layer.offsetX = xImageLayer["offsetx"] != undefined ? xImageLayer["offsetx"] : 0; - layer.offsetY = xImageLayer["offsety"] != undefined ? xImageLayer["offsety"] : 0; - xImage = xImageLayer["image"]; - if (!xImage) return [3, 2]; - _a = layer; - return [4, this.loadTmxImage(new es.TmxImage(), xImage, tmxDirectory)]; - case 1: - _a.image = _b.sent(); - _b.label = 2; - case 2: - layer.properties = this.parsePropertyDict(xImageLayer["properties"]); - return [2, layer]; - } - }); - }); - }; - TiledMapLoader.loadTmxLayer = function (layer, map, xLayer, width, height) { - layer.map = map; - layer.name = xLayer["name"]; - layer.opacity = xLayer["opacity"] != undefined ? xLayer["opacity"] : 1; - layer.visible = xLayer["visible"] != undefined ? xLayer["visible"] : true; - layer.offsetX = xLayer["offsetx"] != undefined ? xLayer["offsetx"] : 0; - layer.offsetY = xLayer["offsety"] != undefined ? xLayer["offsety"] : 0; - layer.width = xLayer["width"]; - layer.height = xLayer["height"]; - var xData = xLayer["data"]; - var encoding = xData["encoding"] != undefined ? xData["encoding"] : "csv"; - layer.tiles = new Array(width * height); - if (encoding == "base64") { - var br = es.TmxUtils.decode(xData.toString(), encoding, xData["compression"]); - var index = 0; - for (var j = 0; j < height; j++) { - for (var i = 0; i < width; i++) { - var gid = br[index]; - layer.tiles[index++] = gid != 0 ? new es.TmxLayerTile(map, gid, i, j) : null; - } - } - } - else if (encoding == "csv") { - var k = 0; - for (var _i = 0, xData_1 = xData; _i < xData_1.length; _i++) { - var s = xData_1[_i]; - var gid = s; - var x = k % width; - var y = k / width; - layer.tiles[k++] = gid != 0 ? new es.TmxLayerTile(map, gid, x, y) : null; - } - } - else if (!encoding) { - var k = 0; - for (var _a = 0, _b = xData["tile"]; _a < _b.length; _a++) { - var e = _b[_a]; - var gid = e["gid"] != undefined ? e["gid"] : 0; - var x = k % width; - var y = k / width; - layer.tiles[k++] = gid != 0 ? new es.TmxLayerTile(map, gid, x, y) : null; - } - } - else { - throw new Error("TmxLayer:未知编码"); - } - layer.properties = TiledMapLoader.parsePropertyDict(xLayer["properties"]); - return layer; - }; - TiledMapLoader.updateMaxTileSizes = function (tileset) { - tileset.tiles.forEach(function (tile) { - if (tile.image) { - if (tile.image.width > tileset.map.maxTileWidth) - tileset.map.maxTileWidth = tile.image.width; - if (tile.image.height > tileset.map.maxTileHeight) - tileset.map.maxTileHeight = tile.image.height; - } - }); - tileset.tileRegions.forEach(function (region) { - var width = region.width; - var height = region.height; - if (width > tileset.map.maxTileWidth) - tileset.map.maxTileWidth = width; - if (width > tileset.map.maxTileHeight) - tileset.map.maxTileHeight = height; - }); - }; - TiledMapLoader.parseOrientationType = function (type) { - if (type == "unknown") - return es.OrientationType.unknown; - if (type == "orthogonal") - return es.OrientationType.orthogonal; - if (type == "isometric") - return es.OrientationType.isometric; - if (type == "staggered") - return es.OrientationType.staggered; - if (type == "hexagonal") - return es.OrientationType.hexagonal; - return es.OrientationType.unknown; - }; - TiledMapLoader.parseStaggerAxisType = function (type) { - if (type == "y") - return es.StaggerAxisType.y; - return es.StaggerAxisType.x; - }; - TiledMapLoader.parseStaggerIndexType = function (type) { - if (type == "even") - return es.StaggerIndexType.even; - return es.StaggerIndexType.odd; - }; - TiledMapLoader.parseRenderOrderType = function (type) { - if (type == "right-up") - return es.RenderOrderType.rightUp; - if (type == "left-down") - return es.RenderOrderType.leftDown; - if (type == "left-up") - return es.RenderOrderType.leftUp; - return es.RenderOrderType.rightDown; - }; - TiledMapLoader.parsePropertyDict = function (prop) { - if (!prop) - return null; - var dict = new Map(); - for (var _i = 0, prop_1 = prop; _i < prop_1.length; _i++) { - var p = prop_1[_i]; - var pname = p["name"]; - var valueAttr = p["value"]; - if (p["type"] == "color") - dict.set(pname, es.TmxUtils.color16ToUnit(valueAttr).toString()); - else - dict.set(pname, valueAttr); - } - return dict; - }; - TiledMapLoader.parseTmxTileset = function (map, xTileset) { - return __awaiter(this, void 0, void 0, function () { - var xFirstGid, firstGid, source, xDocTileset; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - xFirstGid = xTileset["firstgid"]; - firstGid = xFirstGid; - source = xTileset["source"]; - if (!(source != undefined)) return [3, 2]; - source = map.tmxDirectory + source; - return [4, RES.getResByUrl(source).catch(function (err) { - throw new Error(err); - })]; - case 1: - xDocTileset = _a.sent(); - return [2, this.loadTmxTileset(new es.TmxTileset(), map, xDocTileset["tileset"], firstGid)]; - case 2: return [2, this.loadTmxTileset(new es.TmxTileset(), map, xTileset, firstGid)]; - } - }); - }); - }; - TiledMapLoader.loadTmxTileset = function (tileset, map, xTileset, firstGid) { - return __awaiter(this, void 0, void 0, function () { - var xImage, _i, _a, e, _b, _c, _d, t, xTile, tile, id, y, column, x; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - tileset.map = map; - tileset.firstGid = firstGid; - tileset.name = xTileset["name"]; - tileset.tileWidth = xTileset["tilewidth"]; - tileset.tileHeight = xTileset["tileheight"]; - tileset.spacing = xTileset["spacing"] != undefined ? xTileset["spacing"] : 0; - tileset.margin = xTileset["margin"] != undefined ? xTileset["margin"] : 0; - tileset.columns = xTileset["columns"]; - tileset.tileCount = xTileset["tilecount"]; - tileset.tileOffset = this.parseTmxTileOffset(xTileset["tileoffset"]); - xImage = xTileset["image"]; - if (!xImage) return [3, 2]; - return [4, this.loadTmxImage(new es.TmxImage(), xTileset, map.tmxDirectory).then(function (image) { - tileset.image = image; - }).catch(function (err) { - throw new Error(err); - })]; - case 1: - _e.sent(); - _e.label = 2; - case 2: - tileset.terrains = []; - if (xTileset["terrains"]) - for (_i = 0, _a = xTileset["terrains"]; _i < _a.length; _i++) { - e = _a[_i]; - tileset.terrains.push(this.parseTmxTerrain(e)); - } - tileset.tiles = new Map(); - _b = []; - for (_c in xTileset["tiles"]) - _b.push(_c); - _d = 0; - _e.label = 3; - case 3: - if (!(_d < _b.length)) return [3, 6]; - t = _b[_d]; - if (!xTileset["tiles"].hasOwnProperty(t)) return [3, 5]; - xTile = xTileset["tiles"][t]; - return [4, this.loadTmxTilesetTile(new es.TmxTilesetTile(), tileset, xTile, tileset.terrains, map.tmxDirectory)]; - case 4: - tile = _e.sent(); - tileset.tiles.set(tile.id == undefined ? Number(t) + 1 : tile.id, tile); - _e.label = 5; - case 5: - _d++; - return [3, 3]; - case 6: - tileset.properties = this.parsePropertyDict(xTileset["properties"]); - tileset.tileRegions = new Map(); - if (tileset.image) { - id = firstGid; - for (y = tileset.margin; y < tileset.image.height - tileset.margin; y += tileset.tileHeight + tileset.spacing) { - column = 0; - for (x = tileset.margin; x < tileset.image.width - tileset.margin; x += tileset.tileWidth + tileset.spacing) { - tileset.tileRegions.set(id++, new es.Rectangle(x, y, tileset.tileWidth, tileset.tileHeight)); - if (++column >= tileset.columns) - break; - } - } - } - else { - tileset.tiles.forEach(function (tile, key) { - tileset.tileRegions.set(key, new es.Rectangle(0, 0, tile.image.width, tile.image.height)); - }); - } - return [2, tileset]; - } - }); - }); - }; - TiledMapLoader.loadTmxTilesetTile = function (tile, tileset, xTile, terrains, tmxDirectory) { - return __awaiter(this, void 0, void 0, function () { - var strTerrain, index, _i, strTerrain_1, v, edge, xImage, _a, _b, _c, e, _d, _e, e; - return __generator(this, function (_f) { - switch (_f.label) { - case 0: - tile.tileset = tileset; - tile.id = xTile["id"]; - strTerrain = xTile["terrain"]; - if (strTerrain) { - tile.terrainEdges = new Array(4); - index = 0; - for (_i = 0, strTerrain_1 = strTerrain; _i < strTerrain_1.length; _i++) { - v = strTerrain_1[_i]; - edge = terrains[v]; - tile.terrainEdges[index++] = edge; - } - } - tile.probability = xTile["probability"] != undefined ? xTile["probability"] : 1; - tile.type = xTile["type"]; - xImage = xTile["image"]; - if (!xImage) return [3, 2]; - _a = tile; - return [4, this.loadTmxImage(new es.TmxImage(), xImage, tmxDirectory)]; - case 1: - _a.image = _f.sent(); - _f.label = 2; - case 2: - tile.objectGroups = []; - if (xTile["objectgroup"]) - for (_b = 0, _c = xTile["objectgroup"]; _b < _c.length; _b++) { - e = _c[_b]; - tile.objectGroups.push(this.loadTmxObjectGroup(new es.TmxObjectGroup(), tileset.map, e)); - } - tile.animationFrames = []; - if (xTile["animation"]) { - for (_d = 0, _e = xTile["animation"]["frame"]; _d < _e.length; _d++) { - e = _e[_d]; - tile.animationFrames.push(this.loadTmxAnimationFrame(new es.TmxAnimationFrame(), e)); - } - } - tile.properties = this.parsePropertyDict(xTile["properties"]); - if (tile.properties) - tile.processProperties(); - return [2, tile]; - } - }); - }); - }; - TiledMapLoader.loadTmxAnimationFrame = function (frame, xFrame) { - frame.gid = xFrame["tileid"]; - frame.duration = xFrame["duration"] / 1000; - return frame; - }; - TiledMapLoader.loadTmxObjectGroup = function (group, map, xObjectGroup) { - group.map = map; - group.name = xObjectGroup["name"] != undefined ? xObjectGroup["name"] : ""; - group.color = es.TmxUtils.color16ToUnit(xObjectGroup["color"]); - group.opacity = xObjectGroup["opacity"] != undefined ? xObjectGroup["opacity"] : 1; - group.visible = xObjectGroup["visible"] != undefined ? xObjectGroup["visible"] : true; - group.offsetX = xObjectGroup["offsetx"] != undefined ? xObjectGroup["offsetx"] : 0; - group.offsetY = xObjectGroup["offsety"] != undefined ? xObjectGroup["offsety"] : 0; - var drawOrderDict = new Map(); - drawOrderDict.set("unknown", es.DrawOrderType.unkownOrder); - drawOrderDict.set("topdown", es.DrawOrderType.IndexOrder); - drawOrderDict.set("index", es.DrawOrderType.TopDown); - var drawOrderValue = xObjectGroup["draworder"]; - if (drawOrderValue) - group.drawOrder = drawOrderDict.get(drawOrderValue); - group.objects = []; - for (var _i = 0, _a = xObjectGroup["objects"]; _i < _a.length; _i++) { - var e = _a[_i]; - group.objects.push(this.loadTmxObject(new es.TmxObject(), map, e)); - } - group.properties = this.parsePropertyDict(xObjectGroup["properties"]); - return group; - }; - TiledMapLoader.loadTmxObject = function (obj, map, xObject) { - obj.id = xObject["id"] != undefined ? xObject["id"] : 0; - obj.name = xObject["name"] != undefined ? xObject["name"] : ""; - obj.x = xObject["x"]; - obj.y = xObject["y"]; - obj.width = xObject["width"] != undefined ? xObject["width"] : 0; - obj.height = xObject["height"] != undefined ? xObject["height"] : 0; - obj.type = xObject["type"] != undefined ? xObject["type"] : ""; - obj.visible = xObject["visible"] != undefined ? xObject["visible"] : true; - obj.rotation = xObject["rotation"] != undefined ? xObject["rotation"] : 0; - var xGid = xObject["gid"]; - var xEllipse = xObject["ellipse"]; - var xPolygon = xObject["polygon"]; - var xPolyline = xObject["polyline"]; - var xText = xObject["text"]; - var xPoint = xObject["point"]; - if (xGid) { - obj.tile = new es.TmxLayerTile(map, xGid, Math.round(obj.x), Math.round(obj.y)); - obj.objectType = es.TmxObjectType.tile; - } - else if (xEllipse) { - obj.objectType = es.TmxObjectType.ellipse; - } - else if (xPolygon) { - obj.points = this.parsePoints(xPolygon); - obj.objectType = es.TmxObjectType.polygon; - } - else if (xPolyline) { - obj.points = this.parsePoints(xPolyline); - obj.objectType = es.TmxObjectType.polyline; - } - else if (xText) { - obj.text = this.loadTmxText(new es.TmxText(), xText); - obj.objectType = es.TmxObjectType.text; - } - else if (xPoint) { - obj.objectType = es.TmxObjectType.point; - } - else { - obj.objectType = es.TmxObjectType.basic; - } - obj.properties = this.parsePropertyDict(xObject["properties"]); - return obj; - }; - TiledMapLoader.loadTmxText = function (text, xText) { - text.fontFamily = xText["fontfamily"] != undefined ? xText["fontfamily"] : "sans-serif"; - text.pixelSize = xText["pixelsize"] != undefined ? xText["pixelsize"] : 16; - text.wrap = xText["wrap"] != undefined ? xText["wrap"] : false; - text.color = es.TmxUtils.color16ToUnit(xText["color"]); - text.bold = xText["bold"] ? xText["bold"] : false; - text.italic = xText["italic"] ? xText["italic"] : false; - text.underline = xText["underline"] ? xText["underline"] : false; - text.strikeout = xText["strikeout"] ? xText["strikeout"] : false; - text.kerning = xText["kerning"] ? xText["kerning"] : true; - text.alignment = this.loadTmxAlignment(new es.TmxAlignment(), xText); - text.value = xText; - return text; - }; - TiledMapLoader.loadTmxAlignment = function (alignment, xText) { - function firstLetterToUpperCase(str) { - if (!str || str == "") - return str; - return str[0].toString().toUpperCase() + str.substr(1); - } - var xHorizontal = xText["halign"] != undefined ? xText["halign"] : "left"; - alignment.horizontal = es.TmxHorizontalAlignment[firstLetterToUpperCase(xHorizontal)]; - var xVertical = xText["valign"] != undefined ? xText["valign"] : "top"; - alignment.vertical = es.TmxVerticalAlignment[firstLetterToUpperCase((xVertical))]; - return alignment; - }; - TiledMapLoader.parsePoints = function (xPoints) { - var points = []; - var index = 0; - for (var _i = 0, xPoints_1 = xPoints; _i < xPoints_1.length; _i++) { - var s = xPoints_1[_i]; - points[index++] = this.parsePoint(s); - } - return points; - }; - TiledMapLoader.parsePoint = function (pt) { - return new es.Vector2(pt.x, pt.y); - }; - TiledMapLoader.parseTmxTerrain = function (xTerrain) { - var terrain = new es.TmxTerrain(); - terrain.name = xTerrain["name"]; - terrain.tile = xTerrain["tile"]; - terrain.properties = this.parsePropertyDict(xTerrain["properties"]); - return terrain; - }; - TiledMapLoader.parseTmxTileOffset = function (xTileOffset) { - var tmxTileOffset = new es.TmxTileOffset(); - if (!xTileOffset) { - tmxTileOffset.x = 0; - tmxTileOffset.y = 0; - return tmxTileOffset; - } - tmxTileOffset.x = xTileOffset["x"]; - tmxTileOffset.y = xTileOffset["y"]; - return tmxTileOffset; - }; - TiledMapLoader.loadTmxImage = function (image, xImage, tmxDirectory) { - return __awaiter(this, void 0, void 0, function () { - var xSource, texture; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - xSource = xImage["image"]; - if (xSource != undefined) { - image.source = tmxDirectory + xSource; - } - else { - image.source = tmxDirectory + xImage; - } - return [4, RES.getResByUrl(image.source, null, this, RES.ResourceItem.TYPE_IMAGE).catch(function (err) { - throw new Error(err); - })]; - case 1: - texture = _a.sent(); - image.bitmap = new egret.SpriteSheet(texture); - image.trans = es.TmxUtils.color16ToUnit(xImage["trans"]); - image.width = xImage["imagewidth"] != undefined ? xImage["imagewidth"] : texture.textureWidth; - image.height = xImage["imageheight"] != undefined ? xImage["imageheight"] : texture.textureHeight; - return [2, image]; - } - }); - }); - }; - return TiledMapLoader; - }()); - es.TiledMapLoader = TiledMapLoader; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var TiledRendering = (function () { - function TiledRendering() { - } - TiledRendering.renderMap = function (map, container, position, scale, layerDepth) { - var _this = this; - map.layers.forEach(function (layer) { - if (layer instanceof es.TmxLayer && layer.visible) { - _this.renderLayer(layer, container, position, scale, layerDepth); - } - else if (layer instanceof es.TmxImageLayer && layer.visible) { - _this.renderImageLayer(layer, container, position, scale, layerDepth); - } - else if (layer instanceof es.TmxGroup && layer.visible) { - _this.renderGroup(layer, container, position, scale, layerDepth); - } - else if (layer instanceof es.TmxObjectGroup && layer.visible) { - _this.renderObjectGroup(layer, container, position, scale, layerDepth); - } - }); - }; - TiledRendering.renderLayer = function (layer, container, position, scale, layerDepth) { - if (!layer.visible) - return; - var tileWidth = layer.map.tileWidth * scale.x; - var tileHeight = layer.map.tileHeight * scale.y; - var color = es.DrawUtils.getColorMatrix(0xFFFFFF); - for (var i = 0; i < layer.tiles.length; i++) { - var tile = layer.tiles[i]; - if (!tile) - continue; - this.renderTile(tile, container, position, scale, tileWidth, tileHeight, color, layerDepth); - } - }; - TiledRendering.renderLayerRenderCamera = function (layer, container, position, scale, layerDepth, camerClipBounds) { - if (layer instanceof es.TmxLayer && layer.visible) { - this.renderLayerCamera(layer, container, position, scale, layerDepth, camerClipBounds); - } - else if (layer instanceof es.TmxImageLayer && layer.visible) { - this.renderImageLayer(layer, container, position, scale, layerDepth); - } - else if (layer instanceof es.TmxGroup && layer.visible) { - this.renderGroup(layer, container, position, scale, layerDepth); - } - else if (layer instanceof es.TmxObjectGroup && layer.visible) { - this.renderObjectGroup(layer, container, position, scale, layerDepth); - } - }; - TiledRendering.renderLayerCamera = function (layer, container, position, scale, layerDepth, camerClipBounds) { - if (!layer.visible) - return; - position = position.add(layer.offset); - camerClipBounds.location = camerClipBounds.location.subtract(position); - var tileWidth = layer.map.tileWidth * scale.x; - var tileHeight = layer.map.tileHeight * scale.y; - var minX, minY, maxX, maxY = 0; - if (layer.map.requiresLargeTileCulling) { - minX = layer.map.worldToTilePositionX(camerClipBounds.left - (layer.map.maxTileWidth * scale.x - tileWidth)); - minY = layer.map.worldToTilePositionY(camerClipBounds.top - (layer.map.maxTileHeight * scale.y - tileHeight)); - maxX = layer.map.worldToTilePositionX(camerClipBounds.right + (layer.map.maxTileWidth * scale.x - tileWidth)); - maxY = layer.map.worldToTilePositionY(camerClipBounds.bottom + (layer.map.maxTileHeight * scale.y - tileHeight)); - } - else { - minX = layer.map.worldToTilePositionX(camerClipBounds.left); - minY = layer.map.worldToTilePositionY(camerClipBounds.top); - maxX = layer.map.worldToTilePositionX(camerClipBounds.right); - maxY = layer.map.worldToTilePositionY(camerClipBounds.bottom); - } - var color = es.DrawUtils.getColorMatrix(0xFFFFFF); - for (var y = minY; y <= maxY; y++) { - for (var x = minX; x <= maxX; x++) { - var tile = layer.getTile(x, y); - if (tile) - this.renderTile(tile, container, position, scale, tileWidth, tileHeight, color, layerDepth); - } - } - }; - TiledRendering.renderImageLayer = function (layer, container, position, scale, layerDepth) { - if (!layer.visible) - return; - var color = es.DrawUtils.getColorMatrix(0xFFFFFF); - var pos = es.Vector2.add(position, new es.Vector2(layer.offsetX, layer.offsetY).multiply(scale)); - if (!layer.image.texture.parent) - container.addChild(layer.image.texture); - layer.image.texture.x = pos.x; - layer.image.texture.y = pos.y; - layer.image.texture.scaleX = scale.x; - layer.image.texture.scaleY = scale.y; - layer.image.texture.filters = [color]; - }; - TiledRendering.renderObjectGroup = function (objGroup, container, position, scale, layerDepth) { - if (!objGroup.visible) - return; - function debugRender(obj, pos) { - if (!container) - return; - if (!es.Core.debugRenderEndabled) - return; - if (!obj.textField.parent && obj.name) { - obj.textField.text = obj.name; - obj.textField.size = 12; - obj.textField.fontFamily = "sans-serif"; - if (obj.shape) { - obj.textField.x = pos.x + (obj.shape.getBounds().width - obj.textField.width) / 2 + obj.shape.getBounds().x; - obj.textField.y = pos.y - obj.textField.height - 5 + obj.shape.getBounds().y; - } - else { - obj.textField.x = pos.x + (obj.width - obj.textField.width) / 2; - obj.textField.y = pos.y - obj.textField.height - 5; - } - obj.textField.background = true; - obj.textField.backgroundColor = 0xa0a0a4; - obj.textField.textColor = 0xffffff; - container.addChild(obj.textField); - } - } - for (var object in objGroup.objects) { - var obj = objGroup.objects[object]; - if (!obj.visible) - continue; - if (!es.Core.debugRenderEndabled) { - if (obj.objectType != es.TmxObjectType.tile && obj.objectType != es.TmxObjectType.text) - continue; - } - var pos = es.Vector2.add(position, new es.Vector2(obj.x, obj.y).multiply(scale)); - switch (obj.objectType) { - case es.TmxObjectType.basic: - if (!obj.shape.parent) { - obj.shape.x = obj.x; - obj.shape.y = obj.y; - container.addChild(obj.shape); - obj.shape.graphics.clear(); - obj.shape.graphics.lineStyle(1, 0xa0a0a4); - obj.shape.graphics.beginFill(0x979798, 0.5); - obj.shape.graphics.drawRect(0, 0, obj.width * scale.x, obj.height * scale.y); - obj.shape.graphics.endFill(); - debugRender(obj, pos); - } - break; - case es.TmxObjectType.point: - var size = objGroup.map.tileWidth * 0.5; - pos.x -= size * 0.5; - pos.y -= size * 0.5; - if (!obj.shape.parent) { - obj.shape.x = pos.x; - obj.shape.y = pos.y; - container.addChild(obj.shape); - obj.shape.graphics.clear(); - obj.shape.graphics.lineStyle(1, 0xa0a0a4); - obj.shape.graphics.beginFill(0x979798, 0.5); - obj.shape.graphics.drawCircle(0, 0, 1); - obj.shape.graphics.endFill(); - debugRender(obj, pos); - } - break; - case es.TmxObjectType.tile: - this.renderTilesetTile(objGroup, obj, container, pos, scale, debugRender); - break; - case es.TmxObjectType.ellipse: - pos = new es.Vector2(obj.x + obj.width * 0.5, obj.y + obj.height * 0.5).multiply(scale); - if (!obj.shape.parent) { - obj.shape.x = pos.x; - obj.shape.y = pos.y; - container.addChild(obj.shape); - obj.shape.graphics.clear(); - obj.shape.graphics.lineStyle(1, 0xa0a0a4); - obj.shape.graphics.beginFill(0x979798, 0.5); - obj.shape.graphics.drawCircle(0, 0, obj.width * 0.5); - obj.shape.graphics.endFill(); - debugRender(obj, pos); - } - break; - case es.TmxObjectType.polygon: - case es.TmxObjectType.polyline: - var points = []; - for (var i = 0; i < obj.points.length; i++) - points[i] = es.Vector2.multiply(obj.points[i], scale); - if (!obj.shape.parent && points.length > 0) { - obj.shape.x = pos.x; - obj.shape.y = pos.y; - container.addChild(obj.shape); - obj.shape.graphics.clear(); - obj.shape.graphics.lineStyle(1, 0xa0a0a4); - for (var i = 0; i < points.length; i++) { - if (i == 0) { - obj.shape.graphics.moveTo(points[i].x, points[i].y); - } - else { - obj.shape.graphics.lineTo(points[i].x, points[i].y); - } - } - obj.shape.graphics.endFill(); - debugRender(obj, pos); - } - break; - case es.TmxObjectType.text: - if (!obj.textField.parent) { - obj.textField.x = pos.x; - obj.textField.y = pos.y; - container.addChild(obj.textField); - obj.textField.text = obj.text.value; - obj.textField.textColor = obj.text.color; - obj.textField.bold = obj.text.bold != undefined ? obj.text.bold : false; - obj.textField.italic = obj.text.italic != undefined ? obj.text.italic : false; - obj.textField.size = obj.text.pixelSize; - obj.textField.fontFamily = obj.text.fontFamily; - } - break; - default: - break; - } - } - }; - TiledRendering.renderTilesetTile = function (objGroup, obj, container, pos, scale, debugRender) { - var tileset = objGroup.map.getTilesetForTileGid(obj.tile.gid); - var sourceRect = tileset.tileRegions.get(obj.tile.gid); - if (container) { - if (tileset.image) { - if (obj.tile.horizontalFlip && obj.tile.verticalFlip) { - pos.x += tileset.tileHeight + (sourceRect.height * scale.y - tileset.tileHeight); - pos.y -= (sourceRect.width * scale.x - tileset.tileWidth); - } - else if (obj.tile.horizontalFlip) { - pos.x += tileset.tileWidth + (sourceRect.height * scale.y - tileset.tileHeight); - } - else if (obj.tile.verticalFlip) { - pos.y += (tileset.tileWidth - sourceRect.width * scale.x); - } - else { - pos.y += (tileset.tileHeight - sourceRect.height * scale.y); - } - var texture = tileset.image.bitmap.getTexture("" + obj.tile.gid); - if (!texture) { - texture = tileset.image.bitmap.createTexture("" + obj.tile.gid, sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height); - } - tileset.image.texture = new Bitmap(texture); - container.addChild(tileset.image.texture); - tileset.image.texture.x = pos.x; - tileset.image.texture.y = pos.y; - if (obj.tile.verticalFlip && obj.tile.horizontalFlip) { - tileset.image.texture.scaleX = -1; - tileset.image.texture.scaleY = -1; - } - else if (obj.tile.verticalFlip) { - tileset.image.texture.scaleX = scale.x; - tileset.image.texture.scaleY = -1; - } - else if (obj.tile.horizontalFlip) { - tileset.image.texture.scaleX = -1; - tileset.image.texture.scaleY = scale.y; - } - else { - tileset.image.texture.scaleX = scale.x; - tileset.image.texture.scaleY = scale.y; - } - tileset.image.texture.anchorOffsetX = 0; - tileset.image.texture.anchorOffsetY = 0; - debugRender(obj, pos); - } - else { - var tilesetTile = tileset.tiles.get(obj.tile.gid); - var texture = tilesetTile.image.bitmap.getTexture("" + obj.tile.gid); - if (!texture) { - texture = tilesetTile.image.bitmap.createTexture("" + obj.tile.gid, sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height); - } - pos.y -= obj.height; - tilesetTile.image.texture = new Bitmap(texture); - container.addChild(tilesetTile.image.texture); - tilesetTile.image.texture.width = obj.width; - tilesetTile.image.texture.height = obj.height; - tilesetTile.image.texture.x = pos.x; - tilesetTile.image.texture.y = pos.y; - if (obj.tile.verticalFlip && obj.tile.horizontalFlip) { - tilesetTile.image.texture.scaleX = -1; - tilesetTile.image.texture.scaleY = -1; - } - else if (obj.tile.verticalFlip) { - tilesetTile.image.texture.scaleX = scale.x; - tilesetTile.image.texture.scaleY = -1; - } - else if (obj.tile.horizontalFlip) { - tilesetTile.image.texture.scaleX = -1; - tilesetTile.image.texture.scaleY = scale.y; - } - else { - tilesetTile.image.texture.scaleX = scale.x; - tilesetTile.image.texture.scaleY = scale.y; - } - tilesetTile.image.texture.anchorOffsetX = 0; - tilesetTile.image.texture.anchorOffsetY = 0; - } - } - }; - TiledRendering.renderGroup = function (group, container, position, scale, layerDepth) { - var _this = this; - if (!group.visible) - return; - group.layers.forEach(function (layer) { - if (layer instanceof es.TmxGroup) { - _this.renderGroup(layer, container, position, scale, layerDepth); - } - if (layer instanceof es.TmxObjectGroup) { - _this.renderObjectGroup(layer, container, position, scale, layerDepth); - } - if (layer instanceof es.TmxLayer) { - _this.renderLayer(layer, container, position, scale, layerDepth); - } - if (layer instanceof es.TmxImageLayer) { - _this.renderImageLayer(layer, container, position, scale, layerDepth); - } - }); - }; - TiledRendering.renderTile = function (tile, container, position, scale, tileWidth, tileHeight, color, layerDepth) { - var gid = tile.gid; - var tilesetTile = tile.tilesetTile; - if (tilesetTile && tilesetTile.animationFrames.length > 0) - gid = tilesetTile.currentAnimationFrameGid; - var sourceRect = tile.tileset.tileRegions.get(gid); - var tx = Math.floor(tile.x) * tileWidth; - var ty = Math.floor(tile.y) * tileHeight; - var rotation = 0; - if (tile.horizontalFlip && tile.verticalFlip) { - tx += tileHeight + (sourceRect.height * scale.y - tileHeight); - ty -= (sourceRect.width * scale.x - tileWidth); - } - else if (tile.horizontalFlip) { - tx += tileWidth + (sourceRect.height * scale.y - tileHeight); - } - else if (tile.verticalFlip) { - ty += (tileWidth - sourceRect.width * scale.x); - } - else { - ty += (tileHeight - sourceRect.height * scale.y); - } - var pos = new es.Vector2(tx, ty).add(position); - if (tile.tileset.image) { - if (container) { - var texture = tile.tileset.image.bitmap.getTexture("" + gid); - if (!texture) { - texture = tile.tileset.image.bitmap.createTexture("" + gid, sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height); - } - tile.tileset.image.texture = new Bitmap(texture); - container.addChild(tile.tileset.image.texture); - if (tile.tileset.image.texture.x != pos.x) - tile.tileset.image.texture.x = pos.x; - if (tile.tileset.image.texture.y != pos.y) - tile.tileset.image.texture.y = pos.y; - if (tile.verticalFlip && tile.horizontalFlip) { - tile.tileset.image.texture.scaleX = -1; - tile.tileset.image.texture.scaleY = -1; - } - else if (tile.verticalFlip) { - tile.tileset.image.texture.scaleX = scale.x; - tile.tileset.image.texture.scaleY = -1; - } - else if (tile.horizontalFlip) { - tile.tileset.image.texture.scaleX = -1; - tile.tileset.image.texture.scaleY = scale.y; - } - else { - tile.tileset.image.texture.scaleX = scale.x; - tile.tileset.image.texture.scaleY = scale.y; - } - if (tile.tileset.image.texture.rotation != rotation) - tile.tileset.image.texture.rotation = rotation; - if (tile.tileset.image.texture.anchorOffsetX != 0) - tile.tileset.image.texture.anchorOffsetX = 0; - if (tile.tileset.image.texture.anchorOffsetY != 0) - tile.tileset.image.texture.anchorOffsetY = 0; - } - } - else { - if (tilesetTile.image.texture) { - if (!tilesetTile.image.bitmap.getTexture(gid.toString())) { - tilesetTile.image.texture = new Bitmap(tilesetTile.image.bitmap.createTexture(gid.toString(), sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height)); - container.addChild(tilesetTile.image.texture); - } - tilesetTile.image.texture.x = pos.x; - tilesetTile.image.texture.y = pos.y; - tilesetTile.image.texture.scaleX = scale.x; - tilesetTile.image.texture.scaleY = scale.y; - tilesetTile.image.texture.rotation = rotation; - tilesetTile.image.texture.anchorOffsetX = 0; - tilesetTile.image.texture.anchorOffsetY = 0; - tilesetTile.image.texture.filters = [color]; - } - } - }; - return TiledRendering; - }()); - es.TiledRendering = TiledRendering; -})(es || (es = {})); -var es; -(function (es) { - var TmxTileset = (function (_super) { - __extends(TmxTileset, _super); - function TmxTileset() { - return _super !== null && _super.apply(this, arguments) || this; - } - TmxTileset.prototype.update = function () { - this.tiles.forEach(function (value) { - value.updateAnimatedTiles(); - }); - }; - return TmxTileset; - }(es.TmxDocument)); - es.TmxTileset = TmxTileset; - var TmxTileOffset = (function () { - function TmxTileOffset() { - } - return TmxTileOffset; - }()); - es.TmxTileOffset = TmxTileOffset; - var TmxTerrain = (function () { - function TmxTerrain() { - } - return TmxTerrain; - }()); - es.TmxTerrain = TmxTerrain; -})(es || (es = {})); -var es; -(function (es) { - var TmxTilesetTile = (function () { - function TmxTilesetTile() { - } - Object.defineProperty(TmxTilesetTile.prototype, "currentAnimationFrameGid", { - get: function () { - return this.animationFrames[this._animationCurrentFrame].gid + this.tileset.firstGid; - }, - enumerable: true, - configurable: true - }); - TmxTilesetTile.prototype.processProperties = function () { - var value; - value = this.properties.get("engine.isDestructable"); - if (value) - this.isDestructable = Boolean(value); - value = this.properties.get("engine:isSlope"); - if (value) - this.isSlope = Boolean(value); - value = this.properties.get("engine:isOneWayPlatform"); - if (value) - this.isOneWayPlatform = Boolean(value); - value = this.properties.get("engine:slopeTopLeft"); - if (value) - this.slopeTopLeft = Number(value); - value = this.properties.get("engine:slopeTopRight"); - if (value) - this.slopeTopRight = Number(value); - }; - TmxTilesetTile.prototype.updateAnimatedTiles = function () { - if (this.animationFrames.length == 0) - return; - this._animationElapsedTime += es.Time.deltaTime; - if (this._animationElapsedTime > this.animationFrames[this._animationCurrentFrame].duration) { - this._animationCurrentFrame = es.MathHelper.incrementWithWrap(this._animationCurrentFrame, this.animationFrames.length); - this._animationElapsedTime = 0; - } - }; - return TmxTilesetTile; - }()); - es.TmxTilesetTile = TmxTilesetTile; - var TmxAnimationFrame = (function () { - function TmxAnimationFrame() { - } - return TmxAnimationFrame; - }()); - es.TmxAnimationFrame = TmxAnimationFrame; -})(es || (es = {})); -var es; -(function (es) { - var TmxUtils = (function () { - function TmxUtils() { - } - TmxUtils.decode = function (data, encoding, compression) { - compression = compression || "none"; - encoding = encoding || "none"; - switch (encoding) { - case "base64": - var decoded = es.Base64Utils.decodeBase64AsArray(data, 4); - return (compression === "none") ? decoded : es.Base64Utils.decompress(data, decoded, compression); - case "csv": - return es.Base64Utils.decodeCSV(data); - case "none": - var datas = []; - for (var i = 0; i < data.length; i++) { - datas[i] = +data[i].gid; - } - return datas; - default: - throw new Error("未定义的编码:" + encoding); - } - }; - TmxUtils.color16ToUnit = function ($color) { - if (!$color) - return 0xFFFFFF; - var colorStr = "0x" + $color.slice(1); - return parseInt(colorStr, 16); - }; - return TmxUtils; - }()); - es.TmxUtils = TmxUtils; -})(es || (es = {})); diff --git a/demo/libs/framework_tiled/framework_tiled.min.js b/demo/libs/framework_tiled/framework_tiled.min.js deleted file mode 100644 index 2ff5d590..00000000 --- a/demo/libs/framework_tiled/framework_tiled.min.js +++ /dev/null @@ -1 +0,0 @@ -window.es={},window.__extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}();var __awaiter=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))(function(n,a){function o(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){e.done?n(e.value):new i(function(t){t(e.value)}).then(o,s)}l((r=r.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var i,r,n,a,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,r&&(n=2&a[0]?r.return:a[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,a[1])).done)return n;switch(r=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(n=(n=o.trys).length>0&&n[n.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]=0&&(t.push(this.findBoundsRect(i,a,n,e)),i=-1)}i>=0&&(t.push(this.findBoundsRect(i,this.map.width,n,e)),i=-1)}return t},t.prototype.findBoundsRect=function(t,i,r,n){for(var a=-1,o=r+1;othis.tileHeight||this.maxTileWidth>this.tileWidth},enumerable:!0,configurable:!0}),i.prototype.getTilesetForTileGid=function(e){if(0==e)return null;for(var t=this.tilesets.length-1;t>=0;t--)if(this.tilesets[t].firstGid<=e)return this.tilesets[t];console.error("tile gid"+e+"未在任何tileset中找到")},i.prototype.worldToTilePositionX=function(t,i){void 0===i&&(i=!0);var r=Math.floor(t/this.tileWidth);return i?e.MathHelper.clamp(r,0,this.width-1):r},i.prototype.worldToTilePositionY=function(t,i){void 0===i&&(i=!0);var r=Math.floor(t/this.tileHeight);return i?e.MathHelper.clamp(r,0,this.height-1):r},i.prototype.getLayer=function(e){return this.layers[e]},i.prototype.update=function(){this.tilesets.forEach(function(e){e.update()})},i.prototype.dispose=function(e){void 0===e&&(e=!0),this._isDisposed||(e&&(this.tilesets.forEach(function(e){e.image&&e.image.dispose()}),this.imageLayers.forEach(function(e){e.image&&e.image.dispose()})),this._isDisposed=!0)},i}(e.TmxDocument);e.TmxMap=t,function(e){e[e.unknown=0]="unknown",e[e.orthogonal=1]="orthogonal",e[e.isometric=2]="isometric",e[e.staggered=3]="staggered",e[e.hexagonal=4]="hexagonal"}(e.OrientationType||(e.OrientationType={})),function(e){e[e.x=0]="x",e[e.y=1]="y"}(e.StaggerAxisType||(e.StaggerAxisType={})),function(e){e[e.odd=0]="odd",e[e.even=1]="even"}(e.StaggerIndexType||(e.StaggerIndexType={})),function(e){e[e.rightDown=0]="rightDown",e[e.rightUp=1]="rightUp",e[e.leftDown=2]="leftDown",e[e.leftUp=3]="leftUp"}(e.RenderOrderType||(e.RenderOrderType={}))}(es||(es={})),function(e){var t=function(){return function(){}}();e.TmxObjectGroup=t;var i=function(){return function(){this.shape=new egret.Shape,this.textField=new egret.TextField}}();e.TmxObject=i;var r=function(){return function(){}}();e.TmxText=r;var n=function(){return function(){}}();e.TmxAlignment=n,function(e){e[e.basic=0]="basic",e[e.point=1]="point",e[e.tile=2]="tile",e[e.ellipse=3]="ellipse",e[e.polygon=4]="polygon",e[e.polyline=5]="polyline",e[e.text=6]="text"}(e.TmxObjectType||(e.TmxObjectType={})),function(e){e[e.unkownOrder=-1]="unkownOrder",e[e.TopDown=0]="TopDown",e[e.IndexOrder=1]="IndexOrder"}(e.DrawOrderType||(e.DrawOrderType={})),function(e){e[e.left=0]="left",e[e.center=1]="center",e[e.right=2]="right",e[e.justify=3]="justify"}(e.TmxHorizontalAlignment||(e.TmxHorizontalAlignment={})),function(e){e[e.top=0]="top",e[e.center=1]="center",e[e.bottom=2]="bottom"}(e.TmxVerticalAlignment||(e.TmxVerticalAlignment={}))}(es||(es={})),function(e){var t=function(){function t(){}return t.loadTmxMap=function(e,t){var i=RES.getRes(t);return this.loadTmxMapData(e,i,RES.getResourceInfo(t))},t.loadTmxMapData=function(t,i,r){return __awaiter(this,void 0,void 0,function(){var n,a,o,s;return __generator(this,function(l){switch(l.label){case 0:t.version=i.version,t.tiledVersion=i.tiledversion,t.width=i.width,t.height=i.height,t.tileWidth=i.tilewidth,t.tileHeight=i.tileheight,t.hexSideLength=i.hexsidelength,t.orientation=this.parseOrientationType(i.orientation),t.staggerAxis=this.parseStaggerAxisType(i.staggeraxis),t.staggerIndex=this.parseStaggerIndexType(i.staggerindex),t.renderOrder=this.parseRenderOrderType(i.renderorder),t.nextObjectID=i.nextobjectid,t.backgroundColor=e.TmxUtils.color16ToUnit(i.color),t.properties=this.parsePropertyDict(i.properties),t.maxTileWidth=t.tileWidth,t.maxTileHeight=t.tileHeight,t.tmxDirectory=r.root+r.url.replace(".","_").replace(r.name,""),t.tilesets=[],n=0,a=i.tilesets,l.label=1;case 1:return ne.map.maxTileWidth&&(e.map.maxTileWidth=t.image.width),t.image.height>e.map.maxTileHeight&&(e.map.maxTileHeight=t.image.height))}),e.tileRegions.forEach(function(t){var i=t.width,r=t.height;i>e.map.maxTileWidth&&(e.map.maxTileWidth=i),i>e.map.maxTileHeight&&(e.map.maxTileHeight=r)})},t.parseOrientationType=function(t){return"unknown"==t?e.OrientationType.unknown:"orthogonal"==t?e.OrientationType.orthogonal:"isometric"==t?e.OrientationType.isometric:"staggered"==t?e.OrientationType.staggered:"hexagonal"==t?e.OrientationType.hexagonal:e.OrientationType.unknown},t.parseStaggerAxisType=function(t){return"y"==t?e.StaggerAxisType.y:e.StaggerAxisType.x},t.parseStaggerIndexType=function(t){return"even"==t?e.StaggerIndexType.even:e.StaggerIndexType.odd},t.parseRenderOrderType=function(t){return"right-up"==t?e.RenderOrderType.rightUp:"left-down"==t?e.RenderOrderType.leftDown:"left-up"==t?e.RenderOrderType.leftUp:e.RenderOrderType.rightDown},t.parsePropertyDict=function(t){if(!t)return null;for(var i=new Map,r=0,n=t;r=t.columns));x+=t.tileWidth+t.spacing);else t.tiles.forEach(function(i,r){t.tileRegions.set(r,new e.Rectangle(0,0,i.image.width,i.image.height))});return[2,t]}})})},t.loadTmxTilesetTile=function(t,i,r,n,a){return __awaiter(this,void 0,void 0,function(){var o,s,l,h,p,c,u,d,g,m,f,x,y;return __generator(this,function(T){switch(T.label){case 0:if(t.tileset=i,t.id=r.id,o=r.terrain)for(t.terrainEdges=new Array(4),s=0,l=0,h=o;l0){s.shape.x=l.x,s.shape.y=l.y,i.addChild(s.shape),s.shape.graphics.clear(),s.shape.graphics.lineStyle(1,10526884);for(c=0;c0&&(p=c.currentAnimationFrameGid);var u=i.tileset.tileRegions.get(p),d=Math.floor(i.x)*o,g=Math.floor(i.y)*s;i.horizontalFlip&&i.verticalFlip?(d+=s+(u.height*a.y-s),g-=u.width*a.x-o):i.horizontalFlip?d+=o+(u.height*a.y-s):i.verticalFlip?g+=o-u.width*a.x:g+=s-u.height*a.y;var m=new e.Vector2(d,g).add(n);if(i.tileset.image){if(r){var f=i.tileset.image.bitmap.getTexture(""+p);f||(f=i.tileset.image.bitmap.createTexture(""+p,u.x,u.y,u.width,u.height)),i.tileset.image.texture=new t(f),r.addChild(i.tileset.image.texture),i.tileset.image.texture.x!=m.x&&(i.tileset.image.texture.x=m.x),i.tileset.image.texture.y!=m.y&&(i.tileset.image.texture.y=m.y),i.verticalFlip&&i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=-1):i.verticalFlip?(i.tileset.image.texture.scaleX=a.x,i.tileset.image.texture.scaleY=-1):i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=a.y):(i.tileset.image.texture.scaleX=a.x,i.tileset.image.texture.scaleY=a.y),0!=i.tileset.image.texture.rotation&&(i.tileset.image.texture.rotation=0),0!=i.tileset.image.texture.anchorOffsetX&&(i.tileset.image.texture.anchorOffsetX=0),0!=i.tileset.image.texture.anchorOffsetY&&(i.tileset.image.texture.anchorOffsetY=0)}}else c.image.texture&&(c.image.bitmap.getTexture(p.toString())||(c.image.texture=new t(c.image.bitmap.createTexture(p.toString(),u.x,u.y,u.width,u.height)),r.addChild(c.image.texture)),c.image.texture.x=m.x,c.image.texture.y=m.y,c.image.texture.scaleX=a.x,c.image.texture.scaleY=a.y,c.image.texture.rotation=0,c.image.texture.anchorOffsetX=0,c.image.texture.anchorOffsetY=0,c.image.texture.filters=[l])},i}();e.TiledRendering=i}(es||(es={})),function(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.update=function(){this.tiles.forEach(function(e){e.updateAnimatedTiles()})},t}(e.TmxDocument);e.TmxTileset=t;var i=function(){return function(){}}();e.TmxTileOffset=i;var r=function(){return function(){}}();e.TmxTerrain=r}(es||(es={})),function(e){var t=function(){function t(){}return Object.defineProperty(t.prototype,"currentAnimationFrameGid",{get:function(){return this.animationFrames[this._animationCurrentFrame].gid+this.tileset.firstGid},enumerable:!0,configurable:!0}),t.prototype.processProperties=function(){var e;(e=this.properties.get("engine.isDestructable"))&&(this.isDestructable=Boolean(e)),(e=this.properties.get("engine:isSlope"))&&(this.isSlope=Boolean(e)),(e=this.properties.get("engine:isOneWayPlatform"))&&(this.isOneWayPlatform=Boolean(e)),(e=this.properties.get("engine:slopeTopLeft"))&&(this.slopeTopLeft=Number(e)),(e=this.properties.get("engine:slopeTopRight"))&&(this.slopeTopRight=Number(e))},t.prototype.updateAnimatedTiles=function(){0!=this.animationFrames.length&&(this._animationElapsedTime+=e.Time.deltaTime,this._animationElapsedTime>this.animationFrames[this._animationCurrentFrame].duration&&(this._animationCurrentFrame=e.MathHelper.incrementWithWrap(this._animationCurrentFrame,this.animationFrames.length),this._animationElapsedTime=0))},t}();e.TmxTilesetTile=t;var i=function(){return function(){}}();e.TmxAnimationFrame=i}(es||(es={})),function(e){var t=function(){function t(){}return t.decode=function(t,i,r){switch(r=r||"none",i=i||"none"){case"base64":var n=e.Base64Utils.decodeBase64AsArray(t,4);return"none"===r?n:e.Base64Utils.decompress(t,n,r);case"csv":return e.Base64Utils.decodeCSV(t);case"none":for(var a=[],o=0;o - * Before calling this method requires the application of any resource load, we recommend starting at the application entry class (Main) The first call processing. This method is only responsible for acquiring version information, is not responsible for downloaded resources. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取版本信息数据。
- * 这个方法的调用需要在应用程序进行任何资源加载之前,建议在应用程序的入口类(Main)的开始最先进行调用处理。此方法只负责获取版本信息,不负责资源的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - init(): Promise; - /** - * Get the actual URL of the resource file.
- * Because this method needs to be called to control the actual version of the URL have the original resource files were changed, so would like to get the specified resource file the actual URL.
- * In the development and debugging phase, this method will directly return value passed. - * @param url Url used in the game - * @returns Actual loaded url - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取资源文件实际的URL地址。
- * 由于版本控制实际已经对原来的资源文件的URL进行了改变,因此想获取指定资源文件实际的URL时需要调用此方法。
- * 在开发调试阶段,这个方法会直接返回传入的参数值。 - * @param url 游戏中使用的url - * @returns 实际加载的url - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getVirtualUrl(url: string): string; - } - /** - * Manage version control class - * @version Egret 2.4 - * @platform Web,Native - * @event egret.Event.COMPLETE Version control loading is complete when thrown - * @event egret.IOErrorEvent.IO_ERROR Version control failed to load when thrown - * @includeExample extension/version/VersionControl.ts - * @language en_US - */ - /** - * 管理版本控制的类 - * @version Egret 2.4 - * @platform Web,Native - * @event egret.Event.COMPLETE 版本控制加载完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 版本控制加载失败时抛出 - * @includeExample extension/version/VersionControl.ts - * @language zh_CN - */ - interface VersionController extends IVersionController { - } - /** - * @version Egret 2.4 - * @platform Web,Native - */ - let VersionController: { - /** - * Constructor initialization - * @language en_US - */ - /** - * 初始化构造函数 - * @language zh_CN - */ - new (): VersionController; - }; -} -declare type ResourceRootSelector = () => T; -declare type ResourceNameSelector = (file: string) => string; -declare type ResourceMergerSelector = (file: string) => { - path: string; - alias: string; -}; -declare module RES { - /** - * Get resource information through file path - * @param path file path - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 通过文件路径获取资源信息 - * @param path 文件路径 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResourceInfo(path: string): File | null; - /** - * @private - */ - interface ResourceInfo { - url: string; - type: string; - root: string; - crc32?: string; - size?: number; - extra?: 1 | undefined; - name: string; - soundType?: string; - scale9grid?: string; - groupNames?: string[]; - promise?: Promise; - } - /** - * @private - */ - interface Data { - resourceRoot: string; - mergeSelector: ResourceMergerSelector | null; - fileSystem: FileSystem; - groups: { - [groupName: string]: string[]; - }; - alias: { - [aliasName: string]: string; - }; - loadGroup: string[]; - } - /** - * @class RES.ResourceConfig - * @classdesc - * @private - */ - class ResourceConfig { - config: Data; - constructor(); - init(): Promise; - /** - * 根据组名获取组加载项列表 - * @method RES.ResourceConfig#getGroupByName - * @param name {string} 组名 - * @returns {Array} - */ - getGroupByName(name: string): ResourceInfo[]; - __temp__get__type__via__url(url_or_alias: string): string; - getResourceWithSubkey(key: string): { - r: ResourceInfo; - key: string; - subkey: string; - } | null; - getKeyByAlias(aliasName: string): string; - getResource(path_or_alias: string): ResourceInfo | null; - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或sbuKeys属性的一项或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * 添加一个二级键名到配置列表。 - * @method RES.ResourceConfig#addSubkey - * @param subkey {string} 要添加的二级键名 - * @param name {string} 二级键名所属的资源name属性 - */ - addSubkey(subkey: string, name: string): void; - addAlias(alias: any, key: any): void; - addResourceData(data: { - name: string; - type: string; - url: string; - root?: string; - extra?: 1 | undefined; - }): void; - removeResourceData(data: { - name: string; - type?: string; - url: string; - root?: string; - extra?: 1 | undefined; - }): void; - } -} -declare module RES { - /** - * @class RES.ResourceLoader - * @classdesc - * @private - */ - class ResourceLoader { - /** - * 当前组加载的项总个数,key为groupName - */ - private groupTotalDic; - /** - * 已经加载的项个数,key为groupName - */ - private numLoadedDic; - /** - * 加载失败的组,key为groupName - */ - private groupErrorDic; - private retryTimesDic; - maxRetryTimes: number; - private reporterDic; - private dispatcherDic; - private failedList; - private loadItemErrorDic; - private errorDic; - /** - * 资源优先级队列,key为资源,value为优先级 - */ - private itemListPriorityDic; - /** - * 资源是否在加载 - */ - private itemLoadDic; - private promiseHash; - /** - * 延迟加载队列,getResByUrl ,getResAsync等方法存储队列 - */ - private lazyLoadList; - pushResItem(resInfo: ResourceInfo): Promise; - /** - * 加载队列,存储组的队列 - */ - pushResGroup(list: ResourceInfo[], groupName: string, priority: number, reporter?: PromiseTaskReporter): Promise; - /** - * 更新组的优先级顺序 - * @param list 存储数据的队列 - * @param priority 优先级 - */ - private updatelistPriority(list, priority); - /** - * 搜索单项资源的优先级 - * @param item 单项资源 - */ - private findPriorityInDic(item); - private loadingCount; - /** - * 最大线程数目 - */ - thread: number; - /** - * 加载下一项资源,线程控制 - */ - private loadNextResource(); - /** - * 加载单向资源 - */ - private loadSingleResource(); - /** - * 获取下一个待加载项 - */ - private getOneResourceInfoInGroup(); - /** - * 设置组的加载进度,同时返回当前组是否加载完成 - * @param groupName 组名 - * @param r 加载完成的资源 - */ - private setGroupProgress(groupName, r); - /** - * 加载组的最后一项,同时派发事件 - * @param groupName 组名 - * @param lastError 最后一项是否成功,此项为错误信息 - */ - private loadGroupEnd(groupName, lastError?); - /** - * 删除事件派发器,Promise的缓存,返回事件派发器 - * @param groupName 组名或是root+name - */ - private deleteDispatcher(groupName); - /** - * 加载资源 - * @param r 资源信息 - * @param p 加载处理器 - */ - private loadResource(r, p?); - /** - * 释放资源 - * @param r 资源信息 - */ - unloadResource(r: ResourceInfo): boolean; - } -} -declare module RES { -} -declare module RES { - type GetResAsyncCallback = (value?: any, key?: string) => any; - /** - * Convert the file name of the resource to the Key value used in the project. - * @param url Resource Name. - * @returns The key value used in the project - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 将资源的文件名称转换为项目中所使用的Key值。 - * 在加载合并图集的时候使用,例如图集加载A_json,需要加载对应A_png,这里就是转换的机制 - * 一般项目中无需更改,只有没有使用默认的key和文件对应的需要修改 - * @param url 资源名称。 - * @returns 项目中所用的key值 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function nameSelector(url: any): string; - /** - * Get the read type of the file. - * When using getResByUrl does not specify the type of the read file, it will find the corresponding type according to this method. - * File types not found are loaded by default in binary format - * @param path file path. - * @returns Processor type used to read the file - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文件的读取类型 - * 在使用getResByUrl没有指定读取文件的类型,会根据这个方法寻找对应的类型 - * 没有查找到的文件类型以二进制格式默认加载 - * @param path 文件路径 - * @returns 读取文件所用的Processor类型 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function typeSelector(path: string): string; - /** - * Conduct mapping injection with class definition as the value, Deprecated. - * @deprecated - * @see RES.processor.map - * @language en_US - */ - /** - * 以类定义为值进行映射注入,已废弃。 - * @deprecated - * @see RES.processor.map - * @language zh_CN - */ - function registerAnalyzer(type: string, analyzerClass: any): void; - /** - * Set whether it is compatible mode - * When the value is true, the assetsManager will output the design of Res. When it is false, all the loaded resources will be returned as promises. - * The default is false, run in strict assetsManager mode - * @version Egret 5.2.9 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否为兼容模式 - * 当值为true时,assetsManager会以Res的设计输出,当为false时候,所有的加载资源都会以promise的方式返回 - * 默认是false,以严格assetsManager方式运行 - * @version Egret 5.2.9 - * @platform Web,Native - * @language zh_CN - */ - function setIsCompatible(value: boolean): void; - /** - * Load configuration file and parse. - * @param url The url address of the resource config - * @param resourceRoot The root address of the resource config - * @returns Promise - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载配置文件并解析。 - * @param url 资源配置的url地址 - * @param resourceRoot 资源配置的根地址 - * @returns Promise - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function loadConfig(url: string, resourceRoot: string): Promise; - /** - * Load a set of resources according to the group name. - * @param name Group name to load the resource group. - * @param priority Load priority can be negative, the default value is 0. - *
A low priority group must wait for the high priority group to complete the end of the load to start, and the same priority group will be loaded at the same time. - * @param reporter Resource group loading progress prompt - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名加载一组资源。 - * @param name 要加载资源组的组名。 - * @param priority 加载优先级,可以为负数,默认值为 0。 - *
低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。 - * @param reporter 资源组的加载进度提示 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise; - /** - * Check whether a resource group has been loaded. - * @param name Group name。 - * @returns Is loading or not. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 检查某个资源组是否已经加载完成。 - * @param name 组名。 - * @returns 是否正在加载。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function isGroupLoaded(name: string): boolean; - /** - * A list of groups of loading is obtained according to the group name. - * @param name Group name. - * @returns The resource item array of group. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名获取组加载项列表。 - * @param name 组名。 - * @returns 加载项列表。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getGroupByName(name: string): Array; - /** - * Create a custom load resource group, note that this method is valid only after the resource configuration file is loaded. - *
You can monitor the ResourceEvent.CONFIG_COMPLETE event to verify that the configuration is complete. - * @param name Group name to create the load resource group. - * @param keys To be included in the list of key keys, the corresponding configuration file in the name or sbuKeys property one or a resource group name. - * @param override Is the default false for the same name resource group already exists. - * @returns Create success or fail. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - *
可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。 - * @param name 要创建的加载资源组的组名。 - * @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。 - * @param override 是否覆盖已经存在的同名资源组,默认 false。 - * @returns 是否创建成功。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * Check whether the configuration file contains the specified resources. - * @param key A sbuKeys attribute or name property in a configuration file. - * @returns Whether you have the specified resource - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 检查配置文件里是否含有指定的资源。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @returns 是否拥有指定资源 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function hasRes(key: string): boolean; - /** - * The synchronization method for obtaining the cache has been loaded with the success of the resource. - *
The type of resource and the corresponding return value types are as follows: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript primary object - *
RES.ResourceItem.TYPE_IMAGE : img Html Object,or egret.BitmapData interface。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. If the incoming parameter is the name of the entire SpriteSheet is returned is {image1: Texture, "image2": Texture}. - *
2. If the incoming is "sheet.image1", the return is a single resource. - *
3. If the incoming is the name of the "image1" single resource, the return is a single resource. - * But if there are two SpriteSheet in a single picture of the same name, the return of the image after the load. - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html Object - *
RES.ResourceItem.TYPE_TEXT : string - * @param key A subKeys attribute or name property in a configuration file. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 同步方式获取缓存的已经加载成功的资源。 - *
资源类型和对应的返回值类型关系如下: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript 原生对象 - *
RES.ResourceItem.TYPE_IMAGE : img Html 对象,或者 egret.BitmapData 接口。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. 如果传入的参数是整个 SpriteSheet 的名称返回的是 {"image1":Texture,"image2":Texture} 这样的格式。 - *
2. 如果传入的是 "sheet.image1",返回的是单个资源。 - *
3. 如果传入的是 "image1" 单个资源的名称,返回的是单个资源。但是如果有两张 SpriteSheet 中有单个图片资源名称相同,返回的是后加载的那个图片资源。 - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html 对象 - *
RES.ResourceItem.TYPE_TEXT : string - * @param key 对应配置文件里的 name 属性或 subKeys 属性的一项。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getRes(key: string): any; - /** - * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way. - * @param key A sbuKeys attribute or name property in a configuration file. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResAsync(key: string): Promise; - /** - * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way. - * @param key A sbuKeys attribute or name property in a configuration file. - * @param compFunc Call back function. Example:compFunc(data,key):void. - * @param thisObject This pointer of call back function. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @param compFunc 回调函数。示例:compFunc(data,key):void。 - * @param thisObject 回调函数的 this 引用。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): Promise | void; - /** - * Access to external resources through the full URL. - * @param url The external path to load the file. - * @param compFunc Call back function. Example:compFunc(data,url):void。 - * @param thisObject This pointer of call back function. - * @param type File type (optional). Use the static constants defined in the ResourceItem class. If you do not set the file name extension. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 通过完整URL方式获取外部资源。 - * @param url 要加载文件的外部路径。 - * @param compFunc 回调函数。示例:compFunc(data,url):void。 - * @param thisObject 回调函数的 this 引用。 - * @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResByUrl(url: string, compFunc?: Function, thisObject?: any, type?: string): Promise; - /** - * Destroy a single resource file or a set of resources to the cache data, to return whether to delete success. - * @param name Name attribute or resource group name of the load item in the configuration file. - * @param force Destruction of a resource group when the other resources groups have the same resource situation whether the resources will be deleted, the default value true. - * @returns Are successful destruction. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @param name 配置文件中加载项的name属性或资源组名。 - * @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。 - * @see #setMaxRetryTimes - * @returns 是否销毁成功。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function destroyRes(name: string, force?: boolean): boolean; - /** - * Sets the maximum number of concurrent load threads, the default value is 4. - * @param thread The number of concurrent loads to be set. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 设置最大并发加载线程数量,默认值是 4。 - * @param thread 要设置的并发加载数。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function setMaxLoadingThread(thread: number): void; - /** - * Sets the number of retry times when the resource failed to load, and the default value is 3. - * @param retry To set the retry count. - * @includeExample extension/resource/Resource.ts - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 设置资源加载失败时的重试次数,默认值是 3。 - * @param retry 要设置的重试次数。 - * @includeExample extension/resource/Resource.ts - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function setMaxRetryTimes(retry: number): void; - /** - * Add event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listener functions for handling events. This function must accept the Event object as its only parameter, and can't return any results, - * As shown in the following example: function (evt:Event):void can have any name. - * @param thisObject The this object that is bound to a function. - * @param useCapture Determine the listener is running on the capture or running on the target and the bubbling phase. Set useCapture to true, - * then the listener in the capture phase processing events, but not in the target or the bubbling phase processing events. - * If useCapture is false, then the listener only in the target or the bubbling phase processing events. - * To listen for events in all three stages, please call addEventListener two times: once the useCapture is set to true, once the useCapture is set to false. - * @param priority Event listener priority. Priority is specified by a 32 - bit integer with a symbol. The higher the number, the higher the priority. - * All listeners with a priority for n will be processed before the -1 n listener. - * If two or more listeners share the same priority, they are processed in accordance with the order of their added. The default priority is 0. - * @see RES.ResourceEvent - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 添加事件侦听器,参考 ResourceEvent 定义的常量。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的 this 对象。 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于目标和冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在目标或冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在目标或冒泡阶段处理事件。 - * 要在所有三个阶段都侦听事件,请调用 addEventListener 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的 32 位整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see RES.ResourceEvent - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function addEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Remove event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listening function。 - * @param thisObject The this object that is bound to a function. - * @param useCapture Is used to capture, and this property is only valid in the display list. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 移除事件侦听器,参考ResourceEvent定义的常量。 - * @param type 事件名。 - * @param listener 侦听函数。 - * @param thisObject 侦听函数绑定的this对象。 - * @param useCapture 是否使用捕获,这个属性只在显示列表中生效。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function removeEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean): void; - /** - * Adding a custom resource configuration. - * @param data To add configuration. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 自定义添加一项资源配置。 - * @param data 要添加的配置。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function $addResourceData(data: { - name: string; - type: string; - url: string; - }): void; - /** - * Returns the VersionController - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获得版本控制器. - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getVersionController(): VersionController; - /** - * Register the VersionController - * @param vcs The VersionController to register. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 注册版本控制器,通过RES模块加载资源时会从版本控制器获取真实url - * @param vcs 注入的版本控制器。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function registerVersionController(vcs: VersionController): void; - /** - * Convert the address of the loaded resource (via version controller conversion) - * @param url path to the original resource - * @returns converted address - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 转换加载资源的地址(经过版本控制器的转换) - * @param url 原始资源的路径 - * @returns 转换后的地址 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getVirtualUrl(url: any): any; - /** - * @private - */ - class Resource extends egret.EventDispatcher { - vcs: VersionController; - isVcsInit: boolean; - constructor(); - registerVersionController(vcs: VersionController): void; - /** - * 开始加载配置 - * @method RES.loadConfig - */ - loadConfig(): Promise; - /** - * @private - * 版本控制器加载后的加载配置 - */ - private normalLoadConfig; - /** - * 检查某个资源组是否已经加载完成 - * @method RES.isGroupLoaded - * @param name {string} - */ - isGroupLoaded(name: string): boolean; - /** - * 根据组名获取组加载项列表 - * @method RES.getGroupByName - * @param name {string} - */ - getGroupByName(name: string): Array; - /** - * 根据组名加载一组资源 - * @method RES.loadGroup - * @param name {string} - * @param priority {number} - */ - loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise; - private _loadGroup(name, priority?, reporter?); - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * 检查配置文件里是否含有指定的资源 - * @method RES.hasRes - * @param key {string} 对应配置文件里的name属性或subKeys属性的一项。 - * @returns {boolean} - */ - hasRes(key: string): boolean; - /** - * 通过key同步获取资源 - * @method RES.getRes - * @param key {string} - * @returns {any} - */ - getRes(resKey: string): any; - /** - * 通过key异步获取资源 - * @method RES.getResAsync - * @param key {string} - * @param compFunc {Function} 回调函数。示例:compFunc(data,url):void。 - * @param thisObject {any} - */ - getResAsync(key: string): Promise; - getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): Promise; - /** - * 通过url获取资源 - * @method RES.getResByUrl - * @param url {string} - * @param compFunc {Function} - * @param thisObject {any} - * @param type {string} - */ - getResByUrl(url: string, compFunc?: Function, thisObject?: any, type?: string): Promise; - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @method RES.destroyRes - * @param name {string} 配置文件中加载项的name属性或资源组名 - * @param force {boolean} 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值true - * @returns {boolean} - */ - destroyRes(name: string, force?: boolean): boolean; - /** - * 设置最大并发加载线程数量,默认值是4. - * @method RES.setMaxLoadingThread - * @param thread {number} 要设置的并发加载数。 - */ - setMaxLoadingThread(thread: number): void; - /** - * 设置资源加载失败时的重试次数。 - * @param retry 要设置的重试次数。 - */ - setMaxRetryTimes(retry: number): void; - addResourceData(data: { - name: string; - type: string; - url: string; - }): void; - } -} -declare namespace RES { - /** - * Print the memory occupied by the picture. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 对文件路径的一些操作,针对的是 C:/A/B/C/D/example.ts这种格式 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - namespace path { - /** - * Format the file path,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" - * @param filename Incoming file path - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 格式化文件路径,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" - * @param filename 传入的文件路径 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function normalize(filename: string): string; - /** - * Get the file name according to the file path, "C:/A/B/example.ts"=>"example.ts" - * @param filename Incoming file path - * @return File name - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据文件路径得到文件名字,"C:/A/B/example.ts"=>"example.ts" - * @param filename 传入的文件路径 - * @return 文件的名字 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function basename(filename: string): string; - /** - * The path to the folder where the file is located,"C:/A/B/example.ts"=>"C:/A/B" - * @param filename Incoming file path - * @return The address of the folder where the file is located - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 文件所在文件夹路径,"C:/A/B/example.ts"=>"C:/A/B" - * @param filename 传入的文件路径 - * @return 文件所在文件夹的地址 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function dirname(path: string): string; - } -} -declare namespace RES { - /** - * @private - */ - class NativeVersionController implements IVersionController { - private versionInfo; - init(): Promise; - getVirtualUrl(url: string): string; - private getLocalData(filePath); - } -} -declare module RES.processor { - interface Processor { - /** - * Start loading a single resource - * @param host Load the processor, you can use the processor to load resources, directly use http to get the resources back - * @param resource Resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 开始加载单项资源 - * @param host 加载处理器,可以不使用这个处理器加载资源,直接用http获取资源返回即可 - * @param resource 资源的信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - onLoadStart(host: ProcessHost, resource: ResourceInfo): Promise; - /** - * Remove a single resource, usually call host.unload (resource); - * @param host Load the processor - * @param resource Resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 移除单项资源,一般调用host.unload(resource); - * @param host 加载处理器 - * @param resource 资源的信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - onRemoveStart(host: ProcessHost, resource: ResourceInfo): void; - /** - * Get the submap of the merged atlas - * @param host Load the processor - * @param resource Resource information - * @param key The key value of the resource - * @param subkey Collection of subset names - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获取合并图集的子图 - * @param host 加载处理器 - * @param resource 资源的信息 - * @param key 资源的key值 - * @param subkey 子集名称的集合 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - getData?(host: ProcessHost, resource: ResourceInfo, key: string, subkey: string): any; - } - /** - * Register the processor that loads the resource - * @param type Load resource type - * @param processor Loaded processor, an instance that implements the Processor interface - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 注册加载资源的处理器 - * @param type 加载资源类型 - * @param processor 加载的处理器,一个实现Processor接口的实例 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function map(type: string, processor: Processor): void; - /** - * @private - * @param url - * @param file - */ - function getRelativePath(url: string, file: string): string; - var ImageProcessor: Processor; - const KTXTextureProcessor: RES.processor.Processor; - /** - * - */ - function makeEtc1SeperatedAlphaResourceInfo(resource: ResourceInfo): ResourceInfo; - /** - * - */ - const ETC1KTXProcessor: Processor; - var BinaryProcessor: Processor; - var TextProcessor: Processor; - var JsonProcessor: Processor; - var SoundProcessor: Processor; -} -declare module RES { - /** - * The events of resource loading. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源加载事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - class ResourceEvent extends egret.Event { - /** - * Failure event for a load item. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 一个加载项加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static ITEM_LOAD_ERROR: string; - /** - * Configure file to load and parse the completion event. Note: if a configuration file is loaded, it will not be thrown out, and if you want to handle the configuration loading failure, monitor the CONFIG_LOAD_ERROR event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static CONFIG_COMPLETE: string; - /** - * Configuration file failed to load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static CONFIG_LOAD_ERROR: string; - /** - * Delay load group resource loading progress event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载进度事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_PROGRESS: string; - /** - * Delay load group resource to complete event. Note: if you have a resource item loading failure, the event will not be thrown, if you want to handle the group load failure, please listen to the GROUP_LOAD_ERROR event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_COMPLETE: string; - /** - * Delayed load group resource failed event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_LOAD_ERROR: string; - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 5.2 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 5.2 - * @platform Web,Native - * @private - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * File number that has been loaded. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 已经加载的文件数。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - itemsLoaded: number; - /** - * Total file number to load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的总文件数。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - itemsTotal: number; - /** - * Resource group name. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源组名。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - groupName: string; - /** - * An item of information that is finished by the end of a load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 一次加载项加载结束的项信息对象。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - resItem: ResourceItem; - } -} -declare module RES { - /** - * Resource term. One of the resources arrays in resource.json. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源项。对应 resource.json 中 resources 数组中的一项。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - namespace ResourceItem { - /** - * XML file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * XML 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_XML: string; - /** - * Picture file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 图片文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_IMAGE: string; - /** - * Binary file. - * @version Egret 5.2 - * @platform Web - * @language en_US - */ - /** - * 二进制文件。 - * @version Egret 5.2 - * @platform Web - * @language zh_CN - */ - const TYPE_BIN: string; - /** - * Text file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 文本文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_TEXT: string; - /** - * JSON file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * JSON 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_JSON: string; - /** - * SpriteSheet file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * SpriteSheet 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_SHEET: string; - /** - * BitmapTextSpriteSheet file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapTextSpriteSheet 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_FONT: string; - /** - * Sound file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 声音文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_SOUND: string; - function convertToResItem(r: ResourceInfo): ResourceItem; - } - interface ResourceItem extends ResourceInfo { - /** - * Name of resource term. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载项名称。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * URL of resource term. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的文件地址。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - url: string; - /** - * Type of resource term. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载项文件类型。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - type: string; - /** - * The raw data object to be referenced. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的原始数据对象。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - data: ResourceInfo; - crc32?: string; - size?: number; - soundType?: string; - } -} -declare module RES { - /** - * assetsManager underlying storage resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * assetsManager底层存储资源信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - interface File { - url: string; - type: string; - name: string; - root: string; - } - /** - * @private - */ - interface FileSystem { - addFile(data: { - name: string; - type: string; - url: string; - root?: string; - extra?: 1 | undefined; - }): any; - getFile(filename: string): File | null; - profile(): void; - removeFile(filename: string): any; - } -} -declare module RES { - /** - * Print the memory occupied by the picture. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 打印图片所占内存 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function profile(): void; - /** - * @private - */ - interface ProcessHost { - state: { - [index: string]: number; - }; - resourceConfig: ResourceConfig; - load: (resource: ResourceInfo, processor?: string | processor.Processor) => Promise; - unload: (resource: ResourceInfo) => void; - save: (rexource: ResourceInfo, data: any) => void; - get: (resource: ResourceInfo) => any; - remove: (resource: ResourceInfo) => void; - } - /** - * @private - */ - class ResourceManagerError extends Error { - static errorMessage: { - 1001: string; - 1002: string; - 2001: string; - 2002: string; - 2003: string; - 2004: string; - 2005: string; - 2006: string; - }; - /** - * why instanceof e != ResourceManagerError ??? - * see link : https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work - */ - private __resource_manager_error__; - constructor(code: number, replacer?: Object, replacer2?: Object); - } -} -declare namespace RES { - /** - * Resource group loading progress prompt - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源组的加载进度提示 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - interface PromiseTaskReporter { - /** - * Progress callback, asynchronous execution, load number and order have nothing to do - * @param current The number of currently loaded - * @param total Total resources required in the current resource bundle - * @param resItem currently loading resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 进度回调,异步执行,加载数目和顺序无关 - * @param current 当前已经加载数目 - * @param total 当前资源包内需要资源总数 - * @param resItem 当前加载资源信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - onProgress?(current: number, total: number, resItem: ResourceInfo | undefined): void; - } -} diff --git a/demo/libs/modules/assetsmanager/assetsmanager.js b/demo/libs/modules/assetsmanager/assetsmanager.js deleted file mode 100644 index 8a02b53e..00000000 --- a/demo/libs/modules/assetsmanager/assetsmanager.js +++ /dev/null @@ -1,2992 +0,0 @@ -var __reflect = (this && this.__reflect) || function (p, c, t) { - p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; -}; -var __extends = this && this.__extends || function __extends(t, e) { - function r() { - this.constructor = t; -} -for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]); -r.prototype = e.prototype, t.prototype = new r(); -}; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { -})(RES || (RES = {})); -var RES; -(function (RES) { - /** - * @internal - */ - RES.resourceNameSelector = function (p) { return p; }; - /** - * Get resource information through file path - * @param path file path - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 通过文件路径获取资源信息 - * @param path 文件路径 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResourceInfo(path) { - var result = RES.config.config.fileSystem.getFile(path); - if (!result) { - path = RES.resourceNameSelector(path); - result = RES.config.config.fileSystem.getFile(path); - } - return result; - } - RES.getResourceInfo = getResourceInfo; - var configItem; - /** - * 注册config的相关配置 - * @internal - * @param url config的地址 - * @param root 根路径 - */ - function setConfigURL(url, root) { - var type; - if (url.indexOf(".json") >= 0) { - type = "legacyResourceConfig"; - } - else { - type = "resourceConfig"; - } - configItem = { type: type, root: root, url: url, name: url }; - } - RES.setConfigURL = setConfigURL; - /** - * @class RES.ResourceConfig - * @classdesc - * @private - */ - var ResourceConfig = (function () { - function ResourceConfig() { - } - ResourceConfig.prototype.init = function () { - if (!this.config) { - this.config = { - alias: {}, groups: {}, resourceRoot: configItem.root, - mergeSelector: null, - fileSystem: null, - loadGroup: [] - }; - } - return RES.queue.pushResItem(configItem).catch(function (e) { - if (!RES.isCompatible) { - if (!e.__resource_manager_error__) { - if (e.error) { - console.error(e.error.stack); - } - else { - console.error(e.stack); - } - e = new RES.ResourceManagerError(1002); - } - } - RES.host.remove(configItem); - return Promise.reject(e); - }); - }; - /** - * 根据组名获取组加载项列表 - * @method RES.ResourceConfig#getGroupByName - * @param name {string} 组名 - * @returns {Array} - */ - ResourceConfig.prototype.getGroupByName = function (name) { - var group = this.config.groups[name]; - var result = []; - if (!group) { - return result; - } - for (var _i = 0, group_1 = group; _i < group_1.length; _i++) { - var paramKey = group_1[_i]; - var tempResult = void 0; - tempResult = RES.config.getResourceWithSubkey(paramKey); - if (tempResult == null) { - continue; - } - var r = tempResult.r, key = tempResult.key; - if (r == null) { - /** 加载组里面的资源,可能不存在 */ - throw new RES.ResourceManagerError(2005, key); - continue; - } - if (result.indexOf(r) == -1) { - result.push(r); - } - } - return result; - }; - ResourceConfig.prototype.__temp__get__type__via__url = function (url_or_alias) { - var url = this.config.alias[url_or_alias]; - if (!url) { - url = url_or_alias; - } - if (RES.typeSelector) { - var type = RES.typeSelector(url); - if (!type) { - throw new RES.ResourceManagerError(2004, url); - } - return type; - } - else { - console.warn("RES.mapConfig 并未设置 typeSelector"); - return "unknown"; - } - }; - ResourceConfig.prototype.getResourceWithSubkey = function (key) { - key = this.getKeyByAlias(key); - var index = key.indexOf("#"); - var subkey = ""; - if (index >= 0) { - subkey = key.substr(index + 1); - key = key.substr(0, index); - } - var r = this.getResource(key); - if (!r) { - return null; - } - else { - return { - r: r, key: key, subkey: subkey - }; - } - }; - ResourceConfig.prototype.getKeyByAlias = function (aliasName) { - if (this.config.alias[aliasName]) { - return this.config.alias[aliasName]; - } - else { - return aliasName; - } - }; - ResourceConfig.prototype.getResource = function (path_or_alias) { - var path = this.config.alias[path_or_alias]; - if (!path) { - path = path_or_alias; - } - var r = getResourceInfo(path); - if (!r) { - return null; - } - else { - return r; - } - }; - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或sbuKeys属性的一项或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - ResourceConfig.prototype.createGroup = function (name, keys, override) { - if (override === void 0) { override = false; } - if ((!override && this.config.groups[name]) || !keys || keys.length == 0) { - return false; - } - var group = []; - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - if (this.config.groups[key]) { - var groupInfo = this.config.groups[key]; - group = group.concat(groupInfo); - } - else { - group.push(key); - } - } - this.config.groups[name] = group; - return true; - // var groupDic: any = this.groupDic; - // var group: Array = []; - // var length: number = keys.length; - // for (var i: number = 0; i < length; i++) { - // var key: string = keys[i]; - // var g: Array = groupDic[key]; - // if (g) { - // var len: number = g.length; - // for (var j: number = 0; j < len; j++) { - // var item: any = g[j]; - // if (group.indexOf(item) == -1) - // group.push(item); - // } - // } - // else { - // item = this.keyMap[key]; - // if (item) { - // if (group.indexOf(item) == -1) - // group.push(item); - // } - // else { - // egret.$warn(3200, key); - // } - // } - // } - // if (group.length == 0) - // return false; - // this.groupDic[name] = group; - // return true; - }; - /** - * 添加一个二级键名到配置列表。 - * @method RES.ResourceConfig#addSubkey - * @param subkey {string} 要添加的二级键名 - * @param name {string} 二级键名所属的资源name属性 - */ - ResourceConfig.prototype.addSubkey = function (subkey, name) { - this.addAlias(subkey, name + "#" + subkey); - }; - ResourceConfig.prototype.addAlias = function (alias, key) { - if (this.config.alias[key]) { - key = this.config.alias[key]; - } - this.config.alias[alias] = key; - }; - ResourceConfig.prototype.addResourceData = function (data) { - if (RES.hasRes(data.name)) { - return; - } - if (!data.type) { - data.type = this.__temp__get__type__via__url(data.url); - } - RES.config.config.fileSystem.addFile(data); - }; - ResourceConfig.prototype.removeResourceData = function (data) { - if (!RES.hasRes(data.name)) { - return; - } - RES.config.config.fileSystem.removeFile(data.url); - if (this.config.alias[data.name]) { - delete this.config.alias[data.name]; - } - }; - return ResourceConfig; - }()); - RES.ResourceConfig = ResourceConfig; - __reflect(ResourceConfig.prototype, "RES.ResourceConfig"); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * @class RES.ResourceLoader - * @classdesc - * @private - */ - var ResourceLoader = (function () { - function ResourceLoader() { - /** - * 当前组加载的项总个数,key为groupName - */ - this.groupTotalDic = {}; - /** - * 已经加载的项个数,key为groupName - */ - this.numLoadedDic = {}; - /** - * 加载失败的组,key为groupName - */ - this.groupErrorDic = {}; - this.retryTimesDic = {}; - this.maxRetryTimes = 3; - this.reporterDic = {}; - this.dispatcherDic = {}; - this.failedList = new Array(); - this.loadItemErrorDic = {}; - this.errorDic = {}; - /** - * 资源优先级队列,key为资源,value为优先级 - */ - this.itemListPriorityDic = {}; - /** - * 资源是否在加载 - */ - this.itemLoadDic = {}; - this.promiseHash = {}; - /** - * 延迟加载队列,getResByUrl ,getResAsync等方法存储队列 - */ - this.lazyLoadList = new Array(); - this.loadingCount = 0; - /** - * 最大线程数目 - */ - this.thread = 4; - } - ResourceLoader.prototype.pushResItem = function (resInfo) { - if (this.promiseHash[resInfo.root + resInfo.name]) { - return this.promiseHash[resInfo.root + resInfo.name]; - } - this.lazyLoadList.push(resInfo); - this.itemListPriorityDic[Number.NEGATIVE_INFINITY] = this.lazyLoadList; - this.updatelistPriority(this.lazyLoadList, Number.NEGATIVE_INFINITY); - var dispatcher = new egret.EventDispatcher(); - this.dispatcherDic[resInfo.root + resInfo.name] = dispatcher; - var promise = new Promise(function (resolve, reject) { - dispatcher.addEventListener("complete", function (e) { - resolve(e.data); - }, null); - dispatcher.addEventListener("error", function (e) { - reject(e.data); - }, null); - }); - this.promiseHash[resInfo.root + resInfo.name] = promise; - this.loadNextResource(); - return promise; - }; - /** - * 加载队列,存储组的队列 - */ - ResourceLoader.prototype.pushResGroup = function (list, groupName, priority, reporter) { - if (this.promiseHash[groupName]) { - return this.promiseHash[groupName]; - } - var total = list.length; - for (var i = 0; i < total; i++) { - var resInfo = list[i]; - if (!resInfo.groupNames) { - resInfo.groupNames = []; - } - resInfo.groupNames.push(groupName); - } - this.groupTotalDic[groupName] = list.length; - this.numLoadedDic[groupName] = 0; - this.updatelistPriority(list, priority); - this.reporterDic[groupName] = reporter; - var dispatcher = new egret.EventDispatcher(); - this.dispatcherDic[groupName] = dispatcher; - var promise = new Promise(function (resolve, reject) { - dispatcher.addEventListener("complete", resolve, null); - dispatcher.addEventListener("error", function (e) { - reject(e.data); - }, null); - }); - this.promiseHash[groupName] = promise; - this.loadNextResource(); - return promise; - }; - /** - * 更新组的优先级顺序 - * @param list 存储数据的队列 - * @param priority 优先级 - */ - ResourceLoader.prototype.updatelistPriority = function (list, priority) { - if (this.itemListPriorityDic[priority] == undefined) { - this.itemListPriorityDic[priority] = []; - } - for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { - var item = list_1[_i]; - if (this.itemLoadDic[item.root + item.name] == 1) { - continue; - } - var oldPriority = this.findPriorityInDic(item); - if (oldPriority == undefined) { - this.itemListPriorityDic[priority].push(item); - } - else { - if (oldPriority < priority) { - this.itemListPriorityDic[priority].push(item); - var index = this.itemListPriorityDic[oldPriority].indexOf(item); - this.itemListPriorityDic[oldPriority].splice(index, 1); - } - } - } - }; - /** - * 搜索单项资源的优先级 - * @param item 单项资源 - */ - ResourceLoader.prototype.findPriorityInDic = function (item) { - for (var priority in this.itemListPriorityDic) { - if (this.itemListPriorityDic[priority].indexOf(item) > -1) - return parseInt(priority); - } - return undefined; - }; - /** - * 加载下一项资源,线程控制 - */ - ResourceLoader.prototype.loadNextResource = function () { - while (this.loadingCount < this.thread) { - var isload = this.loadSingleResource(); - if (!isload) { - break; - } - } - }; - /** - * 加载单向资源 - */ - ResourceLoader.prototype.loadSingleResource = function () { - var _this = this; - var r = this.getOneResourceInfoInGroup(); - if (!r) - return false; - this.itemLoadDic[r.root + r.name] = 1; - this.loadingCount++; - this.loadResource(r) - .then(function (response) { - _this.loadingCount--; - delete _this.itemLoadDic[r.root + r.name]; - RES.host.save(r, response); - if (_this.promiseHash[r.root + r.name]) { - var dispatcher = _this.deleteDispatcher(r.root + r.name); - dispatcher.dispatchEventWith("complete", false, response); - } - var groupNames = r.groupNames; - if (groupNames) { - delete r.groupNames; - for (var _i = 0, groupNames_1 = groupNames; _i < groupNames_1.length; _i++) { - var groupName = groupNames_1[_i]; - if (_this.setGroupProgress(groupName, r)) { - _this.loadGroupEnd(groupName); - } - } - } - _this.loadNextResource(); - }).catch(function (error) { - if (!error) { - throw r.name + " load fail"; - } - if (!error.__resource_manager_error__) { - throw error; - } - delete _this.itemLoadDic[r.root + r.name]; - _this.loadingCount--; - delete RES.host.state[r.root + r.name]; - var times = _this.retryTimesDic[r.name] || 1; - if (times > _this.maxRetryTimes) { - delete _this.retryTimesDic[r.name]; - if (_this.promiseHash[r.root + r.name]) { - var dispatcher = _this.deleteDispatcher(r.root + r.name); - dispatcher.dispatchEventWith("error", false, { r: r, error: error }); - } - var groupNames = r.groupNames; - if (groupNames) { - delete r.groupNames; - for (var _i = 0, groupNames_2 = groupNames; _i < groupNames_2.length; _i++) { - var groupName = groupNames_2[_i]; - if (!_this.loadItemErrorDic[groupName]) { - _this.loadItemErrorDic[groupName] = []; - } - if (_this.loadItemErrorDic[groupName].indexOf(r) == -1) { - _this.loadItemErrorDic[groupName].push(r); - } - _this.groupErrorDic[groupName] = true; - if (_this.setGroupProgress(groupName, r)) { - _this.loadGroupEnd(groupName, error); - } - else { - _this.errorDic[groupName] = error; - } - } - } - _this.loadNextResource(); - } - else { - _this.retryTimesDic[r.name] = times + 1; - _this.failedList.push(r); - _this.loadNextResource(); - return; - } - }); - return true; - }; - /** - * 获取下一个待加载项 - */ - ResourceLoader.prototype.getOneResourceInfoInGroup = function () { - if (this.failedList.length > 0) - return this.failedList.shift(); - var maxPriority = Number.NEGATIVE_INFINITY; - for (var p in this.itemListPriorityDic) { - maxPriority = Math.max(maxPriority, p); - } - var list = this.itemListPriorityDic[maxPriority]; - if (!list) { - return undefined; - } - if (list.length == 0) { - delete this.itemListPriorityDic[maxPriority]; - return this.getOneResourceInfoInGroup(); - } - return list.shift(); - }; - /** - * 设置组的加载进度,同时返回当前组是否加载完成 - * @param groupName 组名 - * @param r 加载完成的资源 - */ - ResourceLoader.prototype.setGroupProgress = function (groupName, r) { - var reporter = this.reporterDic[groupName]; - this.numLoadedDic[groupName]++; - var current = this.numLoadedDic[groupName]; - var total = this.groupTotalDic[groupName]; - if (reporter && reporter.onProgress) { - reporter.onProgress(current, total, r); - } - return current == total; - }; - /** - * 加载组的最后一项,同时派发事件 - * @param groupName 组名 - * @param lastError 最后一项是否成功,此项为错误信息 - */ - ResourceLoader.prototype.loadGroupEnd = function (groupName, lastError) { - delete this.groupTotalDic[groupName]; - delete this.numLoadedDic[groupName]; - delete this.reporterDic[groupName]; - var dispatcher = this.deleteDispatcher(groupName); - if (!lastError) { - var groupError = this.groupErrorDic[groupName]; - delete this.groupErrorDic[groupName]; - if (groupError) { - var itemList = this.loadItemErrorDic[groupName]; - delete this.loadItemErrorDic[groupName]; - var error = this.errorDic[groupName]; - delete this.errorDic[groupName]; - dispatcher.dispatchEventWith("error", false, { itemList: itemList, error: error }); - } - else { - dispatcher.dispatchEventWith("complete"); - } - } - else { - delete this.groupErrorDic[groupName]; - var itemList = this.loadItemErrorDic[groupName]; - delete this.loadItemErrorDic[groupName]; - dispatcher.dispatchEventWith("error", false, { itemList: itemList, lastError: lastError }); - } - }; - /** - * 删除事件派发器,Promise的缓存,返回事件派发器 - * @param groupName 组名或是root+name - */ - ResourceLoader.prototype.deleteDispatcher = function (groupName) { - delete this.promiseHash[groupName]; - var dispatcher = this.dispatcherDic[groupName]; - delete this.dispatcherDic[groupName]; - return dispatcher; - }; - /** - * 加载资源 - * @param r 资源信息 - * @param p 加载处理器 - */ - ResourceLoader.prototype.loadResource = function (r, p) { - if (!p) { - if (RES.FEATURE_FLAG.FIX_DUPLICATE_LOAD == 1) { - var s = RES.host.state[r.root + r.name]; - if (s == 2) { - return Promise.resolve(RES.host.get(r)); - } - if (s == 1) { - return r.promise; - } - } - p = RES.processor.isSupport(r); - } - if (!p) { - throw new RES.ResourceManagerError(2001, r.name, r.type); - } - RES.host.state[r.root + r.name] = 1; - var promise = p.onLoadStart(RES.host, r); - r.promise = promise; - return promise; - }; - /** - * 释放资源 - * @param r 资源信息 - */ - ResourceLoader.prototype.unloadResource = function (r) { - var data = RES.host.get(r); - if (!data) { - console.warn("尝试释放不存在的资源:", r.name); - return false; - } - var p = RES.processor.isSupport(r); - if (p) { - p.onRemoveStart(RES.host, r); - RES.host.remove(r); - if (r.extra == 1) { - RES.config.removeResourceData(r); - } - return true; - } - else { - return true; - } - }; - return ResourceLoader; - }()); - RES.ResourceLoader = ResourceLoader; - __reflect(ResourceLoader.prototype, "RES.ResourceLoader"); -})(RES || (RES = {})); -var RES; -(function (RES) { - /** - * Decorator, determine if the parameter is null - * @internal - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 装饰器,判断参数是否为null - * @internal - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - RES.checkNull = function (target, propertyKey, descriptor) { - var method = descriptor.value; - descriptor.value = function () { - var arg = []; - for (var _i = 0; _i < arguments.length; _i++) { - arg[_i] = arguments[_i]; - } - if (!arg[0]) { - console.warn("\u65B9\u6CD5" + propertyKey + "\u7684\u53C2\u6570\u4E0D\u80FD\u4E3Anull"); - return null; - } - else { - return method.apply(this, arg); - } - }; - }; - /** - * 功能开关 - * LOADING_STATE:处理重复加载 - * @internal - */ - RES.FEATURE_FLAG = { - FIX_DUPLICATE_LOAD: 1 - }; - /** - * @internal - */ - var upgrade; - (function (upgrade) { - var _level = "warning"; - function setUpgradeGuideLevel(level) { - _level = level; - } - upgrade.setUpgradeGuideLevel = setUpgradeGuideLevel; - })(upgrade = RES.upgrade || (RES.upgrade = {})); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * Convert the file name of the resource to the Key value used in the project. - * @param url Resource Name. - * @returns The key value used in the project - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 将资源的文件名称转换为项目中所使用的Key值。 - * 在加载合并图集的时候使用,例如图集加载A_json,需要加载对应A_png,这里就是转换的机制 - * 一般项目中无需更改,只有没有使用默认的key和文件对应的需要修改 - * @param url 资源名称。 - * @returns 项目中所用的key值 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function nameSelector(url) { - return RES.path.basename(url).split(".").join("_"); - } - RES.nameSelector = nameSelector; - /** - * Get the read type of the file. - * When using getResByUrl does not specify the type of the read file, it will find the corresponding type according to this method. - * File types not found are loaded by default in binary format - * @param path file path. - * @returns Processor type used to read the file - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文件的读取类型 - * 在使用getResByUrl没有指定读取文件的类型,会根据这个方法寻找对应的类型 - * 没有查找到的文件类型以二进制格式默认加载 - * @param path 文件路径 - * @returns 读取文件所用的Processor类型 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function typeSelector(path) { - var ext = path.substr(path.lastIndexOf(".") + 1); - var type; - switch (ext) { - case RES.ResourceItem.TYPE_XML: - case RES.ResourceItem.TYPE_JSON: - case RES.ResourceItem.TYPE_SHEET: - type = ext; - break; - case "png": - case "jpg": - case "gif": - case "jpeg": - case "bmp": - type = RES.ResourceItem.TYPE_IMAGE; - break; - case "fnt": - type = RES.ResourceItem.TYPE_FONT; - break; - case "txt": - type = RES.ResourceItem.TYPE_TEXT; - break; - case "mp3": - case "ogg": - case "mpeg": - case "wav": - case "m4a": - case "mp4": - case "aiff": - case "wma": - case "mid": - type = RES.ResourceItem.TYPE_SOUND; - break; - case "mergeJson": - case "zip": - case "pvr": - type = ext; - break; - default: - type = RES.ResourceItem.TYPE_BIN; - break; - } - return type; - } - RES.typeSelector = typeSelector; - /** - * Conduct mapping injection with class definition as the value, Deprecated. - * @deprecated - * @see RES.processor.map - * @language en_US - */ - /** - * 以类定义为值进行映射注入,已废弃。 - * @deprecated - * @see RES.processor.map - * @language zh_CN - */ - function registerAnalyzer(type, analyzerClass) { - throw new RES.ResourceManagerError(2002); - } - RES.registerAnalyzer = registerAnalyzer; - /** - * Set whether it is compatible mode - * When the value is true, the assetsManager will output the design of Res. When it is false, all the loaded resources will be returned as promises. - * The default is false, run in strict assetsManager mode - * @version Egret 5.2.9 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否为兼容模式 - * 当值为true时,assetsManager会以Res的设计输出,当为false时候,所有的加载资源都会以promise的方式返回 - * 默认是false,以严格assetsManager方式运行 - * @version Egret 5.2.9 - * @platform Web,Native - * @language zh_CN - */ - function setIsCompatible(value) { - RES.isCompatible = value; - } - RES.setIsCompatible = setIsCompatible; - /** - * @internal - */ - RES.isCompatible = false; - /** - * Load configuration file and parse. - * @param url The url address of the resource config - * @param resourceRoot The root address of the resource config - * @returns Promise - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载配置文件并解析。 - * @param url 资源配置的url地址 - * @param resourceRoot 资源配置的根地址 - * @returns Promise - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function loadConfig(url, resourceRoot) { - if (resourceRoot.indexOf('://') >= 0) { - var temp = resourceRoot.split('://'); - resourceRoot = temp[0] + '://' + RES.path.normalize(temp[1] + '/'); - url = url.replace(resourceRoot, ''); - } - else { - resourceRoot = RES.path.normalize(resourceRoot + "/"); - url = url.replace(resourceRoot, ''); - } - RES.setConfigURL(url, resourceRoot); - if (!instance) - instance = new Resource(); - return compatiblePromise(instance.loadConfig()); - } - RES.loadConfig = loadConfig; - function compatiblePromise(promise) { - if (RES.isCompatible) { - promise.catch(function (e) { }).then(); - return undefined; - } - else { - return promise; - } - } - /** - * Load a set of resources according to the group name. - * @param name Group name to load the resource group. - * @param priority Load priority can be negative, the default value is 0. - *
A low priority group must wait for the high priority group to complete the end of the load to start, and the same priority group will be loaded at the same time. - * @param reporter Resource group loading progress prompt - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名加载一组资源。 - * @param name 要加载资源组的组名。 - * @param priority 加载优先级,可以为负数,默认值为 0。 - *
低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。 - * @param reporter 资源组的加载进度提示 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function loadGroup(name, priority, reporter) { - if (priority === void 0) { priority = 0; } - return compatiblePromise(instance.loadGroup(name, priority, reporter)); - } - RES.loadGroup = loadGroup; - /** - * Check whether a resource group has been loaded. - * @param name Group name。 - * @returns Is loading or not. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 检查某个资源组是否已经加载完成。 - * @param name 组名。 - * @returns 是否正在加载。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function isGroupLoaded(name) { - return instance.isGroupLoaded(name); - } - RES.isGroupLoaded = isGroupLoaded; - /** - * A list of groups of loading is obtained according to the group name. - * @param name Group name. - * @returns The resource item array of group. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名获取组加载项列表。 - * @param name 组名。 - * @returns 加载项列表。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getGroupByName(name) { - return instance.getGroupByName(name).map(function (r) { return RES.ResourceItem.convertToResItem(r); }); - } - RES.getGroupByName = getGroupByName; - /** - * Create a custom load resource group, note that this method is valid only after the resource configuration file is loaded. - *
You can monitor the ResourceEvent.CONFIG_COMPLETE event to verify that the configuration is complete. - * @param name Group name to create the load resource group. - * @param keys To be included in the list of key keys, the corresponding configuration file in the name or sbuKeys property one or a resource group name. - * @param override Is the default false for the same name resource group already exists. - * @returns Create success or fail. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - *
可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。 - * @param name 要创建的加载资源组的组名。 - * @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。 - * @param override 是否覆盖已经存在的同名资源组,默认 false。 - * @returns 是否创建成功。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function createGroup(name, keys, override) { - if (override === void 0) { override = false; } - return instance.createGroup(name, keys, override); - } - RES.createGroup = createGroup; - /** - * Check whether the configuration file contains the specified resources. - * @param key A sbuKeys attribute or name property in a configuration file. - * @returns Whether you have the specified resource - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 检查配置文件里是否含有指定的资源。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @returns 是否拥有指定资源 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function hasRes(key) { - return instance.hasRes(key); - } - RES.hasRes = hasRes; - /** - * The synchronization method for obtaining the cache has been loaded with the success of the resource. - *
The type of resource and the corresponding return value types are as follows: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript primary object - *
RES.ResourceItem.TYPE_IMAGE : img Html Object,or egret.BitmapData interface。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. If the incoming parameter is the name of the entire SpriteSheet is returned is {image1: Texture, "image2": Texture}. - *
2. If the incoming is "sheet.image1", the return is a single resource. - *
3. If the incoming is the name of the "image1" single resource, the return is a single resource. - * But if there are two SpriteSheet in a single picture of the same name, the return of the image after the load. - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html Object - *
RES.ResourceItem.TYPE_TEXT : string - * @param key A subKeys attribute or name property in a configuration file. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 同步方式获取缓存的已经加载成功的资源。 - *
资源类型和对应的返回值类型关系如下: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript 原生对象 - *
RES.ResourceItem.TYPE_IMAGE : img Html 对象,或者 egret.BitmapData 接口。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. 如果传入的参数是整个 SpriteSheet 的名称返回的是 {"image1":Texture,"image2":Texture} 这样的格式。 - *
2. 如果传入的是 "sheet.image1",返回的是单个资源。 - *
3. 如果传入的是 "image1" 单个资源的名称,返回的是单个资源。但是如果有两张 SpriteSheet 中有单个图片资源名称相同,返回的是后加载的那个图片资源。 - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html 对象 - *
RES.ResourceItem.TYPE_TEXT : string - * @param key 对应配置文件里的 name 属性或 subKeys 属性的一项。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getRes(key) { - return instance.getRes(key); - } - RES.getRes = getRes; - /** - * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way. - * @param key A sbuKeys attribute or name property in a configuration file. - * @param compFunc Call back function. Example:compFunc(data,key):void. - * @param thisObject This pointer of call back function. - * @see #setMaxRetryTimes - * @example The following code demonstrates how to load a resource via getResAsync - *
-     *       RES.getResAsync("resource/example.json");//Only pass the key value to get the resource
-     *
-     *       RES.getResAsync("resource/example.json", (data) => {
-     *          console.log(data)
-     *       }, this) //Pass in the key value, compFunc and thisObject get the resource, the latter two must appear at the same time
-     * 
- * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @param compFunc 回调函数。示例:compFunc(data,key):void。 - * @param thisObject 回调函数的 this 引用。 - * @see #setMaxRetryTimes - * @example 以下代码演示了如何通过getResAsync加载资源 - *
-     *       RES.getResAsync("resource/example.json");//只传入key值获取资源
-     *
-     *       RES.getResAsync("resource/example.json", (data) => {
-     *          console.log(data)
-     *       }, this) //传入key值,compFunc和thisObject获取资源,后两个必须同时出现
-     * 
- * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResAsync(key, compFunc, thisObject) { - return compatiblePromise(instance.getResAsync.apply(instance, arguments)); - } - RES.getResAsync = getResAsync; - /** - * Access to external resources through the full URL. - * @param url The external path to load the file. - * @param compFunc Call back function. Example:compFunc(data,url):void。 - * @param thisObject This pointer of call back function. - * @param type File type (optional). Use the static constants defined in the ResourceItem class. If you do not set the file name extension. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 通过完整URL方式获取外部资源。 - * @param url 要加载文件的外部路径。 - * @param compFunc 回调函数。示例:compFunc(data,url):void。 - * @param thisObject 回调函数的 this 引用。 - * @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResByUrl(url, compFunc, thisObject, type) { - if (type === void 0) { type = ""; } - if (!instance) { - var message = egret.sys.tr(3200); - egret.warn(message); - return Promise.reject(message); - } - return compatiblePromise(instance.getResByUrl(url, compFunc, thisObject, type)); - } - RES.getResByUrl = getResByUrl; - /** - * Destroy a single resource file or a set of resources to the cache data, to return whether to delete success. - * @param name Name attribute or resource group name of the load item in the configuration file. - * @param force Destruction of a resource group when the other resources groups have the same resource situation whether the resources will be deleted, the default value true. - * @returns Are successful destruction. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @param name 配置文件中加载项的name属性或资源组名。 - * @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。 - * @see #setMaxRetryTimes - * @returns 是否销毁成功。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function destroyRes(name, force) { - return instance.destroyRes(name, force); - } - RES.destroyRes = destroyRes; - /** - * Sets the maximum number of concurrent load threads, the default value is 4. - * @param thread The number of concurrent loads to be set. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 设置最大并发加载线程数量,默认值是 4。 - * @param thread 要设置的并发加载数。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function setMaxLoadingThread(thread) { - if (!instance) - instance = new Resource(); - instance.setMaxLoadingThread(thread); - } - RES.setMaxLoadingThread = setMaxLoadingThread; - /** - * Sets the number of retry times when the resource failed to load, and the default value is 3. - * @param retry To set the retry count. - * @includeExample extension/resource/Resource.ts - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 设置资源加载失败时的重试次数,默认值是 3。 - * @param retry 要设置的重试次数。 - * @includeExample extension/resource/Resource.ts - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function setMaxRetryTimes(retry) { - instance.setMaxRetryTimes(retry); - } - RES.setMaxRetryTimes = setMaxRetryTimes; - /** - * Add event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listener functions for handling events. This function must accept the Event object as its only parameter, and can't return any results, - * As shown in the following example: function (evt:Event):void can have any name. - * @param thisObject The this object that is bound to a function. - * @param useCapture Determine the listener is running on the capture or running on the target and the bubbling phase. Set useCapture to true, - * then the listener in the capture phase processing events, but not in the target or the bubbling phase processing events. - * If useCapture is false, then the listener only in the target or the bubbling phase processing events. - * To listen for events in all three stages, please call addEventListener two times: once the useCapture is set to true, once the useCapture is set to false. - * @param priority Event listener priority. Priority is specified by a 32 - bit integer with a symbol. The higher the number, the higher the priority. - * All listeners with a priority for n will be processed before the -1 n listener. - * If two or more listeners share the same priority, they are processed in accordance with the order of their added. The default priority is 0. - * @see RES.ResourceEvent - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 添加事件侦听器,参考 ResourceEvent 定义的常量。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的 this 对象。 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于目标和冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在目标或冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在目标或冒泡阶段处理事件。 - * 要在所有三个阶段都侦听事件,请调用 addEventListener 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的 32 位整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see RES.ResourceEvent - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function addEventListener(type, listener, thisObject, useCapture, priority) { - if (useCapture === void 0) { useCapture = false; } - if (priority === void 0) { priority = 0; } - if (!instance) - instance = new Resource(); - instance.addEventListener(type, listener, thisObject, useCapture, priority); - } - RES.addEventListener = addEventListener; - /** - * Remove event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listening function。 - * @param thisObject The this object that is bound to a function. - * @param useCapture Is used to capture, and this property is only valid in the display list. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 移除事件侦听器,参考ResourceEvent定义的常量。 - * @param type 事件名。 - * @param listener 侦听函数。 - * @param thisObject 侦听函数绑定的this对象。 - * @param useCapture 是否使用捕获,这个属性只在显示列表中生效。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function removeEventListener(type, listener, thisObject, useCapture) { - if (useCapture === void 0) { useCapture = false; } - instance.removeEventListener(type, listener, thisObject, useCapture); - } - RES.removeEventListener = removeEventListener; - /** - * Adding a custom resource configuration. - * @param data To add configuration. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 自定义添加一项资源配置。 - * @param data 要添加的配置。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function $addResourceData(data) { - //这里可能需要其他配置 - instance.addResourceData(data); - } - RES.$addResourceData = $addResourceData; - /** - * Returns the VersionController - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获得版本控制器. - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getVersionController() { - if (!instance) - instance = new Resource(); - return instance.vcs; - } - RES.getVersionController = getVersionController; - /** - * Register the VersionController - * @param vcs The VersionController to register. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 注册版本控制器,通过RES模块加载资源时会从版本控制器获取真实url - * @param vcs 注入的版本控制器。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function registerVersionController(vcs) { - if (!instance) - instance = new Resource(); - instance.registerVersionController(vcs); - } - RES.registerVersionController = registerVersionController; - /** - * Convert the address of the loaded resource (via version controller conversion) - * @param url path to the original resource - * @returns converted address - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 转换加载资源的地址(经过版本控制器的转换) - * @param url 原始资源的路径 - * @returns 转换后的地址 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getVirtualUrl(url) { - if (instance.vcs) { - return instance.vcs.getVirtualUrl(url); - } - else { - return url; - } - } - RES.getVirtualUrl = getVirtualUrl; - /** - * @private - */ - var Resource = (function (_super) { - __extends(Resource, _super); - function Resource() { - var _this = _super.call(this) || this; - _this.isVcsInit = false; - /** - * @private - * 版本控制器加载后的加载配置 - */ - _this.normalLoadConfig = function () { - return RES.config.init().then(function (data) { - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.CONFIG_COMPLETE); - }, function (error) { - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.CONFIG_LOAD_ERROR); - return Promise.reject(error); - }); - }; - if (RES.VersionController) { - _this.vcs = new RES.VersionController(); - } - return _this; - } - Resource.prototype.registerVersionController = function (vcs) { - this.vcs = vcs; - this.isVcsInit = false; - }; - /** - * 开始加载配置 - * @method RES.loadConfig - */ - Resource.prototype.loadConfig = function () { - var _this = this; - if (!this.isVcsInit && this.vcs) { - this.isVcsInit = true; - return this.vcs.init().then(function () { - return _this.normalLoadConfig(); - }); - } - else { - return this.normalLoadConfig(); - } - }; - /** - * 检查某个资源组是否已经加载完成 - * @method RES.isGroupLoaded - * @param name {string} - */ - Resource.prototype.isGroupLoaded = function (name) { - var resources = RES.config.getGroupByName(name); - return resources.every(function (r) { return RES.host.get(r) != null; }); - }; - /** - * 根据组名获取组加载项列表 - * @method RES.getGroupByName - * @param name {string} - */ - Resource.prototype.getGroupByName = function (name) { - return RES.config.getGroupByName(name); - }; - /** - * 根据组名加载一组资源 - * @method RES.loadGroup - * @param name {string} - * @param priority {number} - */ - Resource.prototype.loadGroup = function (name, priority, reporter) { - var _this = this; - if (priority === void 0) { priority = 0; } - var reporterDelegate = { - onProgress: function (current, total, resItem) { - if (reporter && reporter.onProgress) { - reporter.onProgress(current, total, resItem); - } - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_PROGRESS, name, resItem, current, total); - } - }; - return this._loadGroup(name, priority, reporterDelegate).then(function (data) { - if (RES.config.config.loadGroup.indexOf(name) == -1) { - RES.config.config.loadGroup.push(name); - } - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_COMPLETE, name); - }, function (error) { - if (RES.config.config.loadGroup.indexOf(name) == -1) { - RES.config.config.loadGroup.push(name); - } - if (error.itemList) { - var itemList = error.itemList; - var length_1 = itemList.length; - for (var i = 0; i < length_1; i++) { - var item = itemList[i]; - delete item.promise; - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, name, item); - } - } - if (RES.isCompatible) { - console.warn(error.error.message); - } - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.GROUP_LOAD_ERROR, name); - return Promise.reject(error.error); - }); - }; - Resource.prototype._loadGroup = function (name, priority, reporter) { - if (priority === void 0) { priority = 0; } - var resources = RES.config.getGroupByName(name); - if (resources.length == 0) { - return new Promise(function (resolve, reject) { - reject({ error: new RES.ResourceManagerError(2005, name) }); - }); - } - return RES.queue.pushResGroup(resources, name, priority, reporter); - }; - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - Resource.prototype.createGroup = function (name, keys, override) { - if (override === void 0) { override = false; } - return RES.config.createGroup(name, keys, override); - }; - /** - * 检查配置文件里是否含有指定的资源 - * @method RES.hasRes - * @param key {string} 对应配置文件里的name属性或subKeys属性的一项。 - * @returns {boolean} - */ - Resource.prototype.hasRes = function (key) { - return RES.config.getResourceWithSubkey(key) != null; - }; - /** - * 通过key同步获取资源 - * @method RES.getRes - * @param key {string} - * @returns {any} - */ - Resource.prototype.getRes = function (resKey) { - var result = RES.config.getResourceWithSubkey(resKey); - if (result) { - var r = result.r; - var key = result.key; - var subkey = result.subkey; - var p = RES.processor.isSupport(r); - if (p && p.getData && subkey) { - return p.getData(RES.host, r, key, subkey); - } - else { - return RES.host.get(r); - } - } - else { - return null; - } - }; - Resource.prototype.getResAsync = function (key, compFunc, thisObject) { - var _this = this; - var paramKey = key; - var tempResult = RES.config.getResourceWithSubkey(key); - if (tempResult == null) { - if (compFunc) { - compFunc.call(thisObject, null, paramKey); - } - return Promise.reject(new RES.ResourceManagerError(2006, key)); - } - var data = this.getRes(key); - if (data) { - if (compFunc) { - egret.callLater(function () { - compFunc.call(thisObject, data, paramKey); - }, this); - } - return Promise.resolve(data); - } - var r = tempResult.r, subkey = tempResult.subkey; - return RES.queue.pushResItem(r).then(function (value) { - RES.host.save(r, value); - var p = RES.processor.isSupport(r); - if (p && p.getData && subkey) { - value = p.getData(RES.host, r, key, subkey); - } - if (compFunc) { - compFunc.call(thisObject, value, paramKey); - } - return value; - }, function (error) { - RES.host.remove(r); - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, "", r); - if (compFunc) { - compFunc.call(thisObject, null, paramKey); - return Promise.reject(null); - } - return Promise.reject(error); - }); - }; - /** - * 通过url获取资源 - * @method RES.getResByUrl - * @param url {string} - * @param compFunc {Function} - * @param thisObject {any} - * @param type {string} - */ - Resource.prototype.getResByUrl = function (url, compFunc, thisObject, type) { - var _this = this; - if (type === void 0) { type = ""; } - var r = RES.config.getResource(url); - if (!r) { - if (!type) { - type = RES.config.__temp__get__type__via__url(url); - } - // manager.config.addResourceData({ name: url, url: url }); - r = { name: url, url: url, type: type, root: '', extra: 1 }; - RES.config.addResourceData(r); - r = RES.config.getResource(url); - if (!r) { - throw 'never'; - } - } - return RES.queue.pushResItem(r).then(function (value) { - RES.host.save(r, value); - if (compFunc && r) { - compFunc.call(thisObject, value, r.url); - } - return value; - }, function (error) { - RES.host.remove(r); - RES.ResourceEvent.dispatchResourceEvent(_this, RES.ResourceEvent.ITEM_LOAD_ERROR, "", r); - if (compFunc) { - compFunc.call(thisObject, null, url); - return Promise.reject(null); - } - return Promise.reject(error); - }); - }; - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @method RES.destroyRes - * @param name {string} 配置文件中加载项的name属性或资源组名 - * @param force {boolean} 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值true - * @returns {boolean} - */ - Resource.prototype.destroyRes = function (name, force) { - if (force === void 0) { force = true; } - var group = RES.config.getGroupByName(name); - if (group && group.length > 0) { - var index = RES.config.config.loadGroup.indexOf(name); - if (index == -1) { - return false; - } - if (force || (RES.config.config.loadGroup.length == 1 && RES.config.config.loadGroup[0] == name)) { - for (var _i = 0, group_2 = group; _i < group_2.length; _i++) { - var item = group_2[_i]; - RES.queue.unloadResource(item); - } - RES.config.config.loadGroup.splice(index, 1); - } - else { - var removeItemHash = {}; - for (var _a = 0, _b = RES.config.config.loadGroup; _a < _b.length; _a++) { - var groupName = _b[_a]; - for (var key in RES.config.config.groups[groupName]) { - var tmpname = RES.config.config.groups[groupName][key]; - if (removeItemHash[tmpname]) { - removeItemHash[tmpname]++; - } - else { - removeItemHash[tmpname] = 1; - } - } - } - for (var _c = 0, group_3 = group; _c < group_3.length; _c++) { - var item = group_3[_c]; - if (removeItemHash[item.name] && removeItemHash[item.name] == 1) { - RES.queue.unloadResource(item); - } - } - RES.config.config.loadGroup.splice(index, 1); - } - return true; - } - else { - var item = RES.config.getResource(name); - if (item) { - return RES.queue.unloadResource(item); - } - else { - console.warn("\u5728\u5185\u5B58" + name + "\u8D44\u6E90\u4E0D\u5B58\u5728"); - return false; - } - } - }; - /** - * 设置最大并发加载线程数量,默认值是4. - * @method RES.setMaxLoadingThread - * @param thread {number} 要设置的并发加载数。 - */ - Resource.prototype.setMaxLoadingThread = function (thread) { - if (thread < 1) { - thread = 1; - } - RES.queue.thread = thread; - }; - /** - * 设置资源加载失败时的重试次数。 - * @param retry 要设置的重试次数。 - */ - Resource.prototype.setMaxRetryTimes = function (retry) { - retry = Math.max(retry, 0); - RES.queue.maxRetryTimes = retry; - }; - Resource.prototype.addResourceData = function (data) { - data["root"] = ''; - RES.config.addResourceData(data); - }; - __decorate([ - RES.checkNull - ], Resource.prototype, "hasRes", null); - __decorate([ - RES.checkNull - ], Resource.prototype, "getRes", null); - __decorate([ - RES.checkNull - ], Resource.prototype, "getResAsync", null); - __decorate([ - RES.checkNull - ], Resource.prototype, "getResByUrl", null); - return Resource; - }(egret.EventDispatcher)); - RES.Resource = Resource; - __reflect(Resource.prototype, "RES.Resource"); - /** - * Resource单例 - */ - var instance; -})(RES || (RES = {})); -var RES; -(function (RES) { - /** - * Print the memory occupied by the picture. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 对文件路径的一些操作,针对的是 C:/A/B/C/D/example.ts这种格式 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - var path; - (function (path_1) { - /** - * Format the file path,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" - * @param filename Incoming file path - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 格式化文件路径,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" - * @param filename 传入的文件路径 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function normalize(filename) { - var arr = filename.split("/"); - return arr.filter(function (value, index) { return !!value || index == arr.length - 1; }).join("/"); - } - path_1.normalize = normalize; - /** - * Get the file name according to the file path, "C:/A/B/example.ts"=>"example.ts" - * @param filename Incoming file path - * @return File name - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据文件路径得到文件名字,"C:/A/B/example.ts"=>"example.ts" - * @param filename 传入的文件路径 - * @return 文件的名字 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function basename(filename) { - return filename.substr(filename.lastIndexOf("/") + 1); - } - path_1.basename = basename; - /** - * The path to the folder where the file is located,"C:/A/B/example.ts"=>"C:/A/B" - * @param filename Incoming file path - * @return The address of the folder where the file is located - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 文件所在文件夹路径,"C:/A/B/example.ts"=>"C:/A/B" - * @param filename 传入的文件路径 - * @return 文件所在文件夹的地址 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function dirname(path) { - return path.substr(0, path.lastIndexOf("/")); - } - path_1.dirname = dirname; - })(path = RES.path || (RES.path = {})); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * @private - */ - var NativeVersionController = (function () { - function NativeVersionController() { - } - NativeVersionController.prototype.init = function () { - this.versionInfo = this.getLocalData("all.manifest"); - return Promise.resolve(); - }; - NativeVersionController.prototype.getVirtualUrl = function (url) { - return url; - }; - NativeVersionController.prototype.getLocalData = function (filePath) { - if (egret_native.readUpdateFileSync && egret_native.readResourceFileSync) { - //先取更新目录 - var content = egret_native.readUpdateFileSync(filePath); - if (content != null) { - return JSON.parse(content); - } - //再取资源目录 - content = egret_native.readResourceFileSync(filePath); - if (content != null) { - return JSON.parse(content); - } - } - return null; - }; - return NativeVersionController; - }()); - RES.NativeVersionController = NativeVersionController; - __reflect(NativeVersionController.prototype, "RES.NativeVersionController", ["RES.IVersionController"]); - if (egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE) { - RES.VersionController = NativeVersionController; - } -})(RES || (RES = {})); -var RES; -(function (RES) { - var processor; - (function (processor_1) { - /** - * @internal - * @param resource 对应的资源接口,需要type属性 - */ - function isSupport(resource) { - return processor_1._map[resource.type]; - } - processor_1.isSupport = isSupport; - /** - * Register the processor that loads the resource - * @param type Load resource type - * @param processor Loaded processor, an instance that implements the Processor interface - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 注册加载资源的处理器 - * @param type 加载资源类型 - * @param processor 加载的处理器,一个实现Processor接口的实例 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function map(type, processor) { - processor_1._map[type] = processor; - } - processor_1.map = map; - /** - * @internal - */ - function promisify(loader, resource) { - var _this = this; - return new Promise(function (resolve, reject) { - var onSuccess = function () { - var texture = loader['data'] ? loader['data'] : loader['response']; - resolve(texture); - }; - var onError = function () { - var e = new RES.ResourceManagerError(1001, resource.url); - reject(e); - }; - loader.addEventListener(egret.Event.COMPLETE, onSuccess, _this); - loader.addEventListener(egret.IOErrorEvent.IO_ERROR, onError, _this); - }); - } - /** - * @private - * @param url - * @param file - */ - function getRelativePath(url, file) { - if (file.indexOf("://") != -1) { - return file; - } - url = url.split("\\").join("/"); - var params = url.match(/#.*|\?.*/); - var paramUrl = ""; - if (params) { - paramUrl = params[0]; - } - var index = url.lastIndexOf("/"); - if (index != -1) { - url = url.substring(0, index + 1) + file; - } - else { - url = file; - } - return url + paramUrl; - } - processor_1.getRelativePath = getRelativePath; - processor_1.ImageProcessor = { - onLoadStart: function (host, resource) { - var loader = new egret.ImageLoader(); - loader.load(RES.getVirtualUrl(resource.root + resource.url)); - return promisify(loader, resource) - .then(function (bitmapData) { - var texture = new egret.Texture(); - texture._setBitmapData(bitmapData); - var r = host.resourceConfig.getResource(resource.name); - if (r && r.scale9grid) { - var list = r.scale9grid.split(","); - texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); - } - return texture; - }); - }, - onRemoveStart: function (host, resource) { - var texture = host.get(resource); - texture.dispose(); - } - }; - processor_1.KTXTextureProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, 'bin').then(function (data) { - if (!data) { - console.error('ktx:' + resource.root + resource.url + ' is null'); - return null; - } - var ktx = new egret.KTXContainer(data, 1); - if (ktx.isInvalid) { - console.error('ktx:' + resource.root + resource.url + ' is invalid'); - return null; - } - // - var bitmapData = new egret.BitmapData(data); - bitmapData.debugCompressedTextureURL = resource.root + resource.url; - bitmapData.format = 'ktx'; - ktx.uploadLevels(bitmapData, false); - // - var texture = new egret.Texture(); - texture._setBitmapData(bitmapData); - var r = host.resourceConfig.getResource(resource.name); - if (r && r.scale9grid) { - var list = r.scale9grid.split(","); - texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); - } - // - host.save(resource, texture); - return texture; - }, function (e) { - host.remove(resource); - throw e; - }); - }, - onRemoveStart: function (host, resource) { - var texture = host.get(resource); - if (texture) { - texture.dispose(); - } - } - }; - /** - * - */ - function makeEtc1SeperatedAlphaResourceInfo(resource) { - return { name: resource.name + '_alpha', url: resource['etc1_alpha_url'], type: 'ktx', root: resource.root }; - } - processor_1.makeEtc1SeperatedAlphaResourceInfo = makeEtc1SeperatedAlphaResourceInfo; - /** - * - */ - processor_1.ETC1KTXProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, "ktx").then(function (colorTex) { - if (!colorTex) { - return null; - } - if (resource['etc1_alpha_url']) { - var r_1 = makeEtc1SeperatedAlphaResourceInfo(resource); - return host.load(r_1, "ktx") - .then(function (alphaMaskTex) { - if (colorTex && colorTex.$bitmapData && alphaMaskTex.$bitmapData) { - colorTex.$bitmapData.etcAlphaMask = alphaMaskTex.$bitmapData; - host.save(r_1, alphaMaskTex); - } - else { - host.remove(r_1); - } - return colorTex; - }, function (e) { - host.remove(r_1); - throw e; - }); - } - return colorTex; - }, function (e) { - host.remove(resource); - throw e; - }); - }, - onRemoveStart: function (host, resource) { - var colorTex = host.get(resource); - if (colorTex) { - colorTex.dispose(); - } - if (resource['etc1_alpha_url']) { - var r = makeEtc1SeperatedAlphaResourceInfo(resource); - var alphaMaskTex = host.get(r); - if (alphaMaskTex) { - alphaMaskTex.dispose(); - } - host.unload(r); //这里其实还会再删除一次,不过无所谓了。alphaMaskTex已经显示删除了 - } - } - }; - processor_1.BinaryProcessor = { - onLoadStart: function (host, resource) { - var request = new egret.HttpRequest(); - request.responseType = egret.HttpResponseType.ARRAY_BUFFER; - request.open(RES.getVirtualUrl(resource.root + resource.url), "get"); - request.send(); - return promisify(request, resource); - }, - onRemoveStart: function (host, resource) { - } - }; - processor_1.TextProcessor = { - onLoadStart: function (host, resource) { - var request = new egret.HttpRequest(); - request.responseType = egret.HttpResponseType.TEXT; - request.open(RES.getVirtualUrl(resource.root + resource.url), "get"); - request.send(); - return promisify(request, resource); - }, - onRemoveStart: function (host, resource) { - return true; - } - }; - processor_1.JsonProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, 'text').then(function (text) { - var data = JSON.parse(text); - return data; - }); - }, - onRemoveStart: function (host, request) { - } - }; - /** - * @internal - */ - processor_1.XMLProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, 'text').then(function (text) { - var data = egret.XML.parse(text); - return data; - }); - }, - onRemoveStart: function (host, resource) { - return true; - } - }; - /** - * @internal - */ - processor_1.CommonJSProcessor = { - onLoadStart: function (host, resource) { - // let text = await host.load(resource, 'text'); - return host.load(resource, 'text').then(function (text) { - var f = new Function('require', 'exports', text); - var require = function () { }; - var exports = {}; - try { - f(require, exports); - } - catch (e) { - throw new RES.ResourceManagerError(2003, resource.name, e.message); - } - return exports; - }); - }, - onRemoveStart: function (host, resource) { - } - }; - /** - * @internal - */ - processor_1.SheetProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, "json").then(function (data) { - var r = host.resourceConfig.getResource(RES.nameSelector(data.file)); - if (!r) { - var imageName = getRelativePath(resource.url, data.file); - r = { name: imageName, url: imageName, type: 'image', root: resource.root }; - } - return host.load(r) - .then(function (bitmapData) { - if (!bitmapData) { - return null; - } - var frames = data.frames; - var spriteSheet = new egret.SpriteSheet(bitmapData); - spriteSheet["$resourceInfo"] = r; - for (var subkey in frames) { - var config = frames[subkey]; - var texture = spriteSheet.createTexture(subkey, config.x, config.y, config.w, config.h, config.offX, config.offY, config.sourceW, config.sourceH); - if (config["scale9grid"]) { - var str = config["scale9grid"]; - var list = str.split(","); - texture["scale9Grid"] = new egret.Rectangle(parseInt(list[0]), parseInt(list[1]), parseInt(list[2]), parseInt(list[3])); - } - } - host.save(r, bitmapData); - return spriteSheet; - }, function (e) { - host.remove(r); - throw e; - }); - }); - }, - getData: function (host, resource, key, subkey) { - var data = host.get(resource); - if (data) { - return data.getTexture(subkey); - } - else { - return null; - } - }, - onRemoveStart: function (host, resource) { - var sheet = host.get(resource); - var r = sheet["$resourceInfo"]; - sheet.dispose(); - host.unload(r); - } - }; - var fontGetTexturePath = function (url, fntText) { - var file = ""; - var lines = fntText.split("\n"); - var pngLine = lines[2]; - var index = pngLine.indexOf("file=\""); - if (index != -1) { - pngLine = pngLine.substring(index + 6); - index = pngLine.indexOf("\""); - file = pngLine.substring(0, index); - } - url = url.split("\\").join("/"); - var index = url.lastIndexOf("/"); - if (index != -1) { - url = url.substring(0, index + 1) + file; - } - else { - url = file; - } - return url; - }; - /** - * @internal - */ - processor_1.FontProcessor = { - onLoadStart: function (host, resource) { - // let data: string = await host.load(resource, 'text'); - return host.load(resource, 'text').then(function (data) { - var config; - try { - config = JSON.parse(data); - } - catch (e) { - config = data; - } - var imageName; - if (typeof config === 'string') { - imageName = fontGetTexturePath(resource.url, config); - } - else { - imageName = getRelativePath(resource.url, config.file); - } - var r = host.resourceConfig.getResource(RES.nameSelector(imageName)); - if (!r) { - r = { name: imageName, url: imageName, type: 'image', root: resource.root }; - } - // var texture: egret.Texture = await host.load(r); - return host.load(r).then(function (texture) { - var font = new egret.BitmapFont(texture, config); - font["$resourceInfo"] = r; - // todo refactor - host.save(r, texture); - return font; - }, function (e) { - host.remove(r); - throw e; - }); - }); - }, - onRemoveStart: function (host, resource) { - var font = host.get(resource); - var r = font["$resourceInfo"]; - host.unload(r); - } - }; - processor_1.SoundProcessor = { - onLoadStart: function (host, resource) { - var sound = new egret.Sound(); - sound.load(RES.getVirtualUrl(resource.root + resource.url)); - return promisify(sound, resource).then(function () { - return sound; - }); - }, - onRemoveStart: function (host, resource) { - var sound = host.get(resource); - sound.close(); - } - }; - /** - * @internal - */ - processor_1.MovieClipProcessor = { - onLoadStart: function (host, resource) { - var mcData; - var imageResource; - return host.load(resource, 'json') - .then(function (value) { - mcData = value; - var jsonPath = resource.name; - var imagePath = jsonPath.substring(0, jsonPath.lastIndexOf(".")) + ".png"; - imageResource = host.resourceConfig.getResource(imagePath); - if (!imageResource) { - throw new RES.ResourceManagerError(1001, imagePath); - } - return host.load(imageResource); - }).then(function (value) { - host.save(imageResource, value); - var mcTexture = value; - var mcDataFactory = new egret.MovieClipDataFactory(mcData, mcTexture); - return mcDataFactory; - }); - }, - onRemoveStart: function (host, resource) { - var mcFactory = host.get(resource); - mcFactory.clearCache(); - mcFactory.$spriteSheet.dispose(); - // refactor - var jsonPath = resource.name; - var imagePath = jsonPath.substring(0, jsonPath.lastIndexOf(".")) + ".png"; - var imageResource = host.resourceConfig.getResource(imagePath); - if (imageResource) { - host.unload(imageResource); - } - } - }; - /** - * @internal - */ - processor_1.MergeJSONProcessor = { - onLoadStart: function (host, resource) { - // let data = await host.load(resource, 'json'); - return host.load(resource, 'json').then(function (data) { - for (var key in data) { - RES.config.addSubkey(key, resource.name); - } - return data; - }); - }, - getData: function (host, resource, key, subkey) { - var data = host.get(resource); - if (data) { - return data[subkey]; - } - else { - console.error("missing resource :" + resource.name); - return null; - } - }, - onRemoveStart: function (host, resource) { - } - }; - /** - * @internal - */ - processor_1.LegacyResourceConfigProcessor = { - onLoadStart: function (host, resource) { - return host.load(resource, 'json').then(function (data) { - var resConfigData = RES.config.config; - var root = resource.root; - var fileSystem = resConfigData.fileSystem; - if (!fileSystem) { - fileSystem = { - fsData: {}, - getFile: function (filename) { - return fsData[filename]; - }, - addFile: function (data) { - if (!data.type) - data.type = ""; - if (root == undefined) { - data.root = ""; - } - fsData[data.name] = data; - }, - profile: function () { - console.log(fsData); - }, - removeFile: function (filename) { - delete fsData[filename]; - } - }; - resConfigData.fileSystem = fileSystem; - } - var groups = resConfigData.groups; - for (var _i = 0, _a = data.groups; _i < _a.length; _i++) { - var g = _a[_i]; - if (g.keys == "") { - groups[g.name] = []; - } - else { - groups[g.name] = g.keys.split(","); - } - } - var alias = resConfigData.alias; - var fsData = fileSystem['fsData']; - var _loop_1 = function (resource_1) { - fsData[resource_1.name] = resource_1; - fsData[resource_1.name].root = root; - if (resource_1.subkeys) { - resource_1.subkeys.split(",").forEach(function (subkey) { - alias[subkey] = resource_1.name + "#" + subkey; - alias[resource_1.name + "." + subkey] = resource_1.name + "#" + subkey; - }); - // ResourceConfig. - } - }; - for (var _b = 0, _c = data.resources; _b < _c.length; _b++) { - var resource_1 = _c[_b]; - _loop_1(resource_1); - } - host.save(resource, data); - return data; - }); - }, - onRemoveStart: function () { - } - }; - /** - * @internal - */ - processor_1._map = { - "image": processor_1.ImageProcessor, - "json": processor_1.JsonProcessor, - "text": processor_1.TextProcessor, - "xml": processor_1.XMLProcessor, - "sheet": processor_1.SheetProcessor, - "font": processor_1.FontProcessor, - "bin": processor_1.BinaryProcessor, - "commonjs": processor_1.CommonJSProcessor, - "sound": processor_1.SoundProcessor, - "movieclip": processor_1.MovieClipProcessor, - "mergeJson": processor_1.MergeJSONProcessor, - "legacyResourceConfig": processor_1.LegacyResourceConfigProcessor, - "ktx": processor_1.KTXTextureProcessor, - "etc1.ktx": processor_1.ETC1KTXProcessor, - "pvrtc.ktx": processor_1.KTXTextureProcessor, - }; - })(processor = RES.processor || (RES.processor = {})); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * The events of resource loading. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源加载事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - var ResourceEvent = (function (_super) { - __extends(ResourceEvent, _super); - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 5.2 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 5.2 - * @platform Web,Native - * @private - * @language zh_CN - */ - function ResourceEvent(type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - var _this = _super.call(this, type, bubbles, cancelable) || this; - /** - * File number that has been loaded. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 已经加载的文件数。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - _this.itemsLoaded = 0; - /** - * Total file number to load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的总文件数。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - _this.itemsTotal = 0; - /** - * Resource group name. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源组名。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - _this.groupName = ""; - return _this; - } - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @method RES.ResourceEvent.dispatchResourceEvent - * @param target {egret.IEventDispatcher} - * @param type {string} - * @param groupName {string} - * @param resItem {egret.ResourceItem} - * @param itemsLoaded {number} - * @param itemsTotal {number} - * @internal - * @version Egret 5.2 - * @platform Web,Native - * @language en_CN - */ - ResourceEvent.dispatchResourceEvent = function (target, type, groupName, resItem, itemsLoaded, itemsTotal) { - if (groupName === void 0) { groupName = ""; } - if (resItem === void 0) { resItem = undefined; } - if (itemsLoaded === void 0) { itemsLoaded = 0; } - if (itemsTotal === void 0) { itemsTotal = 0; } - var event = egret.Event.create(ResourceEvent, type); - event.groupName = groupName; - if (resItem) { - event.resItem = RES.ResourceItem.convertToResItem(resItem); - } - event.itemsLoaded = itemsLoaded; - event.itemsTotal = itemsTotal; - var result = target.dispatchEvent(event); - egret.Event.release(event); - return result; - }; - /** - * Failure event for a load item. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 一个加载项加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.ITEM_LOAD_ERROR = "itemLoadError"; - /** - * Configure file to load and parse the completion event. Note: if a configuration file is loaded, it will not be thrown out, and if you want to handle the configuration loading failure, monitor the CONFIG_LOAD_ERROR event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.CONFIG_COMPLETE = "configComplete"; - /** - * Configuration file failed to load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.CONFIG_LOAD_ERROR = "configLoadError"; - /** - * Delay load group resource loading progress event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载进度事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.GROUP_PROGRESS = "groupProgress"; - /** - * Delay load group resource to complete event. Note: if you have a resource item loading failure, the event will not be thrown, if you want to handle the group load failure, please listen to the GROUP_LOAD_ERROR event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.GROUP_COMPLETE = "groupComplete"; - /** - * Delayed load group resource failed event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceEvent.GROUP_LOAD_ERROR = "groupLoadError"; - return ResourceEvent; - }(egret.Event)); - RES.ResourceEvent = ResourceEvent; - __reflect(ResourceEvent.prototype, "RES.ResourceEvent"); -})(RES || (RES = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var RES; -(function (RES) { - /** - * Resource term. One of the resources arrays in resource.json. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源项。对应 resource.json 中 resources 数组中的一项。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - var ResourceItem; - (function (ResourceItem) { - /** - * XML file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * XML 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_XML = "xml"; - /** - * Picture file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 图片文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_IMAGE = "image"; - /** - * Binary file. - * @version Egret 5.2 - * @platform Web - * @language en_US - */ - /** - * 二进制文件。 - * @version Egret 5.2 - * @platform Web - * @language zh_CN - */ - ResourceItem.TYPE_BIN = "bin"; - /** - * Text file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 文本文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_TEXT = "text"; - /** - * JSON file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * JSON 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_JSON = "json"; - /** - * SpriteSheet file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * SpriteSheet 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_SHEET = "sheet"; - /** - * BitmapTextSpriteSheet file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapTextSpriteSheet 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_FONT = "font"; - /** - * Sound file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 声音文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - ResourceItem.TYPE_SOUND = "sound"; - function convertToResItem(r) { - var name = r.name; - if (!RES.config.config) { - name = r.url; - } - else { - for (var aliasName in RES.config.config.alias) { - if (RES.config.config.alias[aliasName] == r.url) { - name = aliasName; - } - } - } - var result = { - name: name, - url: r.url, - type: r.type, - data: r, - root: r.root - }; - return result; - } - ResourceItem.convertToResItem = convertToResItem; - })(ResourceItem = RES.ResourceItem || (RES.ResourceItem = {})); -})(RES || (RES = {})); -var RES; -(function (RES) { - /** - * @internal - */ - var NewFileSystem = (function () { - function NewFileSystem(data) { - this.data = data; - } - NewFileSystem.prototype.profile = function () { - console.log(this.data); - }; - NewFileSystem.prototype.addFile = function (filename, type) { - if (!type) - type = ""; - filename = RES.path.normalize(filename); - var basefilename = RES.path.basename(filename); - var folder = RES.path.dirname(filename); - if (!this.exists(folder)) { - this.mkdir(folder); - } - var d = this.resolve(folder); - d[basefilename] = { url: filename, type: type }; - }; - NewFileSystem.prototype.getFile = function (filename) { - var result = this.resolve(filename); - if (result) { - result.name = filename; - } - return result; - }; - NewFileSystem.prototype.resolve = function (dirpath) { - if (dirpath == "") { - return this.data; - } - dirpath = RES.path.normalize(dirpath); - var list = dirpath.split("/"); - var current = this.data; - for (var _i = 0, list_2 = list; _i < list_2.length; _i++) { - var f = list_2[_i]; - if (current) { - current = current[f]; - } - else { - return current; - } - } - return current; - }; - NewFileSystem.prototype.mkdir = function (dirpath) { - dirpath = RES.path.normalize(dirpath); - var list = dirpath.split("/"); - var current = this.data; - for (var _i = 0, list_3 = list; _i < list_3.length; _i++) { - var f = list_3[_i]; - if (!current[f]) { - current[f] = {}; - } - current = current[f]; - } - }; - NewFileSystem.prototype.exists = function (dirpath) { - if (dirpath == "") - return true; - dirpath = RES.path.normalize(dirpath); - var list = dirpath.split("/"); - var current = this.data; - for (var _i = 0, list_4 = list; _i < list_4.length; _i++) { - var f = list_4[_i]; - if (!current[f]) { - return false; - } - current = current[f]; - } - return true; - }; - return NewFileSystem; - }()); - RES.NewFileSystem = NewFileSystem; - __reflect(NewFileSystem.prototype, "RES.NewFileSystem"); -})(RES || (RES = {})); -var RES; -(function (RES) { - var __tempCache = {}; - /** - * Print the memory occupied by the picture. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 打印图片所占内存 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function profile() { - RES.config.config.fileSystem.profile(); - console.log(__tempCache); - //todo - var totalImageSize = 0; - for (var key in __tempCache) { - var img = __tempCache[key]; - if (img instanceof egret.Texture) { - totalImageSize += img.$bitmapWidth * img.$bitmapHeight * 4; - } - } - console.log("gpu size : " + (totalImageSize / 1024).toFixed(3) + "kb"); - } - RES.profile = profile; - /** - * @internal - */ - RES.host = { - state: {}, - get resourceConfig() { - return RES.config; - }, - load: function (r, processorName) { - var processor = typeof processorName == 'string' ? RES.processor._map[processorName] : processorName; - return RES.queue["loadResource"](r, processor); - }, - unload: function (r) { return RES.queue.unloadResource(r); }, - save: function (resource, data) { - RES.host.state[resource.root + resource.name] = 2; - delete resource.promise; - __tempCache[resource.root + resource.name] = data; - }, - get: function (resource) { - return __tempCache[resource.root + resource.name]; - }, - remove: function (resource) { - delete RES.host.state[resource.root + resource.name]; - delete __tempCache[resource.root + resource.name]; - } - }; - /** - * @internal - */ - RES.config = new RES.ResourceConfig(); - /** - * @internal - */ - RES.queue = new RES.ResourceLoader(); - /** - * @private - */ - var ResourceManagerError = (function (_super) { - __extends(ResourceManagerError, _super); - function ResourceManagerError(code, replacer, replacer2) { - var _this = _super.call(this) || this; - /** - * why instanceof e != ResourceManagerError ??? - * see link : https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work - */ - _this.__resource_manager_error__ = true; - _this.name = code.toString(); - _this.message = ResourceManagerError.errorMessage[code].replace("{0}", replacer).replace("{1}", replacer2); - return _this; - } - ResourceManagerError.errorMessage = { - 1001: '文件加载失败:{0}', - 1002: "ResourceManager 初始化失败:配置文件加载失败", - 2001: "{0}解析失败,不支持指定解析类型:\'{1}\',请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor", - 2002: "Analyzer 相关API 在 ResourceManager 中不再支持,请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor", - 2003: "{0}解析失败,错误原因:{1}", - 2004: "无法找到文件类型:{0}", - 2005: "RES加载了不存在或空的资源组:\"{0}\"", - 2006: "资源配置文件中无法找到特定的资源:{0}" - }; - return ResourceManagerError; - }(Error)); - RES.ResourceManagerError = ResourceManagerError; - __reflect(ResourceManagerError.prototype, "RES.ResourceManagerError"); -})(RES || (RES = {})); diff --git a/demo/libs/modules/assetsmanager/assetsmanager.min.js b/demo/libs/modules/assetsmanager/assetsmanager.min.js deleted file mode 100644 index bd155e96..00000000 --- a/demo/libs/modules/assetsmanager/assetsmanager.min.js +++ /dev/null @@ -1 +0,0 @@ -var __reflect=this&&this.__reflect||function(e,r,t){e.__class__=r,t?t.push(r):t=[r],e.__types__=e.__types__?t.concat(e.__types__):t},__extends=this&&this.__extends||function(e,r){function t(){this.constructor=e}for(var o in r)r.hasOwnProperty(o)&&(e[o]=r[o]);t.prototype=r.prototype,e.prototype=new t},__decorate=this&&this.__decorate||function(e,r,t,o){var n,i=arguments.length,a=3>i?r:null===o?o=Object.getOwnPropertyDescriptor(r,t):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,r,t,o);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(3>i?n(a):i>3?n(r,t,a):n(r,t))||a);return i>3&&a&&Object.defineProperty(r,t,a),a},RES;!function(e){}(RES||(RES={}));var RES;!function(e){var r=function(){function r(){this.groupTotalDic={},this.numLoadedDic={},this.groupErrorDic={},this.retryTimesDic={},this.maxRetryTimes=3,this.reporterDic={},this.dispatcherDic={},this.failedList=new Array,this.loadItemErrorDic={},this.errorDic={},this.itemListPriorityDic={},this.itemLoadDic={},this.promiseHash={},this.lazyLoadList=new Array,this.loadingCount=0,this.thread=4}return r.prototype.pushResItem=function(e){if(this.promiseHash[e.root+e.name])return this.promiseHash[e.root+e.name];this.lazyLoadList.push(e),this.itemListPriorityDic[Number.NEGATIVE_INFINITY]=this.lazyLoadList,this.updatelistPriority(this.lazyLoadList,Number.NEGATIVE_INFINITY);var r=new egret.EventDispatcher;this.dispatcherDic[e.root+e.name]=r;var t=new Promise(function(e,t){r.addEventListener("complete",function(r){e(r.data)},null),r.addEventListener("error",function(e){t(e.data)},null)});return this.promiseHash[e.root+e.name]=t,this.loadNextResource(),t},r.prototype.pushResGroup=function(e,r,t,o){if(this.promiseHash[r])return this.promiseHash[r];for(var n=e.length,i=0;n>i;i++){var a=e[i];a.groupNames||(a.groupNames=[]),a.groupNames.push(r)}this.groupTotalDic[r]=e.length,this.numLoadedDic[r]=0,this.updatelistPriority(e,t),this.reporterDic[r]=o;var s=new egret.EventDispatcher;this.dispatcherDic[r]=s;var u=new Promise(function(e,r){s.addEventListener("complete",e,null),s.addEventListener("error",function(e){r(e.data)},null)});return this.promiseHash[r]=u,this.loadNextResource(),u},r.prototype.updatelistPriority=function(e,r){void 0==this.itemListPriorityDic[r]&&(this.itemListPriorityDic[r]=[]);for(var t=0,o=e;ti){this.itemListPriorityDic[r].push(n);var a=this.itemListPriorityDic[i].indexOf(n);this.itemListPriorityDic[i].splice(a,1)}}}},r.prototype.findPriorityInDic=function(e){for(var r in this.itemListPriorityDic)if(this.itemListPriorityDic[r].indexOf(e)>-1)return parseInt(r)},r.prototype.loadNextResource=function(){for(;this.loadingCountr.maxRetryTimes))return r.retryTimesDic[t.name]=n+1,r.failedList.push(t),void r.loadNextResource();if(delete r.retryTimesDic[t.name],r.promiseHash[t.root+t.name]){var i=r.deleteDispatcher(t.root+t.name);i.dispatchEventWith("error",!1,{r:t,error:o})}var a=t.groupNames;if(a){delete t.groupNames;for(var s=0,u=a;s0)return this.failedList.shift();var e=Number.NEGATIVE_INFINITY;for(var r in this.itemListPriorityDic)e=Math.max(e,r);var t=this.itemListPriorityDic[e];if(t)return 0==t.length?(delete this.itemListPriorityDic[e],this.getOneResourceInfoInGroup()):t.shift()},r.prototype.setGroupProgress=function(e,r){var t=this.reporterDic[e];this.numLoadedDic[e]++;var o=this.numLoadedDic[e],n=this.groupTotalDic[e];return t&&t.onProgress&&t.onProgress(o,n,r),o==n},r.prototype.loadGroupEnd=function(e,r){delete this.groupTotalDic[e],delete this.numLoadedDic[e],delete this.reporterDic[e];var t=this.deleteDispatcher(e);if(r){delete this.groupErrorDic[e];var o=this.loadItemErrorDic[e];delete this.loadItemErrorDic[e],t.dispatchEventWith("error",!1,{itemList:o,lastError:r})}else{var n=this.groupErrorDic[e];if(delete this.groupErrorDic[e],n){var o=this.loadItemErrorDic[e];delete this.loadItemErrorDic[e];var i=this.errorDic[e];delete this.errorDic[e],t.dispatchEventWith("error",!1,{itemList:o,error:i})}else t.dispatchEventWith("complete")}},r.prototype.deleteDispatcher=function(e){delete this.promiseHash[e];var r=this.dispatcherDic[e];return delete this.dispatcherDic[e],r},r.prototype.loadResource=function(r,t){if(!t){if(1==e.FEATURE_FLAG.FIX_DUPLICATE_LOAD){var o=e.host.state[r.root+r.name];if(2==o)return Promise.resolve(e.host.get(r));if(1==o)return r.promise}t=e.processor.isSupport(r)}if(!t)throw new e.ResourceManagerError(2001,r.name,r.type);e.host.state[r.root+r.name]=1;var n=t.onLoadStart(e.host,r);return r.promise=n,n},r.prototype.unloadResource=function(r){var t=e.host.get(r);if(!t)return console.warn("尝试释放不存在的资源:",r.name),!1;var o=e.processor.isSupport(r);return o?(o.onRemoveStart(e.host,r),e.host.remove(r),1==r.extra&&e.config.removeResourceData(r),!0):!0},r}();e.ResourceLoader=r,__reflect(r.prototype,"RES.ResourceLoader")}(RES||(RES={}));var RES;!function(e){e.checkNull=function(e,r,t){var o=t.value;t.value=function(){for(var e=[],t=0;t=0?"legacyResourceConfig":"resourceConfig",o={type:t,root:r,url:e,name:e}}e.resourceNameSelector=function(e){return e},e.getResourceInfo=r;var o;e.setConfigURL=t;var n=function(){function t(){}return t.prototype.init=function(){return this.config||(this.config={alias:{},groups:{},resourceRoot:o.root,mergeSelector:null,fileSystem:null,loadGroup:[]}),e.queue.pushResItem(o)["catch"](function(r){return e.isCompatible||r.__resource_manager_error__||(r.error?console.error(r.error.stack):console.error(r.stack),r=new e.ResourceManagerError(1002)),e.host.remove(o),Promise.reject(r)})},t.prototype.getGroupByName=function(r){var t=this.config.groups[r],o=[];if(!t)return o;for(var n=0,i=t;n=0&&(t=e.substr(r+1),e=e.substr(0,r));var o=this.getResource(e);return o?{r:o,key:e,subkey:t}:null},t.prototype.getKeyByAlias=function(e){return this.config.alias[e]?this.config.alias[e]:e},t.prototype.getResource=function(e){var t=this.config.alias[e];t||(t=e);var o=r(t);return o?o:null},t.prototype.createGroup=function(e,r,t){if(void 0===t&&(t=!1),!t&&this.config.groups[e]||!r||0==r.length)return!1;for(var o=[],n=0,i=r;n=0){var o=t.split("://");t=o[0]+"://"+e.path.normalize(o[1]+"/"),r=r.replace(t,"")}else t=e.path.normalize(t+"/"),r=r.replace(t,"");return e.setConfigURL(r,t),P||(P=new D),a(P.loadConfig())}function a(r){return e.isCompatible?void r["catch"](function(e){}).then():r}function s(e,r,t){return void 0===r&&(r=0),a(P.loadGroup(e,r,t))}function u(e){return P.isGroupLoaded(e)}function c(r){return P.getGroupByName(r).map(function(r){return e.ResourceItem.convertToResItem(r)})}function l(e,r,t){return void 0===t&&(t=!1),P.createGroup(e,r,t)}function f(e){return P.hasRes(e)}function p(e){return P.getRes(e)}function g(e,r,t){return a(P.getResAsync.apply(P,arguments))}function d(e,r,t,o){if(void 0===o&&(o=""),!P){var n=egret.sys.tr(3200);return egret.warn(n),Promise.reject(n)}return a(P.getResByUrl(e,r,t,o))}function v(e,r){return P.destroyRes(e,r)}function h(e){P||(P=new D),P.setMaxLoadingThread(e)}function m(e){P.setMaxRetryTimes(e)}function R(e,r,t,o,n){void 0===o&&(o=!1),void 0===n&&(n=0),P||(P=new D),P.addEventListener(e,r,t,o,n)}function E(e,r,t,o){void 0===o&&(o=!1),P.removeEventListener(e,r,t,o)}function y(e){P.addResourceData(e)}function _(){return P||(P=new D),P.vcs}function S(e){P||(P=new D),P.registerVersionController(e)}function L(e){return P.vcs?P.vcs.getVirtualUrl(e):e}e.nameSelector=r,e.typeSelector=t,e.registerAnalyzer=o,e.setIsCompatible=n,e.isCompatible=!1,e.loadConfig=i,e.loadGroup=s,e.isGroupLoaded=u,e.getGroupByName=c,e.createGroup=l,e.hasRes=f,e.getRes=p,e.getResAsync=g,e.getResByUrl=d,e.destroyRes=v,e.setMaxLoadingThread=h,e.setMaxRetryTimes=m,e.addEventListener=R,e.removeEventListener=E,e.$addResourceData=y,e.getVersionController=_,e.registerVersionController=S,e.getVirtualUrl=L;var D=function(r){function t(){var t=r.call(this)||this;return t.isVcsInit=!1,t.normalLoadConfig=function(){return e.config.init().then(function(r){e.ResourceEvent.dispatchResourceEvent(t,e.ResourceEvent.CONFIG_COMPLETE)},function(r){return e.ResourceEvent.dispatchResourceEvent(t,e.ResourceEvent.CONFIG_LOAD_ERROR),Promise.reject(r)})},e.VersionController&&(t.vcs=new e.VersionController),t}return __extends(t,r),t.prototype.registerVersionController=function(e){this.vcs=e,this.isVcsInit=!1},t.prototype.loadConfig=function(){var e=this;return!this.isVcsInit&&this.vcs?(this.isVcsInit=!0,this.vcs.init().then(function(){return e.normalLoadConfig()})):this.normalLoadConfig()},t.prototype.isGroupLoaded=function(r){var t=e.config.getGroupByName(r);return t.every(function(r){return null!=e.host.get(r)})},t.prototype.getGroupByName=function(r){return e.config.getGroupByName(r)},t.prototype.loadGroup=function(r,t,o){var n=this;void 0===t&&(t=0);var i={onProgress:function(t,i,a){o&&o.onProgress&&o.onProgress(t,i,a),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_PROGRESS,r,a,t,i)}};return this._loadGroup(r,t,i).then(function(t){-1==e.config.config.loadGroup.indexOf(r)&&e.config.config.loadGroup.push(r),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_COMPLETE,r)},function(t){if(-1==e.config.config.loadGroup.indexOf(r)&&e.config.config.loadGroup.push(r),t.itemList)for(var o=t.itemList,i=o.length,a=0;i>a;a++){var s=o[a];delete s.promise,e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.ITEM_LOAD_ERROR,r,s)}return e.isCompatible&&console.warn(t.error.message),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.GROUP_LOAD_ERROR,r),Promise.reject(t.error)})},t.prototype._loadGroup=function(r,t,o){void 0===t&&(t=0);var n=e.config.getGroupByName(r);return 0==n.length?new Promise(function(t,o){o({error:new e.ResourceManagerError(2005,r)})}):e.queue.pushResGroup(n,r,t,o)},t.prototype.createGroup=function(r,t,o){return void 0===o&&(o=!1),e.config.createGroup(r,t,o)},t.prototype.hasRes=function(r){return null!=e.config.getResourceWithSubkey(r)},t.prototype.getRes=function(r){var t=e.config.getResourceWithSubkey(r);if(t){var o=t.r,n=t.key,i=t.subkey,a=e.processor.isSupport(o);return a&&a.getData&&i?a.getData(e.host,o,n,i):e.host.get(o)}return null},t.prototype.getResAsync=function(r,t,o){var n=this,i=r,a=e.config.getResourceWithSubkey(r);if(null==a)return t&&t.call(o,null,i),Promise.reject(new e.ResourceManagerError(2006,r));var s=this.getRes(r);if(s)return t&&egret.callLater(function(){t.call(o,s,i)},this),Promise.resolve(s);var u=a.r,c=a.subkey;return e.queue.pushResItem(u).then(function(n){e.host.save(u,n);var a=e.processor.isSupport(u);return a&&a.getData&&c&&(n=a.getData(e.host,u,r,c)),t&&t.call(o,n,i),n},function(r){return e.host.remove(u),e.ResourceEvent.dispatchResourceEvent(n,e.ResourceEvent.ITEM_LOAD_ERROR,"",u),t?(t.call(o,null,i),Promise.reject(null)):Promise.reject(r)})},t.prototype.getResByUrl=function(r,t,o,n){var i=this;void 0===n&&(n="");var a=e.config.getResource(r);if(!a&&(n||(n=e.config.__temp__get__type__via__url(r)),a={name:r,url:r,type:n,root:"",extra:1},e.config.addResourceData(a),a=e.config.getResource(r),!a))throw"never";return e.queue.pushResItem(a).then(function(r){return e.host.save(a,r),t&&a&&t.call(o,r,a.url),r},function(n){return e.host.remove(a),e.ResourceEvent.dispatchResourceEvent(i,e.ResourceEvent.ITEM_LOAD_ERROR,"",a),t?(t.call(o,null,r),Promise.reject(null)):Promise.reject(n)})},t.prototype.destroyRes=function(r,t){void 0===t&&(t=!0);var o=e.config.getGroupByName(r);if(o&&o.length>0){var n=e.config.config.loadGroup.indexOf(r);if(-1==n)return!1;if(t||1==e.config.config.loadGroup.length&&e.config.config.loadGroup[0]==r){for(var i=0,a=o;ir&&(r=1),e.queue.thread=r},t.prototype.setMaxRetryTimes=function(r){r=Math.max(r,0),e.queue.maxRetryTimes=r},t.prototype.addResourceData=function(r){r.root="",e.config.addResourceData(r)},__decorate([e.checkNull],t.prototype,"hasRes",null),__decorate([e.checkNull],t.prototype,"getRes",null),__decorate([e.checkNull],t.prototype,"getResAsync",null),__decorate([e.checkNull],t.prototype,"getResByUrl",null),t}(egret.EventDispatcher);e.Resource=D,__reflect(D.prototype,"RES.Resource");var P}(RES||(RES={}));var RES;!function(e){var r;!function(e){function r(e){var r=e.split("/");return r.filter(function(e,t){return!!e||t==r.length-1}).join("/")}function t(e){return e.substr(e.lastIndexOf("/")+1)}function o(e){return e.substr(0,e.lastIndexOf("/"))}e.normalize=r,e.basename=t,e.dirname=o}(r=e.path||(e.path={}))}(RES||(RES={}));var RES;!function(e){function r(){e.config.config.fileSystem.profile(),console.log(t);var r=0;for(var o in t){var n=t[o];n instanceof egret.Texture&&(r+=n.$bitmapWidth*n.$bitmapHeight*4)}console.log("gpu size : "+(r/1024).toFixed(3)+"kb")}var t={};e.profile=r,e.host={state:{},get resourceConfig(){return e.config},load:function(r,t){var o="string"==typeof t?e.processor._map[t]:t;return e.queue.loadResource(r,o)},unload:function(r){return e.queue.unloadResource(r)},save:function(r,o){e.host.state[r.root+r.name]=2,delete r.promise,t[r.root+r.name]=o},get:function(e){return t[e.root+e.name]},remove:function(r){delete e.host.state[r.root+r.name],delete t[r.root+r.name]}},e.config=new e.ResourceConfig,e.queue=new e.ResourceLoader;var o=function(e){function r(t,o,n){var i=e.call(this)||this;return i.__resource_manager_error__=!0,i.name=t.toString(),i.message=r.errorMessage[t].replace("{0}",o).replace("{1}",n),i}return __extends(r,e),r.errorMessage={1001:"文件加载失败:{0}",1002:"ResourceManager 初始化失败:配置文件加载失败",2001:"{0}解析失败,不支持指定解析类型:'{1}',请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor",2002:"Analyzer 相关API 在 ResourceManager 中不再支持,请编写自定义 Processor ,更多内容请参见 https://github.com/egret-labs/resourcemanager/blob/master/docs/README.md#processor",2003:"{0}解析失败,错误原因:{1}",2004:"无法找到文件类型:{0}",2005:'RES加载了不存在或空的资源组:"{0}"',2006:"资源配置文件中无法找到特定的资源:{0}"},r}(Error);e.ResourceManagerError=o,__reflect(o.prototype,"RES.ResourceManagerError")}(RES||(RES={}));var RES;!function(e){var r;!function(r){function t(e){return r._map[e.type]}function o(e,t){r._map[e]=t}function n(r,t){var o=this;return new Promise(function(n,i){var a=function(){var e=r.data?r.data:r.response;n(e)},s=function(){var r=new e.ResourceManagerError(1001,t.url);i(r)};r.addEventListener(egret.Event.COMPLETE,a,o),r.addEventListener(egret.IOErrorEvent.IO_ERROR,s,o)})}function i(e,r){if(-1!=r.indexOf("://"))return r;e=e.split("\\").join("/");var t=e.match(/#.*|\?.*/),o="";t&&(o=t[0]);var n=e.lastIndexOf("/");return e=-1!=n?e.substring(0,n+1)+r:r,e+o}function a(e){return{name:e.name+"_alpha",url:e.etc1_alpha_url,type:"ktx",root:e.root}}r.isSupport=t,r.map=o,r.getRelativePath=i,r.ImageProcessor={onLoadStart:function(r,t){var o=new egret.ImageLoader;return o.load(e.getVirtualUrl(t.root+t.url)),n(o,t).then(function(e){var o=new egret.Texture;o._setBitmapData(e);var n=r.resourceConfig.getResource(t.name);if(n&&n.scale9grid){var i=n.scale9grid.split(",");o.scale9Grid=new egret.Rectangle(parseInt(i[0]),parseInt(i[1]),parseInt(i[2]),parseInt(i[3]))}return o})},onRemoveStart:function(e,r){var t=e.get(r);t.dispose()}},r.KTXTextureProcessor={onLoadStart:function(e,r){return e.load(r,"bin").then(function(t){if(!t)return console.error("ktx:"+r.root+r.url+" is null"),null;var o=new egret.KTXContainer(t,1);if(o.isInvalid)return console.error("ktx:"+r.root+r.url+" is invalid"),null;var n=new egret.BitmapData(t);n.debugCompressedTextureURL=r.root+r.url,n.format="ktx",o.uploadLevels(n,!1);var i=new egret.Texture;i._setBitmapData(n);var a=e.resourceConfig.getResource(r.name);if(a&&a.scale9grid){var s=a.scale9grid.split(",");i.scale9Grid=new egret.Rectangle(parseInt(s[0]),parseInt(s[1]),parseInt(s[2]),parseInt(s[3]))}return e.save(r,i),i},function(t){throw e.remove(r),t})},onRemoveStart:function(e,r){var t=e.get(r);t&&t.dispose()}},r.makeEtc1SeperatedAlphaResourceInfo=a,r.ETC1KTXProcessor={onLoadStart:function(e,r){return e.load(r,"ktx").then(function(t){if(!t)return null;if(r.etc1_alpha_url){var o=a(r);return e.load(o,"ktx").then(function(r){return t&&t.$bitmapData&&r.$bitmapData?(t.$bitmapData.etcAlphaMask=r.$bitmapData,e.save(o,r)):e.remove(o),t},function(r){throw e.remove(o),r})}return t},function(t){throw e.remove(r),t})},onRemoveStart:function(e,r){var t=e.get(r);if(t&&t.dispose(),r.etc1_alpha_url){var o=a(r),n=e.get(o);n&&n.dispose(),e.unload(o)}}},r.BinaryProcessor={onLoadStart:function(r,t){var o=new egret.HttpRequest;return o.responseType=egret.HttpResponseType.ARRAY_BUFFER,o.open(e.getVirtualUrl(t.root+t.url),"get"),o.send(),n(o,t)},onRemoveStart:function(e,r){}},r.TextProcessor={onLoadStart:function(r,t){var o=new egret.HttpRequest;return o.responseType=egret.HttpResponseType.TEXT,o.open(e.getVirtualUrl(t.root+t.url),"get"),o.send(),n(o,t)},onRemoveStart:function(e,r){return!0}},r.JsonProcessor={onLoadStart:function(e,r){return e.load(r,"text").then(function(e){var r=JSON.parse(e);return r})},onRemoveStart:function(e,r){}},r.XMLProcessor={onLoadStart:function(e,r){return e.load(r,"text").then(function(e){var r=egret.XML.parse(e);return r})},onRemoveStart:function(e,r){return!0}},r.CommonJSProcessor={onLoadStart:function(r,t){return r.load(t,"text").then(function(r){var o=new Function("require","exports",r),n=function(){},i={};try{o(n,i)}catch(a){throw new e.ResourceManagerError(2003,t.name,a.message)}return i})},onRemoveStart:function(e,r){}},r.SheetProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(o){var n=r.resourceConfig.getResource(e.nameSelector(o.file));if(!n){var a=i(t.url,o.file);n={name:a,url:a,type:"image",root:t.root}}return r.load(n).then(function(e){if(!e)return null;var t=o.frames,i=new egret.SpriteSheet(e);i.$resourceInfo=n;for(var a in t){var s=t[a],u=i.createTexture(a,s.x,s.y,s.w,s.h,s.offX,s.offY,s.sourceW,s.sourceH);if(s.scale9grid){var c=s.scale9grid,l=c.split(",");u.scale9Grid=new egret.Rectangle(parseInt(l[0]),parseInt(l[1]),parseInt(l[2]),parseInt(l[3]))}}return r.save(n,e),i},function(e){throw r.remove(n),e})})},getData:function(e,r,t,o){var n=e.get(r);return n?n.getTexture(o):null},onRemoveStart:function(e,r){var t=e.get(r),o=t.$resourceInfo;t.dispose(),e.unload(o)}};var s=function(e,r){var t="",o=r.split("\n"),n=o[2],i=n.indexOf('file="');-1!=i&&(n=n.substring(i+6),i=n.indexOf('"'),t=n.substring(0,i)),e=e.split("\\").join("/");var i=e.lastIndexOf("/");return e=-1!=i?e.substring(0,i+1)+t:t};r.FontProcessor={onLoadStart:function(r,t){return r.load(t,"text").then(function(o){var n;try{n=JSON.parse(o)}catch(a){n=o}var u;u="string"==typeof n?s(t.url,n):i(t.url,n.file);var c=r.resourceConfig.getResource(e.nameSelector(u));return c||(c={name:u,url:u,type:"image",root:t.root}),r.load(c).then(function(e){var t=new egret.BitmapFont(e,n);return t.$resourceInfo=c,r.save(c,e),t},function(e){throw r.remove(c),e})})},onRemoveStart:function(e,r){var t=e.get(r),o=t.$resourceInfo;e.unload(o)}},r.SoundProcessor={onLoadStart:function(r,t){var o=new egret.Sound;return o.load(e.getVirtualUrl(t.root+t.url)),n(o,t).then(function(){return o})},onRemoveStart:function(e,r){var t=e.get(r);t.close()}},r.MovieClipProcessor={onLoadStart:function(r,t){var o,n;return r.load(t,"json").then(function(i){o=i;var a=t.name,s=a.substring(0,a.lastIndexOf("."))+".png";if(n=r.resourceConfig.getResource(s),!n)throw new e.ResourceManagerError(1001,s);return r.load(n)}).then(function(e){r.save(n,e);var t=e,i=new egret.MovieClipDataFactory(o,t);return i})},onRemoveStart:function(e,r){var t=e.get(r);t.clearCache(),t.$spriteSheet.dispose();var o=r.name,n=o.substring(0,o.lastIndexOf("."))+".png",i=e.resourceConfig.getResource(n);i&&e.unload(i)}},r.MergeJSONProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(r){for(var o in r)e.config.addSubkey(o,t.name);return r})},getData:function(e,r,t,o){var n=e.get(r);return n?n[o]:(console.error("missing resource :"+r.name),null)},onRemoveStart:function(e,r){}},r.LegacyResourceConfigProcessor={onLoadStart:function(r,t){return r.load(t,"json").then(function(o){var n=e.config.config,i=t.root,a=n.fileSystem;a||(a={fsData:{},getFile:function(e){return p[e]},addFile:function(e){e.type||(e.type=""),void 0==i&&(e.root=""),p[e.name]=e},profile:function(){console.log(p)},removeFile:function(e){delete p[e]}},n.fileSystem=a);for(var s=n.groups,u=0,c=o.groups;u { - [key: string]: T; - } - /** - * @private - */ - class DragonBones { - static readonly VERSION: string; - static yDown: boolean; - static debug: boolean; - static debugDraw: boolean; - static webAssembly: boolean; - private readonly _clock; - private readonly _events; - private readonly _objects; - private _eventManager; - constructor(eventManager: IEventDispatcher); - advanceTime(passedTime: number): void; - bufferEvent(value: EventObject): void; - bufferObject(object: BaseObject): void; - readonly clock: WorldClock; - readonly eventManager: IEventDispatcher; - } -} - -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The BaseObject is the base class for all objects in the DragonBones framework. - * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 基础对象,通常 DragonBones 的对象都继承自该类。 - * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。 - * @version DragonBones 4.5 - * @language zh_CN - */ - abstract class BaseObject { - private static _hashCode; - private static _defaultMaxCount; - private static readonly _maxCountMap; - private static readonly _poolsMap; - private static _returnObject(object); - static toString(): string; - /** - * - Set the maximum cache count of the specify object pool. - * @param objectConstructor - The specify class. (Set all object pools max cache count if not set) - * @param maxCount - Max count. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 设置特定对象池的最大缓存数量。 - * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量) - * @param maxCount - 最大缓存数量。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; - /** - * - Clear the cached instances of a specify object pool. - * @param objectConstructor - Specify class. (Clear all cached instances if not set) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除特定对象池的缓存实例。 - * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例) - * @version DragonBones 4.5 - * @language zh_CN - */ - static clearPool(objectConstructor?: (typeof BaseObject) | null): void; - /** - * - Get an instance of the specify class from object pool. - * @param objectConstructor - The specify class. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从对象池中获取特定类的实例。 - * @param objectConstructor - 特定的类。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static borrowObject(objectConstructor: { - new (): T; - }): T; - /** - * - A unique identification number assigned to the object. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 分配给此实例的唯一标识号。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly hashCode: number; - private _isInPool; - protected abstract _onClear(): void; - /** - * - Clear the object and return it back to object pool。 - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除该实例的所有数据并将其返还对象池。 - * @version DragonBones 4.5 - * @language zh_CN - */ - returnToPool(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - 2D Transform matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 转换矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Matrix { - /** - * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - a: number; - /** - * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - b: number; - /** - * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - c: number; - /** - * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - d: number; - /** - * - The distance by which to translate each point along the x axis. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 沿 x 轴平移每个点的距离。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - tx: number; - /** - * - The distance by which to translate each point along the y axis. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 沿 y 轴平移每个点的距离。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - ty: number; - /** - * @private - */ - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - toString(): string; - /** - * @private - */ - copyFrom(value: Matrix): Matrix; - /** - * @private - */ - copyFromArray(value: Array, offset?: number): Matrix; - /** - * - Convert to unit matrix. - * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 转换为单位矩阵。 - * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。 - * @version DragonBones 3.0 - * @language zh_CN - */ - identity(): Matrix; - /** - * - Multiplies the current matrix with another matrix. - * @param value - The matrix that needs to be multiplied. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将当前矩阵与另一个矩阵相乘。 - * @param value - 需要相乘的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - concat(value: Matrix): Matrix; - /** - * - Convert to inverse matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 转换为逆矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - invert(): Matrix; - /** - * - Apply a matrix transformation to a specific point. - * @param x - X coordinate. - * @param y - Y coordinate. - * @param result - The point after the transformation is applied. - * @param delta - Whether to ignore tx, ty's conversion to point. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将矩阵转换应用于特定点。 - * @param x - 横坐标。 - * @param y - 纵坐标。 - * @param result - 应用转换之后的点。 - * @param delta - 是否忽略 tx,ty 对点的转换。 - * @version DragonBones 3.0 - * @language zh_CN - */ - transformPoint(x: number, y: number, result: { - x: number; - y: number; - }, delta?: boolean): void; - /** - * @private - */ - transformRectangle(rectangle: { - x: number; - y: number; - width: number; - height: number; - }, delta?: boolean): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - 2D Transform. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 变换。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Transform { - /** - * @private - */ - static readonly PI: number; - /** - * @private - */ - static readonly PI_D: number; - /** - * @private - */ - static readonly PI_H: number; - /** - * @private - */ - static readonly PI_Q: number; - /** - * @private - */ - static readonly RAD_DEG: number; - /** - * @private - */ - static readonly DEG_RAD: number; - /** - * @private - */ - static normalizeRadian(value: number): number; - /** - * - Horizontal translate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 水平位移。 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - Vertical translate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 垂直位移。 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - Skew. (In radians) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 倾斜。 (以弧度为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - skew: number; - /** - * - rotation. (In radians) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转。 (以弧度为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - rotation: number; - /** - * - Horizontal Scaling. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 水平缩放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - scaleX: number; - /** - * - Vertical scaling. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 垂直缩放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - scaleY: number; - /** - * @private - */ - constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); - toString(): string; - /** - * @private - */ - copyFrom(value: Transform): Transform; - /** - * @private - */ - identity(): Transform; - /** - * @private - */ - add(value: Transform): Transform; - /** - * @private - */ - minus(value: Transform): Transform; - /** - * @private - */ - fromMatrix(matrix: Matrix): Transform; - /** - * @private - */ - toMatrix(matrix: Matrix): Transform; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class ColorTransform { - alphaMultiplier: number; - redMultiplier: number; - greenMultiplier: number; - blueMultiplier: number; - alphaOffset: number; - redOffset: number; - greenOffset: number; - blueOffset: number; - constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); - copyFrom(value: ColorTransform): void; - identity(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The Point object represents a location in a two-dimensional coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Point 对象表示二维坐标系统中的某个位置。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Point { - /** - * - The horizontal coordinate. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 该点的水平坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - The vertical coordinate. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 该点的垂直坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @param x - The horizontal coordinate. - * @param y - The vertical coordinate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 - * @param x - 该对象的x属性值,默认为 0.0。 - * @param y - 该对象的y属性值,默认为 0.0。 - * @version DragonBones 3.0 - * @language zh_CN - */ - constructor(x?: number, y?: number); - /** - * @private - */ - copyFrom(value: Point): void; - /** - * @private - */ - clear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its - * width and its height.
- * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of - * one property has no effect on the others. However, the right and bottom properties are integrally related to those - * four properties. For example, if you change the value of the right property, the value of the width property changes; - * if you change the bottom property, the value of the height property changes. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Rectangle { - /** - * - The x coordinate of the top-left corner of the rectangle. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形左上角的 x 坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - The y coordinate of the top-left corner of the rectangle. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形左上角的 y 坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - The width of the rectangle, in pixels. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形的宽度(以像素为单位)。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - width: number; - /** - * - 矩形的高度(以像素为单位)。 - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - The height of the rectangle, in pixels. - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - height: number; - /** - * @private - */ - constructor(x?: number, y?: number, width?: number, height?: number); - /** - * @private - */ - copyFrom(value: Rectangle): void; - /** - * @private - */ - clear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The user custom data. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 用户自定义数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - class UserData extends BaseObject { - static toString(): string; - /** - * - The custom int numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly ints: Array; - /** - * - The custom float numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly floats: Array; - /** - * - The custom strings. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly strings: Array; - protected _onClear(): void; - /** - * @internal - */ - addInt(value: number): void; - /** - * @internal - */ - addFloat(value: number): void; - /** - * @internal - */ - addString(value: string): void; - /** - * - Get the custom int number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getInt(index?: number): number; - /** - * - Get the custom float number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getFloat(index?: number): number; - /** - * - Get the custom string. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getString(index?: number): string; - } - /** - * @internal - */ - class ActionData extends BaseObject { - static toString(): string; - type: ActionType; - name: string; - bone: BoneData | null; - slot: SlotData | null; - data: UserData | null; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The DragonBones data. - * A DragonBones data contains multiple armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 龙骨数据。 - * 一个龙骨数据包含多个骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - class DragonBonesData extends BaseObject { - static toString(): string; - /** - * @private - */ - autoSearch: boolean; - /** - * - The animation frame rate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画帧频。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameRate: number; - /** - * - The data version. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 数据版本。 - * @version DragonBones 3.0 - * @language zh_CN - */ - version: string; - /** - * - The DragonBones data name. - * The name is consistent with the DragonBones project name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 龙骨数据名称。 - * 该名称与龙骨项目名保持一致。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - stage: ArmatureData | null; - /** - * @internal - */ - readonly frameIndices: Array; - /** - * @internal - */ - readonly cachedFrames: Array; - /** - * - All armature data names. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的骨架数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly armatureNames: Array; - /** - * @private - */ - readonly armatures: Map; - /** - * @internal - */ - binary: ArrayBuffer; - /** - * @internal - */ - intArray: Int16Array; - /** - * @internal - */ - floatArray: Float32Array; - /** - * @internal - */ - frameIntArray: Int16Array; - /** - * @internal - */ - frameFloatArray: Float32Array; - /** - * @internal - */ - frameArray: Int16Array; - /** - * @internal - */ - timelineArray: Uint16Array; - /** - * @private - */ - userData: UserData | null; - protected _onClear(): void; - /** - * @internal - */ - addArmature(value: ArmatureData): void; - /** - * - Get a specific armature data. - * @param armatureName - The armature data name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param armatureName - 骨架数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getArmature(armatureName: string): ArmatureData | null; - /** - * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - dispose(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The armature data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class ArmatureData extends BaseObject { - static toString(): string; - /** - * @private - */ - type: ArmatureType; - /** - * - The animation frame rate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画帧率。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameRate: number; - /** - * @private - */ - cacheFrameRate: number; - /** - * @private - */ - scale: number; - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly aabb: Rectangle; - /** - * - The names of all the animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的动画数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animationNames: Array; - /** - * @private - */ - readonly sortedBones: Array; - /** - * @private - */ - readonly sortedSlots: Array; - /** - * @private - */ - readonly defaultActions: Array; - /** - * @private - */ - readonly actions: Array; - /** - * @private - */ - readonly bones: Map; - /** - * @private - */ - readonly slots: Map; - /** - * @private - */ - readonly constraints: Map; - /** - * @private - */ - readonly skins: Map; - /** - * @private - */ - readonly animations: Map; - /** - * - The default skin data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 默认插槽数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - defaultSkin: SkinData | null; - /** - * - The default animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 默认动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - defaultAnimation: AnimationData | null; - /** - * @private - */ - canvas: CanvasData | null; - /** - * @private - */ - userData: UserData | null; - /** - * @private - */ - parent: DragonBonesData; - protected _onClear(): void; - /** - * @internal - */ - sortBones(): void; - /** - * @internal - */ - cacheFrames(frameRate: number): void; - /** - * @internal - */ - setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; - /** - * @internal - */ - getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; - /** - * @internal - */ - addBone(value: BoneData): void; - /** - * @internal - */ - addSlot(value: SlotData): void; - /** - * @internal - */ - addConstraint(value: ConstraintData): void; - /** - * @internal - */ - addSkin(value: SkinData): void; - /** - * @internal - */ - addAnimation(value: AnimationData): void; - /** - * @internal - */ - addAction(value: ActionData, isDefault: boolean): void; - /** - * - Get a specific done data. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼数据。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getBone(boneName: string): BoneData | null; - /** - * - Get a specific slot data. - * @param slotName - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽数据。 - * @param slotName - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlot(slotName: string): SlotData | null; - /** - * @private - */ - getConstraint(constraintName: string): ConstraintData | null; - /** - * - Get a specific skin data. - * @param skinName - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定皮肤数据。 - * @param skinName - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getSkin(skinName: string): SkinData | null; - /** - * @private - */ - getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; - /** - * - Get a specific animation data. - * @param animationName - The animation animationName. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的动画数据。 - * @param animationName - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getAnimation(animationName: string): AnimationData | null; - } - /** - * - The bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class BoneData extends BaseObject { - static toString(): string; - /** - * @private - */ - inheritTranslation: boolean; - /** - * @private - */ - inheritRotation: boolean; - /** - * @private - */ - inheritScale: boolean; - /** - * @private - */ - inheritReflection: boolean; - /** - * @private - */ - type: BoneType; - /** - * - The bone length. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼长度。 - * @version DragonBones 3.0 - * @language zh_CN - */ - length: number; - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly transform: Transform; - /** - * @private - */ - userData: UserData | null; - /** - * - The parent bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 父骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - parent: BoneData | null; - protected _onClear(): void; - } - /** - * @internal - */ - class SurfaceData extends BoneData { - static toString(): string; - segmentX: number; - segmentY: number; - readonly vertices: Array; - protected _onClear(): void; - } - /** - * - The slot data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class SlotData extends BaseObject { - /** - * @internal - */ - static readonly DEFAULT_COLOR: ColorTransform; - /** - * @internal - */ - static createColor(): ColorTransform; - static toString(): string; - /** - * @private - */ - blendMode: BlendMode; - /** - * @private - */ - displayIndex: number; - /** - * @private - */ - zOrder: number; - /** - * - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - color: ColorTransform; - /** - * @private - */ - userData: UserData | null; - /** - * - The parent bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 父骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - parent: BoneData; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class CanvasData extends BaseObject { - static toString(): string; - hasBackground: boolean; - color: number; - x: number; - y: number; - width: number; - height: number; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The skin data, typically a armature data instance contains at least one skinData. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class SkinData extends BaseObject { - static toString(): string; - /** - * - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly displays: Map>; - /** - * @private - */ - parent: ArmatureData; - protected _onClear(): void; - /** - * @internal - */ - addDisplay(slotName: string, value: DisplayData | null): void; - /** - * @private - */ - getDisplay(slotName: string, displayName: string): DisplayData | null; - /** - * @private - */ - getDisplays(slotName: string): Array | null; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - abstract class ConstraintData extends BaseObject { - order: number; - name: string; - type: ConstraintType; - target: BoneData; - root: BoneData; - bone: BoneData | null; - protected _onClear(): void; - } - /** - * @internal - */ - class IKConstraintData extends ConstraintData { - static toString(): string; - scaleEnabled: boolean; - bendPositive: boolean; - weight: number; - protected _onClear(): void; - } - /** - * @internal - */ - class PathConstraintData extends ConstraintData { - static toString(): string; - pathSlot: SlotData; - pathDisplayData: PathDisplayData; - bones: Array; - positionMode: PositionMode; - spacingMode: SpacingMode; - rotateMode: RotateMode; - position: number; - spacing: number; - rotateOffset: number; - rotateMix: number; - translateMix: number; - protected _onClear(): void; - AddBone(value: BoneData): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class VerticesData { - isShared: boolean; - inheritDeform: boolean; - offset: number; - data: DragonBonesData; - weight: WeightData | null; - clear(): void; - shareFrom(value: VerticesData): void; - } - /** - * @internal - */ - abstract class DisplayData extends BaseObject { - type: DisplayType; - name: string; - path: string; - readonly transform: Transform; - parent: SkinData; - protected _onClear(): void; - } - /** - * @internal - */ - class ImageDisplayData extends DisplayData { - static toString(): string; - readonly pivot: Point; - texture: TextureData | null; - protected _onClear(): void; - } - /** - * @internal - */ - class ArmatureDisplayData extends DisplayData { - static toString(): string; - inheritAnimation: boolean; - readonly actions: Array; - armature: ArmatureData | null; - protected _onClear(): void; - /** - * @private - */ - addAction(value: ActionData): void; - } - /** - * @internal - */ - class MeshDisplayData extends DisplayData { - static toString(): string; - readonly vertices: VerticesData; - texture: TextureData | null; - protected _onClear(): void; - } - /** - * @internal - */ - class BoundingBoxDisplayData extends DisplayData { - static toString(): string; - boundingBox: BoundingBoxData | null; - protected _onClear(): void; - } - /** - * @internal - */ - class PathDisplayData extends DisplayData { - static toString(): string; - closed: boolean; - constantSpeed: boolean; - readonly vertices: VerticesData; - readonly curveLengths: Array; - protected _onClear(): void; - } - /** - * @internal - */ - class WeightData extends BaseObject { - static toString(): string; - count: number; - offset: number; - readonly bones: Array; - protected _onClear(): void; - addBone(value: BoneData): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The base class of bounding box data. - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框数据基类。 - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract class BoundingBoxData extends BaseObject { - /** - * - The bounding box type. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框类型。 - * @version DragonBones 5.0 - * @language zh_CN - */ - type: BoundingBoxType; - /** - * @private - */ - color: number; - /** - * @private - */ - width: number; - /** - * @private - */ - height: number; - protected _onClear(): void; - /** - * - Check whether the bounding box contains a specific point. (Local coordinate system) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查边界框是否包含特定点。(本地坐标系) - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract containsPoint(pX: number, pY: number): boolean; - /** - * - Check whether the bounding box intersects a specific segment. (Local coordinate system) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查边界框是否与特定线段相交。(本地坐标系) - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { - x: number; - y: number; - } | null, intersectionPointB: { - x: number; - y: number; - } | null, normalRadians: { - x: number; - y: number; - } | null): number; - } - /** - * - The rectangle bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 矩形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class RectangleBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * - Compute the bit code for a point (x, y) using the clip rectangle - */ - private static _computeOutCode(x, y, xMin, yMin, xMax, yMax); - /** - * @private - */ - static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } - /** - * - The ellipse bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 椭圆边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class EllipseBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * @private - */ - static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } - /** - * - The polygon bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class PolygonBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * @private - */ - static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - /** - * @private - */ - x: number; - /** - * @private - */ - y: number; - /** - * - The polygon vertices. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形顶点。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly vertices: Array; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class AnimationData extends BaseObject { - static toString(): string; - /** - * - FrameIntArray. - * @internal - */ - frameIntOffset: number; - /** - * - FrameFloatArray. - * @internal - */ - frameFloatOffset: number; - /** - * - FrameArray. - * @internal - */ - frameOffset: number; - /** - * - The frame count of the animation. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的帧数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameCount: number; - /** - * - The play times of the animation. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The duration of the animation. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的持续时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - duration: number; - /** - * @private - */ - scale: number; - /** - * - The fade in time of the animation. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的淡入时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - fadeInTime: number; - /** - * @private - */ - cacheFrameRate: number; - /** - * - The animation name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly cachedFrames: Array; - /** - * @private - */ - readonly boneTimelines: Map>; - /** - * @private - */ - readonly surfaceTimelines: Map>; - /** - * @private - */ - readonly slotTimelines: Map>; - /** - * @private - */ - readonly constraintTimelines: Map>; - /** - * @private - */ - readonly animationTimelines: Map>; - /** - * @private - */ - readonly boneCachedFrameIndices: Map>; - /** - * @private - */ - readonly slotCachedFrameIndices: Map>; - /** - * @private - */ - actionTimeline: TimelineData | null; - /** - * @private - */ - zOrderTimeline: TimelineData | null; - /** - * @private - */ - parent: ArmatureData; - protected _onClear(): void; - /** - * @internal - */ - cacheFrames(frameRate: number): void; - /** - * @private - */ - addBoneTimeline(bone: BoneData, timeline: TimelineData): void; - /** - * @private - */ - addSurfaceTimeline(surface: SurfaceData, timeline: TimelineData): void; - /** - * @private - */ - addSlotTimeline(slot: SlotData, timeline: TimelineData): void; - /** - * @private - */ - addConstraintTimeline(constraint: ConstraintData, timeline: TimelineData): void; - /** - * @private - */ - addAnimationTimeline(timelineName: string, timeline: TimelineData): void; - /** - * @private - */ - getBoneTimelines(timelineName: string): Array | null; - /** - * @private - */ - getSurfaceTimelines(timelineName: string): Array | null; - /** - * @private - */ - getSlotTimelines(timelineName: string): Array | null; - /** - * @private - */ - getConstraintTimelines(timelineName: string): Array | null; - /** - * @private - */ - getAnimationTimelines(timelineName: string): Array | null; - /** - * @private - */ - getBoneCachedFrameIndices(boneName: string): Array | null; - /** - * @private - */ - getSlotCachedFrameIndices(slotName: string): Array | null; - } - /** - * @internal - */ - class TimelineData extends BaseObject { - static toString(): string; - type: TimelineType; - offset: number; - frameIndicesOffset: number; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The animation config is used to describe all the information needed to play an animation state. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画配置用来描述播放一个动画状态所需要的全部信息。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - class AnimationConfig extends BaseObject { - static toString(): string; - /** - * @private - */ - pauseFadeOut: boolean; - /** - * - Fade out the pattern of other animation states when the animation state is fade in. - * This property is typically used to specify the substitution of multiple animation states blend. - * @default dragonBones.AnimationFadeOutMode.All - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 淡入动画状态时淡出其他动画状态的模式。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @default dragonBones.AnimationFadeOutMode.All - * @version DragonBones 5.0 - * @language zh_CN - */ - fadeOutMode: AnimationFadeOutMode; - /** - * @private - */ - fadeOutTweenType: TweenType; - /** - * @private - */ - fadeOutTime: number; - /** - * @private - */ - pauseFadeIn: boolean; - /** - * @private - */ - actionEnabled: boolean; - /** - * @private - */ - additiveBlending: boolean; - /** - * - Whether the animation state has control over the display property of the slots. - * Sometimes blend a animation state does not want it to control the display properties of the slots, - * especially if other animation state are controlling the display properties of the slots. - * @default true - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态是否对插槽的显示对象属性有控制权。 - * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, - * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 - * @default true - * @version DragonBones 5.0 - * @language zh_CN - */ - displayControl: boolean; - /** - * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. - * This property should usually be set to false when blend multiple animation states. - * @default true - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 - * 通常在混合多个动画状态时应该将该属性设置为 false。 - * @default true - * @version DragonBones 5.1 - * @language zh_CN - */ - resetToPose: boolean; - /** - * @private - */ - fadeInTweenType: TweenType; - /** - * - The play times. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The blend layer. - * High layer animation state will get the blend weight first. - * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合图层。 - * 图层高的动画状态会优先获取混合权重。 - * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - layer: number; - /** - * - The start time of play. (In seconds) - * @default 0.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 播放的开始时间。 (以秒为单位) - * @default 0.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - position: number; - /** - * - The duration of play. - * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 播放的持续时间。 - * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - duration: number; - /** - * - The play speed. - * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. - * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度。 - * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 - * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - weight: number; - /** - * - The fade in time. - * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 淡入时间。 - * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - fadeInTime: number; - /** - * - The auto fade out time when the animation state play completed. - * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态播放完成后的自动淡出时间。 - * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - autoFadeOutTime: number; - /** - * - The name of the animation state. (Can be different from the name of the animation data) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态名称。 (可以不同于动画数据) - * @version DragonBones 5.0 - * @language zh_CN - */ - name: string; - /** - * - The animation data name. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画数据名称。 - * @version DragonBones 5.0 - * @language zh_CN - */ - animation: string; - /** - * - The blend group name of the animation state. - * This property is typically used to specify the substitution of multiple animation states blend. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合组名称。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - group: string; - /** - * @private - */ - readonly boneMask: Array; - protected _onClear(): void; - /** - * @private - */ - clear(): void; - /** - * @private - */ - copyFrom(value: AnimationConfig): void; - /** - * @private - */ - containsBoneMask(boneName: string): boolean; - /** - * @private - */ - addBoneMask(armature: Armature, boneName: string, recursive?: boolean): void; - /** - * @private - */ - removeBoneMask(armature: Armature, boneName: string, recursive?: boolean): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class TextureAtlasData extends BaseObject { - /** - * @private - */ - autoSearch: boolean; - /** - * @private - */ - width: number; - /** - * @private - */ - height: number; - /** - * @private - */ - scale: number; - /** - * - The texture atlas name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * - The image path of the texture atlas. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集图片路径。 - * @version DragonBones 3.0 - * @language zh_CN - */ - imagePath: string; - /** - * @private - */ - readonly textures: Map; - protected _onClear(): void; - /** - * @private - */ - copyFrom(value: TextureAtlasData): void; - /** - * @internal - */ - abstract createTexture(): TextureData; - /** - * @internal - */ - addTexture(value: TextureData): void; - /** - * @private - */ - getTexture(textureName: string): TextureData | null; - } - /** - * @internal - */ - abstract class TextureData extends BaseObject { - static createRectangle(): Rectangle; - rotated: boolean; - name: string; - readonly region: Rectangle; - parent: TextureAtlasData; - frame: Rectangle | null; - protected _onClear(): void; - copyFrom(value: TextureData): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class DeformVertices extends BaseObject { - static toString(): string; - verticesDirty: boolean; - readonly vertices: Array; - readonly bones: Array; - verticesData: VerticesData | null; - protected _onClear(): void; - init(verticesDataValue: VerticesData | null, armature: Armature): void; - isBonesUpdate(): boolean; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The armature proxy interface, the docking engine needs to implement it concretely. - * @see dragonBones.Armature - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 骨架代理接口,对接的引擎需要对其进行具体实现。 - * @see dragonBones.Armature - * @version DragonBones 5.0 - * @language zh_CN - */ - interface IArmatureProxy extends IEventDispatcher { - /** - * @internal - */ - dbInit(armature: Armature): void; - /** - * @internal - */ - dbClear(): void; - /** - * @internal - */ - dbUpdate(): void; - /** - * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) - * @example - *
-         *     removeChild(armatureDisplay);
-         *     armatureDisplay.dispose();
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 释放该实例和骨架。 (骨架会回收到对象池) - * @example - *
-         *     removeChild(armatureDisplay);
-         *     armatureDisplay.dispose();
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - dispose(disposeProxy: boolean): void; - /** - * - The armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly armature: Armature; - /** - * - The animation player. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animation: Animation; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - Armature is the core of the skeleton animation system. - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架是骨骼动画系统的核心。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - class Armature extends BaseObject implements IAnimatable { - static toString(): string; - private static _onSortSlots(a, b); - /** - * - Whether to inherit the animation control of the parent armature. - * True to try to have the child armature play an animation with the same name when the parent armature play the animation. - * @default true - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 是否继承父骨架的动画控制。 - * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 - * @default true - * @version DragonBones 4.5 - * @language zh_CN - */ - inheritAnimation: boolean; - /** - * @private - */ - userData: any; - private _lockUpdate; - private _slotsDirty; - private _zOrderDirty; - private _flipX; - private _flipY; - /** - * @internal - */ - _cacheFrameIndex: number; - private readonly _bones; - private readonly _slots; - /** - * @internal - */ - readonly _constraints: Array; - private readonly _actions; - /** - * @internal - */ - _armatureData: ArmatureData; - private _animation; - private _proxy; - private _display; - /** - * @internal - */ - _replaceTextureAtlasData: TextureAtlasData | null; - private _replacedTexture; - /** - * @internal - */ - _dragonBones: DragonBones; - private _clock; - /** - * @internal - */ - _parent: Slot | null; - protected _onClear(): void; - /** - * @internal - */ - _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; - /** - * @internal - */ - _addBone(value: Bone): void; - /** - * @internal - */ - _addSlot(value: Slot): void; - /** - * @internal - */ - _addConstraint(value: Constraint): void; - /** - * @internal - */ - _bufferAction(action: EventObject, append: boolean): void; - /** - * - Dispose the armature. (Return to the object pool) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 释放骨架。 (回收到对象池) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - dispose(): void; - /** - * @internal - */ - init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; - /** - * @inheritDoc - */ - advanceTime(passedTime: number): void; - /** - * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. - * @param boneName - The bone name. (If not set, all bones will be update) - * @param updateSlot - Whether to update the bone's slots. (Default: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 - * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) - * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; - /** - * - Check whether a specific point is inside a custom bounding box in a slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在某个插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - containsPoint(x: number, y: number): Slot | null; - /** - * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 - * @version DragonBones 5.0 - * @language zh_CN - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): Slot | null; - /** - * - Get a specific bone. - * @param name - The bone name. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼。 - * @param name - 骨骼名称。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBone(name: string): Bone | null; - /** - * - Get a specific bone by the display. - * @param display - The display object. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的骨骼。 - * @param display - 显示对象。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBoneByDisplay(display: any): Bone | null; - /** - * - Get a specific slot. - * @param name - The slot name. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽。 - * @param name - 插槽名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlot(name: string): Slot | null; - /** - * - Get a specific slot by the display. - * @param display - The display object. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的插槽。 - * @param display - 显示对象。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlotByDisplay(display: any): Slot | null; - /** - * - Get all bones. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBones(): Array; - /** - * - Get all slots. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlots(): Array; - /** - * - Whether to flip the armature horizontally. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架水平翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - flipX: boolean; - /** - * - Whether to flip the armature vertically. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架垂直翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - flipY: boolean; - /** - * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. - * There is a certain amount of memory overhead to improve performance by caching animation data in memory. - * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. - * When the animation cache is turned on, some features will fail, such as the offset property of bone. - * @example - *
-         *     armature.cacheFrameRate = 24;
-         * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 - * @example - *
-         *     armature.cacheFrameRate = 24;
-         * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language zh_CN - */ - cacheFrameRate: number; - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - The armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly armatureData: ArmatureData; - /** - * - The animation player. - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animation: Animation; - /** - * @pivate - */ - readonly proxy: IArmatureProxy; - /** - * - The EventDispatcher instance of the armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架的 EventDispatcher 实例。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly eventDispatcher: IEventDispatcher; - /** - * - The display container. - * The display of the slot is displayed as the parent. - * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 显示容器实例。 - * 插槽的显示对象都会以此显示容器为父级。 - * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly display: any; - /** - * @private - */ - replacedTexture: any; - /** - * @inheritDoc - */ - clock: WorldClock | null; - /** - * - Get the parent slot which the armature belongs to. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架所属的父插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly parent: Slot | null; - /** - * @deprecated - * @private - */ - replaceTexture(texture: any): void; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - hasEventListener(type: EventStringType): boolean; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - addEventListener(type: EventStringType, listener: Function, target: any): void; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - removeEventListener(type: EventStringType, listener: Function, target: any): void; - /** - * - Deprecated, please refer to {@link #cacheFrameRate}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - enableAnimationCache(frameRate: number): void; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - getDisplay(): any; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The base class of the transform object. - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 变换对象的基类。 - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language zh_CN - */ - abstract class TransformObject extends BaseObject { - protected static readonly _helpMatrix: Matrix; - protected static readonly _helpTransform: Transform; - protected static readonly _helpPoint: Point; - /** - * - A matrix relative to the armature coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly globalTransformMatrix: Matrix; - /** - * - A transform relative to the armature coordinate system. - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的变换。 - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly global: Transform; - /** - * - The offset transform relative to the armature or the parent bone coordinate system. - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架或父骨骼坐标系的偏移变换。 - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly offset: Transform; - /** - * @private - */ - origin: Transform | null; - /** - * @private - */ - userData: any; - protected _globalDirty: boolean; - /** - * @internal - */ - _armature: Armature; - /** - */ - protected _onClear(): void; - /** - * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, - * some engines do not rely on these attributes to update rendering, such as Egret. - * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 - * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - updateGlobalTransform(): void; - /** - * - The armature to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的骨架。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly armature: Armature; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - Bone is one of the most important logical units in the armature animation system, - * and is responsible for the realization of translate, rotation, scaling in the animations. - * A armature can contain multiple bones. - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 - * 一个骨架中可以包含多个骨骼。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - class Bone extends TransformObject { - static toString(): string; - /** - * - The offset mode. - * @see #offset - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 偏移模式。 - * @see #offset - * @version DragonBones 5.5 - * @language zh_CN - */ - offsetMode: OffsetMode; - /** - * @internal - */ - readonly animationPose: Transform; - /** - * @internal - */ - _transformDirty: boolean; - /** - * @internal - */ - _childrenTransformDirty: boolean; - protected _localDirty: boolean; - /** - * @internal - */ - _hasConstraint: boolean; - protected _visible: boolean; - protected _cachedFrameIndex: number; - /** - * @internal - */ - readonly _blendState: BlendState; - /** - * @internal - */ - _boneData: BoneData; - /** - * @private - */ - protected _parent: Bone | null; - /** - * @internal - */ - _cachedFrameIndices: Array | null; - protected _onClear(): void; - protected _updateGlobalTransformMatrix(isCache: boolean): void; - /** - * @internal - */ - init(boneData: BoneData, armatureValue: Armature): void; - /** - * @internal - */ - update(cacheFrameIndex: number): void; - /** - * @internal - */ - updateByConstraint(): void; - /** - * - Forces the bone to update the transform in the next frame. - * When the bone is not animated or its animation state is finished, the bone will not continue to update, - * and when the skeleton must be updated for some reason, the method needs to be called explicitly. - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制骨骼在下一帧更新变换。 - * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - invalidUpdate(): void; - /** - * - Check whether the bone contains a specific bone. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查该骨骼是否包含特定的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - contains(value: Bone): boolean; - /** - * - The bone data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly boneData: BoneData; - /** - * - The visible of all slots in the bone. - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 此骨骼所有插槽的可见。 - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language zh_CN - */ - visible: boolean; - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly parent: Bone | null; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。 - * @deprecated - * @language zh_CN - */ - getBones(): Array; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。 - * @deprecated - * @language zh_CN - */ - getSlots(): Array; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。 - * @deprecated - * @language zh_CN - */ - readonly slot: Slot | null; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class Surface extends Bone { - static toString(): string; - private _dX; - private _dY; - private _k; - private _kX; - private _kY; - readonly _vertices: Array; - readonly _deformVertices: Array; - /** - * - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y - */ - private readonly _hullCache; - /** - * - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] - */ - private readonly _matrixCahce; - protected _onClear(): void; - private _getAffineTransform(x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown); - private _updateVertices(); - protected _updateGlobalTransformMatrix(isCache: boolean): void; - _getGlobalTransformMatrix(x: number, y: number): Matrix; - /** - * @internal - * @private - */ - init(surfaceData: SurfaceData, armatureValue: Armature): void; - /** - * @internal - */ - update(cacheFrameIndex: number): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The slot attached to the armature, controls the display status and properties of the display object. - * A bone can contain multiple slots. - * A slot can contain multiple display objects, displaying only one of the display objects at a time, - * but you can toggle the display object into frame animation while the animation is playing. - * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, - * and a custom other display object. - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class Slot extends TransformObject { - /** - * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. - * @default null - * @see dragonBones.AnimationState#displayControl - * @see dragonBones.AnimationState#name - * @see dragonBones.AnimationState#group - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 - * @default null - * @see dragonBones.AnimationState#displayControl - * @see dragonBones.AnimationState#name - * @see dragonBones.AnimationState#group - * @version DragonBones 4.5 - * @language zh_CN - */ - displayController: string | null; - protected _displayDirty: boolean; - protected _zOrderDirty: boolean; - protected _visibleDirty: boolean; - protected _blendModeDirty: boolean; - /** - * @internal - */ - _colorDirty: boolean; - protected _transformDirty: boolean; - protected _visible: boolean; - protected _blendMode: BlendMode; - protected _displayIndex: number; - protected _animationDisplayIndex: number; - /** - * @internal - */ - _zOrder: number; - protected _cachedFrameIndex: number; - /** - * @internal - */ - _pivotX: number; - /** - * @internal - */ - _pivotY: number; - protected readonly _localMatrix: Matrix; - /** - * @internal - */ - readonly _colorTransform: ColorTransform; - protected readonly _displayDatas: Array; - protected readonly _displayList: Array; - /** - * @internal - */ - _slotData: SlotData; - protected _rawDisplayDatas: Array | null; - /** - * @internal - */ - _displayData: DisplayData | null; - protected _boundingBoxData: BoundingBoxData | null; - protected _textureData: TextureData | null; - /** - * @internal - */ - _deformVertices: DeformVertices | null; - protected _rawDisplay: any; - protected _meshDisplay: any; - protected _display: any; - protected _childArmature: Armature | null; - /** - * @private - */ - protected _parent: Bone; - /** - * @internal - */ - _cachedFrameIndices: Array | null; - protected _onClear(): void; - protected abstract _initDisplay(value: any, isRetain: boolean): void; - protected abstract _disposeDisplay(value: any, isRelease: boolean): void; - protected abstract _onUpdateDisplay(): void; - protected abstract _addDisplay(): void; - protected abstract _replaceDisplay(value: any): void; - protected abstract _removeDisplay(): void; - protected abstract _updateZOrder(): void; - /** - * @internal - */ - abstract _updateVisible(): void; - protected abstract _updateBlendMode(): void; - protected abstract _updateColor(): void; - protected abstract _updateFrame(): void; - protected abstract _updateMesh(): void; - /** - * @internal - */ - abstract _updateGlueMesh(): void; - protected abstract _updateTransform(): void; - protected abstract _identityTransform(): void; - /** - * - Support default skin data. - */ - protected _getDefaultRawDisplayData(displayIndex: number): DisplayData | null; - protected _updateDisplayData(): void; - protected _updateDisplay(): void; - protected _updateGlobalTransformMatrix(isCache: boolean): void; - /** - * @internal - */ - _setDisplayIndex(value: number, isAnimation?: boolean): boolean; - /** - * @internal - */ - _setZorder(value: number): boolean; - /** - * @internal - */ - _setColor(value: ColorTransform): boolean; - /** - * @internal - */ - _setDisplayList(value: Array | null): boolean; - /** - * @internal - */ - init(slotData: SlotData, armatureValue: Armature, rawDisplay: any, meshDisplay: any): void; - /** - * @internal - */ - update(cacheFrameIndex: number): void; - /** - * @private - */ - updateTransformAndMatrix(): void; - /** - * @private - */ - replaceDisplayData(value: DisplayData | null, displayIndex?: number): void; - /** - * - Check whether a specific point is inside a custom bounding box in the slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - containsPoint(x: number, y: number): boolean; - /** - * - Check whether a specific segment intersects a custom bounding box for the slot. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] - * @version DragonBones 5.0 - * @language zh_CN - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - /** - * - Forces the slot to update the state of the display object in the next frame. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 强制插槽在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - invalidUpdate(): void; - /** - * - The visible of slot's display object. - * @default true - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 插槽的显示对象的可见。 - * @default true - * @version DragonBones 5.6 - * @language zh_CN - */ - visible: boolean; - /** - * - The index of the display object displayed in the display list. - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     slot.displayIndex = 3;
-         *     slot.displayController = "none";
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 此时显示的显示对象在显示列表中的索引。 - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     slot.displayIndex = 3;
-         *     slot.displayController = "none";
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - displayIndex: number; - /** - * - The slot name. - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - Contains a display list of display objects or child armatures. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 包含显示对象或子骨架的显示列表。 - * @version DragonBones 3.0 - * @language zh_CN - */ - displayList: Array; - /** - * - The slot data. - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly slotData: SlotData; - /** - * @private - */ - rawDisplayDatas: Array | null; - /** - * @private - */ - readonly displayData: DisplayData | null; - /** - * - The custom bounding box data for the slot at current time. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 插槽此时的自定义包围盒数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly boundingBoxData: BoundingBoxData | null; - /** - * @private - */ - readonly rawDisplay: any; - /** - * @private - */ - readonly meshDisplay: any; - /** - * - The display object that the slot displays at this time. - * @example - *
-         *     let slot = armature.getSlot("text");
-         *     slot.display = new yourEngine.TextField();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的显示对象。 - * @example - *
-         *     let slot = armature.getSlot("text");
-         *     slot.display = new yourEngine.TextField();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - display: any; - /** - * - The child armature that the slot displayed at current time. - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         * let prevChildArmature = slot.childArmature;
-         * if (prevChildArmature) {
-         * prevChildArmature.dispose();
-         *     }
-         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的子骨架。 - * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         * let prevChildArmature = slot.childArmature;
-         * if (prevChildArmature) {
-         * prevChildArmature.dispose();
-         *     }
-         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - childArmature: Armature | null; - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly parent: Bone; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - getDisplay(): any; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - setDisplay(value: any): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - abstract class Constraint extends BaseObject { - protected static readonly _helpMatrix: Matrix; - protected static readonly _helpTransform: Transform; - protected static readonly _helpPoint: Point; - /** - * - For timeline state. - * @internal - */ - _constraintData: ConstraintData; - protected _armature: Armature; - /** - * - For sort bones. - * @internal - */ - _target: Bone; - /** - * - For sort bones. - * @internal - */ - _root: Bone; - protected _bone: Bone | null; - protected _onClear(): void; - abstract init(constraintData: ConstraintData, armature: Armature): void; - abstract update(): void; - abstract invalidUpdate(): void; - readonly name: string; - } - /** - * @internal - */ - class IKConstraint extends Constraint { - static toString(): string; - private _scaleEnabled; - /** - * - For timeline state. - * @internal - */ - _bendPositive: boolean; - /** - * - For timeline state. - * @internal - */ - _weight: number; - protected _onClear(): void; - private _computeA(); - private _computeB(); - init(constraintData: ConstraintData, armature: Armature): void; - update(): void; - invalidUpdate(): void; - } - /** - * @internal - */ - class PathConstraint extends Constraint { - dirty: boolean; - pathOffset: number; - position: number; - spacing: number; - rotateOffset: number; - rotateMix: number; - translateMix: number; - private _pathSlot; - private _bones; - private _spaces; - private _positions; - private _curves; - private _boneLengths; - private _pathGlobalVertices; - private _segments; - static toString(): string; - protected _onClear(): void; - protected _updatePathVertices(verticesData: VerticesData): void; - protected _computeVertices(start: number, count: number, offset: number, out: Array): void; - protected _computeBezierCurve(pathDisplayDta: PathDisplayData, spaceCount: number, tangents: boolean, percentPosition: boolean, percentSpacing: boolean): void; - private addCurvePosition(t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents); - init(constraintData: ConstraintData, armature: Armature): void; - update(): void; - invalidUpdate(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - Play animation interface. (Both Armature and Wordclock implement the interface) - * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. - * @see dragonBones.WorldClock - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) - * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 - * @see dragonBones.WorldClock - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - interface IAnimatable { - /** - * - Advance time. - * @param passedTime - Passed time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 更新时间。 - * @param passedTime - 前进的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - advanceTime(passedTime: number): void; - /** - * - The Wordclock instance to which the current belongs. - * @example - *
-         *     armature.clock = factory.clock; // Add armature to clock.
-         *     armature.clock = null; // Remove armature from clock.
-         * 
- * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 当前所属的 WordClock 实例。 - * @example - *
-         *     armature.clock = factory.clock; // 将骨架添加到时钟。
-         *     armature.clock = null; // 将骨架从时钟移除。
-         * 
- * @version DragonBones 5.0 - * @language zh_CN - */ - clock: WorldClock | null; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - class WorldClock implements IAnimatable { - /** - * - Current time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - time: number; - /** - * - The play speed, used to control animation speed-shift play. - * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度,用于控制动画变速播放。 - * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - private _systemTime; - private readonly _animatebles; - private _clock; - /** - * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. - * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 - * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 - * @version DragonBones 3.0 - * @language zh_CN - */ - constructor(time?: number); - /** - * - Advance time for all IAnimatable instances. - * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 为所有的 IAnimatable 实例更新时间。 - * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - advanceTime(passedTime: number): void; - /** - * - Check whether contains a specific instance of IAnimatable. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - contains(value: IAnimatable): boolean; - /** - * - Add IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - add(value: IAnimatable): void; - /** - * - Removes a specified IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - remove(value: IAnimatable): void; - /** - * - Clear all IAnimatable instances. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - clear(): void; - /** - * @inheritDoc - */ - clock: WorldClock | null; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。 - * @deprecated - * @language zh_CN - */ - static readonly clock: WorldClock; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The animation player is used to play the animation data and manage the animation states. - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器用来播放动画数据和管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - class Animation extends BaseObject { - static toString(): string; - /** - * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - private _lockUpdate; - private _animationDirty; - private _inheritTimeScale; - private readonly _animationNames; - private readonly _animationStates; - private readonly _animations; - private _armature; - private _animationConfig; - private _lastAnimationState; - protected _onClear(): void; - private _fadeOut(animationConfig); - /** - * @internal - */ - init(armature: Armature): void; - /** - * @internal - */ - advanceTime(passedTime: number): void; - /** - * - Clear all animations states. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除所有的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - reset(): void; - /** - * - Pause a specific animation state. - * @param animationName - The name of animation state. (If not set, it will pause all animations) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停指定动画状态的播放。 - * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - stop(animationName?: string | null): void; - /** - * - Play animation with a specific animation config. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @param animationConfig - The animation config. - * @returns The playing animation state. - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 通过指定的动画配置来播放动画。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @param animationConfig - 动画配置。 - * @returns 播放的动画状态。 - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - playConfig(animationConfig: AnimationConfig): AnimationState | null; - /** - * - Play a specific animation. - * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) - * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放指定动画。 - * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - play(animationName?: string | null, playTimes?: number): AnimationState | null; - /** - * - Fade in a specific animation. - * @param animationName - The name of animation data. - * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) - * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) - * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) - * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 淡入播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) - * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) - * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; - /** - * - Play a specific animation from the specific time. - * @param animationName - The name of animation data. - * @param time - The start time point of playing. (In seconds) - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定时间开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param time - 播放开始的时间。 (以秒为单位) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; - /** - * - Play a specific animation from the specific frame. - * @param animationName - The name of animation data. - * @param frame - The start frame of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定帧开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param frame - 播放开始的帧数。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; - /** - * - Play a specific animation from the specific progress. - * @param animationName - The name of animation data. - * @param progress - The start progress value of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定进度开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param progress - 开始播放的进度。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific time. - * @param animationName - The name of animation data. - * @param time - The stop time. (In seconds) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定时间停止指定动画播放 - * @param animationName - 动画数据名称。 - * @param time - 停止的时间。 (以秒为单位) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific frame. - * @param animationName - The name of animation data. - * @param frame - The stop frame. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定帧停止指定动画的播放 - * @param animationName - 动画数据名称。 - * @param frame - 停止的帧数。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific progress. - * @param animationName - The name of animation data. - * @param progress - The stop progress value. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定的进度停止指定的动画播放。 - * @param animationName - 动画数据名称。 - * @param progress - 停止进度。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; - /** - * - Get a specific animation state. - * @param animationName - The name of animation state. - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取指定的动画状态 - * @param animationName - 动画状态名称。 - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - getState(animationName: string): AnimationState | null; - /** - * - Check whether a specific animation data is included. - * @param animationName - The name of animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含指定的动画数据 - * @param animationName - 动画数据名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - hasAnimation(animationName: string): boolean; - /** - * - Get all the animation states. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取所有的动画状态 - * @version DragonBones 5.1 - * @language zh_CN - */ - getStates(): Array; - /** - * - Check whether there is an animation state is playing - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否有动画状态正在播放 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isPlaying: boolean; - /** - * - Check whether all the animation states' playing were finished. - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否所有的动画状态均已播放完毕。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isCompleted: boolean; - /** - * - The name of the last playing animation state. - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态名称 - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly lastAnimationName: string; - /** - * - The name of all animation data - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有动画数据的名称 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly animationNames: Array; - /** - * - All animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有的动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - animations: Map; - /** - * - An AnimationConfig instance that can be used quickly. - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 一个可以快速使用的动画配置实例。 - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly animationConfig: AnimationConfig; - /** - * - The last playing animation state - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly lastAnimationState: AnimationState | null; - /** - * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。 - * @deprecated - * @language zh_CN - */ - gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; - /** - * - Deprecated, please refer to {@link #gotoAndStopByTime()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #gotoAndStopByTime()}。 - * @deprecated - * @language zh_CN - */ - gotoAndStop(animationName: string, time?: number): AnimationState | null; - /** - * - Deprecated, please refer to {@link #animationNames}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #animationNames}。 - * @deprecated - * @language zh_CN - */ - readonly animationList: Array; - /** - * - Deprecated, please refer to {@link #animationNames}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #animationNames}。 - * @deprecated - * @language zh_CN - */ - readonly animationDataList: Array; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The animation state is generated when the animation data is played. - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画状态由播放动画数据时产生。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - class AnimationState extends BaseObject { - static toString(): string; - /** - * @private - */ - actionEnabled: boolean; - /** - * @private - */ - additiveBlending: boolean; - /** - * - Whether the animation state has control over the display object properties of the slots. - * Sometimes blend a animation state does not want it to control the display object properties of the slots, - * especially if other animation state are controlling the display object properties of the slots. - * @default true - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态是否对插槽的显示对象属性有控制权。 - * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, - * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 - * @default true - * @version DragonBones 5.0 - * @language zh_CN - */ - displayControl: boolean; - /** - * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. - * This property should usually be set to false when blend multiple animation states. - * @default true - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 - * 通常在混合多个动画状态时应该将该属性设置为 false。 - * @default true - * @version DragonBones 5.1 - * @language zh_CN - */ - resetToPose: boolean; - /** - * - The play times. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The blend layer. - * High layer animation state will get the blend weight first. - * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合图层。 - * 图层高的动画状态会优先获取混合权重。 - * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - layer: number; - /** - * - The play speed. - * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. - * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度。 - * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 - * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - weight: number; - /** - * - The auto fade out time when the animation state play completed. - * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态播放完成后的自动淡出时间。 - * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - autoFadeOutTime: number; - /** - * @private - */ - fadeTotalTime: number; - /** - * - The name of the animation state. (Can be different from the name of the animation data) - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态名称。 (可以不同于动画数据) - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - name: string; - /** - * - The blend group name of the animation state. - * This property is typically used to specify the substitution of multiple animation states blend. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合组名称。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - group: string; - private _timelineDirty; - /** - * - xx: Play Enabled, Fade Play Enabled - * @internal - */ - _playheadState: number; - /** - * -1: Fade in, 0: Fade complete, 1: Fade out; - * @internal - */ - _fadeState: number; - /** - * -1: Fade start, 0: Fading, 1: Fade complete; - * @internal - */ - _subFadeState: number; - /** - * @internal - */ - _position: number; - /** - * @internal - */ - _duration: number; - private _fadeTime; - private _time; - /** - * @internal - */ - _fadeProgress: number; - /** - * @internal - */ - _weightResult: number; - /** - * @internal - */ - readonly _blendState: BlendState; - private readonly _boneMask; - private readonly _boneTimelines; - private readonly _surfaceTimelines; - private readonly _slotTimelines; - private readonly _constraintTimelines; - private readonly _animationTimelines; - private readonly _poseTimelines; - private readonly _bonePoses; - /** - * @internal - */ - _animationData: AnimationData; - private _armature; - /** - * @internal - */ - _actionTimeline: ActionTimelineState; - private _zOrderTimeline; - /** - * @internal - */ - _parent: AnimationState; - protected _onClear(): void; - private _updateTimelines(); - private _updateBoneAndSlotTimelines(); - private _advanceFadeTime(passedTime); - /** - * @internal - */ - init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; - /** - * @internal - */ - advanceTime(passedTime: number, cacheFrameRate: number): void; - /** - * - Continue play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 继续播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - play(): void; - /** - * - Stop play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - stop(): void; - /** - * - Fade out the animation state. - * @param fadeOutTime - The fade out time. (In seconds) - * @param pausePlayhead - Whether to pause the animation playing when fade out. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 淡出动画状态。 - * @param fadeOutTime - 淡出时间。 (以秒为单位) - * @param pausePlayhead - 淡出时是否暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; - /** - * - Check if a specific bone mask is included. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - containsBoneMask(boneName: string): boolean; - /** - * - Add a specific bone mask. - * @param boneName - The bone name. - * @param recursive - Whether or not to add a mask to the bone's sub-bone. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加特定的骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - addBoneMask(boneName: string, recursive?: boolean): void; - /** - * - Remove the mask of a specific bone. - * @param boneName - The bone name. - * @param recursive - Whether to remove the bone's sub-bone mask. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除特定骨骼的遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否删除该骨骼的子骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - removeBoneMask(boneName: string, recursive?: boolean): void; - /** - * - Remove all bone masks. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除所有骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - removeAllBoneMask(): void; - /** - * - Whether the animation state is fading in. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡入。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeIn: boolean; - /** - * - Whether the animation state is fading out. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡出。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeOut: boolean; - /** - * - Whether the animation state is fade completed. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否淡入或淡出完毕。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeComplete: boolean; - /** - * - Whether the animation state is playing. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否正在播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isPlaying: boolean; - /** - * - Whether the animation state is play completed. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否播放完毕。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isCompleted: boolean; - /** - * - The times has been played. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 已经循环播放的次数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly currentPlayTimes: number; - /** - * - The total time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 总播放时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly totalTime: number; - /** - * - The time is currently playing. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前播放的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - currentTime: number; - /** - * - The animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animationData: AnimationData; - } - /** - * @internal - */ - class BonePose extends BaseObject { - static toString(): string; - readonly current: Transform; - readonly delta: Transform; - readonly result: Transform; - protected _onClear(): void; - } - /** - * @internal - */ - class BlendState { - dirty: boolean; - layer: number; - leftWeight: number; - layerWeight: number; - blendWeight: number; - /** - * -1: First blending, 0: No blending, 1: Blending. - */ - update(weight: number, p_layer: number): number; - clear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - const enum TweenState { - None = 0, - Once = 1, - Always = 2, - } - /** - * @internal - */ - abstract class TimelineState extends BaseObject { - /** - * -1: start, 0: play, 1: complete; - */ - playState: number; - currentPlayTimes: number; - currentTime: number; - protected _tweenState: TweenState; - protected _frameRate: number; - protected _frameValueOffset: number; - protected _frameCount: number; - protected _frameOffset: number; - protected _frameIndex: number; - protected _frameRateR: number; - protected _position: number; - protected _duration: number; - protected _timeScale: number; - protected _timeOffset: number; - protected _dragonBonesData: DragonBonesData; - protected _animationData: AnimationData; - protected _timelineData: TimelineData | null; - protected _armature: Armature; - protected _animationState: AnimationState; - protected _actionTimeline: TimelineState; - protected _frameArray: Array | Int16Array; - protected _frameIntArray: Array | Int16Array; - protected _frameFloatArray: Array | Int16Array; - protected _timelineArray: Array | Uint16Array; - protected _frameIndices: Array; - protected _onClear(): void; - protected abstract _onArriveAtFrame(): void; - protected abstract _onUpdateFrame(): void; - protected _setCurrentTime(passedTime: number): boolean; - init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; - fadeOut(): void; - update(passedTime: number): void; - } - /** - * @internal - */ - abstract class TweenTimelineState extends TimelineState { - private static _getEasingValue(tweenType, progress, easing); - private static _getEasingCurveValue(progress, samples, count, offset); - protected _tweenType: TweenType; - protected _curveCount: number; - protected _framePosition: number; - protected _frameDurationR: number; - protected _tweenProgress: number; - protected _tweenEasing: number; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - } - /** - * @internal - */ - abstract class BoneTimelineState extends TweenTimelineState { - bone: Bone; - bonePose: BonePose; - protected _onClear(): void; - blend(state: number): void; - } - /** - * @internal - */ - abstract class SlotTimelineState extends TweenTimelineState { - slot: Slot; - protected _onClear(): void; - } - /** - * @internal - */ - abstract class ConstraintTimelineState extends TweenTimelineState { - constraint: Constraint; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class ActionTimelineState extends TimelineState { - static toString(): string; - private _onCrossFrame(frameIndex); - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - update(passedTime: number): void; - setCurrentTime(value: number): void; - } - /** - * @internal - */ - class ZOrderTimelineState extends TimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - } - /** - * @internal - */ - class BoneAllTimelineState extends BoneTimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - fadeOut(): void; - } - /** - * @internal - */ - class BoneTranslateTimelineState extends BoneTimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - } - /** - * @internal - */ - class BoneRotateTimelineState extends BoneTimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - fadeOut(): void; - } - /** - * @internal - */ - class BoneScaleTimelineState extends BoneTimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - } - /** - * @internal - */ - class SurfaceTimelineState extends TweenTimelineState { - static toString(): string; - surface: Surface; - private _frameFloatOffset; - private _valueCount; - private _deformCount; - private _valueOffset; - private readonly _current; - private readonly _delta; - private readonly _result; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; - blend(state: number): void; - } - /** - * @internal - */ - class SlotDislayTimelineState extends SlotTimelineState { - static toString(): string; - protected _onArriveAtFrame(): void; - } - /** - * @internal - */ - class SlotColorTimelineState extends SlotTimelineState { - static toString(): string; - private _dirty; - private readonly _current; - private readonly _delta; - private readonly _result; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - fadeOut(): void; - update(passedTime: number): void; - } - /** - * @internal - */ - class DeformTimelineState extends SlotTimelineState { - static toString(): string; - vertexOffset: number; - private _dirty; - private _frameFloatOffset; - private _valueCount; - private _deformCount; - private _valueOffset; - private readonly _current; - private readonly _delta; - private readonly _result; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; - fadeOut(): void; - update(passedTime: number): void; - } - /** - * @internal - */ - class IKConstraintTimelineState extends ConstraintTimelineState { - static toString(): string; - private _current; - private _delta; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - } - /** - * @internal - */ - class AnimationTimelineState extends TweenTimelineState { - static toString(): string; - animationState: AnimationState; - private readonly _floats; - protected _onClear(): void; - protected _onArriveAtFrame(): void; - protected _onUpdateFrame(): void; - blend(state: number): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The properties of the object carry basic information about an event, - * which are passed as parameter or parameter's parameter to event listeners when an event occurs. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 - * @version DragonBones 4.5 - * @language zh_CN - */ - class EventObject extends BaseObject { - /** - * - Animation start play. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画开始播放。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly START: string; - /** - * - Animation loop play complete once. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画循环播放完成一次。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly LOOP_COMPLETE: string; - /** - * - Animation play complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画播放完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly COMPLETE: string; - /** - * - Animation fade in start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_IN: string; - /** - * - Animation fade in complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_IN_COMPLETE: string; - /** - * - Animation fade out start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_OUT: string; - /** - * - Animation fade out complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_OUT_COMPLETE: string; - /** - * - Animation frame event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FRAME_EVENT: string; - /** - * - Animation frame sound event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧声音事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly SOUND_EVENT: string; - /** - * @internal - * @private - */ - static actionDataToInstance(data: ActionData, instance: EventObject, armature: Armature): void; - static toString(): string; - /** - * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) - * @version DragonBones 4.5 - * @language zh_CN - */ - time: number; - /** - * - The event type。 - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件类型。 - * @version DragonBones 4.5 - * @language zh_CN - */ - type: EventStringType; - /** - * - The event name. (The frame event name or the frame sound name) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件名称。 (帧事件的名称或帧声音的名称) - * @version DragonBones 4.5 - * @language zh_CN - */ - name: string; - /** - * - The armature that dispatch the event. - * @see dragonBones.Armature - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的骨架。 - * @see dragonBones.Armature - * @version DragonBones 4.5 - * @language zh_CN - */ - armature: Armature; - /** - * - The bone that dispatch the event. - * @see dragonBones.Bone - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 4.5 - * @language zh_CN - */ - bone: Bone | null; - /** - * - The slot that dispatch the event. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - slot: Slot | null; - /** - * - The animation state that dispatch the event. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - animationState: AnimationState; - /** - * @private - */ - actionData: ActionData | null; - /** - * @private - */ - /** - * - The custom data. - * @see dragonBones.CustomData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义数据。 - * @see dragonBones.CustomData - * @version DragonBones 5.0 - * @language zh_CN - */ - data: UserData | null; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @private - */ - type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; - /** - * - The event dispatcher interface. - * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件派发接口。 - * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 - * @version DragonBones 4.5 - * @language zh_CN - */ - interface IEventDispatcher { - /** - * - Checks whether the object has any listeners registered for a specific type of event。 - * @param type - Event type. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 检查是否为特定的事件类型注册了任何侦听器。 - * @param type - 事件类型。 - * @version DragonBones 4.5 - * @language zh_CN - */ - hasDBEventListener(type: EventStringType): boolean; - /** - * - Dispatches an event into the event flow. - * @param type - Event type. - * @param eventObject - Event object. - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 分派特定的事件到事件流中。 - * @param type - 事件类型。 - * @param eventObject - 事件数据。 - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language zh_CN - */ - dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; - /** - * - Add an event listener object so that the listener receives notification of an event. - * @param type - Event type. - * @param listener - Event listener. - * @param thisObject - The listener function's "this". - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 - * @param type - 事件类型。 - * @param listener - 事件侦听器。 - * @param thisObject - 侦听函数绑定的 this 对象。 - * @version DragonBones 4.5 - * @language zh_CN - */ - addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; - /** - * - Removes a listener from the object. - * @param type - Event type. - * @param listener - Event listener. - * @param thisObject - The listener function's "this". - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 删除特定事件类型的侦听器。 - * @param type - 事件类型。 - * @param listener - 事件侦听器。 - * @param thisObject - 侦听函数绑定的 this 对象。 - * @version DragonBones 4.5 - * @language zh_CN - */ - removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; - /** - * - Deprecated, please refer to {@link #hasDBEventListener()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #hasDBEventListener()}。 - * @deprecated - * @language zh_CN - */ - hasEvent(type: EventStringType): boolean; - /** - * - Deprecated, please refer to {@link #addDBEventListener()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #addDBEventListener()}。 - * @deprecated - * @language zh_CN - */ - addEvent(type: EventStringType, listener: Function, thisObject: any): void; - /** - * - Deprecated, please refer to {@link #removeDBEventListener()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #removeDBEventListener()}。 - * @deprecated - * @language zh_CN - */ - removeEvent(type: EventStringType, listener: Function, thisObject: any): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - abstract class DataParser { - protected static readonly DATA_VERSION_2_3: string; - protected static readonly DATA_VERSION_3_0: string; - protected static readonly DATA_VERSION_4_0: string; - protected static readonly DATA_VERSION_4_5: string; - protected static readonly DATA_VERSION_5_0: string; - protected static readonly DATA_VERSION_5_5: string; - protected static readonly DATA_VERSION: string; - protected static readonly DATA_VERSIONS: Array; - protected static readonly TEXTURE_ATLAS: string; - protected static readonly SUB_TEXTURE: string; - protected static readonly FORMAT: string; - protected static readonly IMAGE_PATH: string; - protected static readonly WIDTH: string; - protected static readonly HEIGHT: string; - protected static readonly ROTATED: string; - protected static readonly FRAME_X: string; - protected static readonly FRAME_Y: string; - protected static readonly FRAME_WIDTH: string; - protected static readonly FRAME_HEIGHT: string; - protected static readonly DRADON_BONES: string; - protected static readonly USER_DATA: string; - protected static readonly ARMATURE: string; - protected static readonly BONE: string; - protected static readonly SURFACE: string; - protected static readonly SLOT: string; - protected static readonly CONSTRAINT: string; - protected static readonly IK: string; - protected static readonly PATH_CONSTRAINT: string; - protected static readonly SKIN: string; - protected static readonly DISPLAY: string; - protected static readonly ANIMATION: string; - protected static readonly Z_ORDER: string; - protected static readonly FFD: string; - protected static readonly FRAME: string; - protected static readonly TRANSLATE_FRAME: string; - protected static readonly ROTATE_FRAME: string; - protected static readonly SCALE_FRAME: string; - protected static readonly DISPLAY_FRAME: string; - protected static readonly COLOR_FRAME: string; - protected static readonly DEFAULT_ACTIONS: string; - protected static readonly ACTIONS: string; - protected static readonly EVENTS: string; - protected static readonly INTS: string; - protected static readonly FLOATS: string; - protected static readonly STRINGS: string; - protected static readonly CANVAS: string; - protected static readonly TRANSFORM: string; - protected static readonly PIVOT: string; - protected static readonly AABB: string; - protected static readonly COLOR: string; - protected static readonly VERSION: string; - protected static readonly COMPATIBLE_VERSION: string; - protected static readonly FRAME_RATE: string; - protected static readonly TYPE: string; - protected static readonly SUB_TYPE: string; - protected static readonly NAME: string; - protected static readonly PARENT: string; - protected static readonly TARGET: string; - protected static readonly STAGE: string; - protected static readonly SHARE: string; - protected static readonly PATH: string; - protected static readonly LENGTH: string; - protected static readonly DISPLAY_INDEX: string; - protected static readonly BLEND_MODE: string; - protected static readonly INHERIT_TRANSLATION: string; - protected static readonly INHERIT_ROTATION: string; - protected static readonly INHERIT_SCALE: string; - protected static readonly INHERIT_REFLECTION: string; - protected static readonly INHERIT_ANIMATION: string; - protected static readonly INHERIT_DEFORM: string; - protected static readonly SEGMENT_X: string; - protected static readonly SEGMENT_Y: string; - protected static readonly BEND_POSITIVE: string; - protected static readonly CHAIN: string; - protected static readonly WEIGHT: string; - protected static readonly FADE_IN_TIME: string; - protected static readonly PLAY_TIMES: string; - protected static readonly SCALE: string; - protected static readonly OFFSET: string; - protected static readonly POSITION: string; - protected static readonly DURATION: string; - protected static readonly TWEEN_EASING: string; - protected static readonly TWEEN_ROTATE: string; - protected static readonly TWEEN_SCALE: string; - protected static readonly CLOCK_WISE: string; - protected static readonly CURVE: string; - protected static readonly SOUND: string; - protected static readonly EVENT: string; - protected static readonly ACTION: string; - protected static readonly X: string; - protected static readonly Y: string; - protected static readonly SKEW_X: string; - protected static readonly SKEW_Y: string; - protected static readonly SCALE_X: string; - protected static readonly SCALE_Y: string; - protected static readonly VALUE: string; - protected static readonly ROTATE: string; - protected static readonly SKEW: string; - protected static readonly ALPHA_OFFSET: string; - protected static readonly RED_OFFSET: string; - protected static readonly GREEN_OFFSET: string; - protected static readonly BLUE_OFFSET: string; - protected static readonly ALPHA_MULTIPLIER: string; - protected static readonly RED_MULTIPLIER: string; - protected static readonly GREEN_MULTIPLIER: string; - protected static readonly BLUE_MULTIPLIER: string; - protected static readonly UVS: string; - protected static readonly VERTICES: string; - protected static readonly TRIANGLES: string; - protected static readonly WEIGHTS: string; - protected static readonly SLOT_POSE: string; - protected static readonly BONE_POSE: string; - protected static readonly GLUE_WEIGHTS: string; - protected static readonly GLUE_MESHES: string; - protected static readonly BONES: string; - protected static readonly POSITION_MODE: string; - protected static readonly SPACING_MODE: string; - protected static readonly ROTATE_MODE: string; - protected static readonly SPACING: string; - protected static readonly ROTATE_OFFSET: string; - protected static readonly ROTATE_MIX: string; - protected static readonly TRANSLATE_MIX: string; - protected static readonly TARGET_DISPLAY: string; - protected static readonly CLOSED: string; - protected static readonly CONSTANT_SPEED: string; - protected static readonly VERTEX_COUNT: string; - protected static readonly LENGTHS: string; - protected static readonly GOTO_AND_PLAY: string; - protected static readonly DEFAULT_NAME: string; - protected static _getArmatureType(value: string): ArmatureType; - protected static _getBoneType(value: string): BoneType; - protected static _getDisplayType(value: string): DisplayType; - protected static _getBoundingBoxType(value: string): BoundingBoxType; - protected static _getActionType(value: string): ActionType; - protected static _getBlendMode(value: string): BlendMode; - protected static _getPositionMode(value: string): PositionMode; - protected static _getSpacingMode(value: string): SpacingMode; - protected static _getRotateMode(value: string): RotateMode; - abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; - abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - static parseDragonBonesData(rawData: any): DragonBonesData | null; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - static parseTextureAtlasData(rawData: any, scale?: number): any; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class ObjectDataParser extends DataParser { - protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; - protected static _getNumber(rawData: any, key: string, defaultValue: number): number; - protected static _getString(rawData: any, key: string, defaultValue: string): string; - protected _rawTextureAtlasIndex: number; - protected readonly _rawBones: Array; - protected _data: DragonBonesData; - protected _armature: ArmatureData; - protected _bone: BoneData; - protected _surface: SurfaceData; - protected _slot: SlotData; - protected _skin: SkinData; - protected _mesh: MeshDisplayData; - protected _animation: AnimationData; - protected _timeline: TimelineData; - protected _rawTextureAtlases: Array | null; - private _defaultColorOffset; - private _prevClockwise; - private _prevRotation; - private readonly _helpMatrixA; - private readonly _helpMatrixB; - private readonly _helpTransform; - private readonly _helpColorTransform; - private readonly _helpPoint; - private readonly _helpArray; - private readonly _intArray; - private readonly _floatArray; - private readonly _frameIntArray; - private readonly _frameFloatArray; - private readonly _frameArray; - private readonly _timelineArray; - private readonly _cacheRawMeshes; - private readonly _cacheMeshes; - private readonly _actionFrames; - private readonly _weightSlotPose; - private readonly _weightBonePoses; - private readonly _cacheBones; - private readonly _slotChildActions; - private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); - private _samplingEasingCurve(curve, samples); - private _parseActionDataInFrame(rawData, frameStart, bone, slot); - private _mergeActionFrame(rawData, frameStart, type, bone, slot); - protected _parseArmature(rawData: any, scale: number): ArmatureData; - protected _parseBone(rawData: any): BoneData; - protected _parseIKConstraint(rawData: any): ConstraintData | null; - protected _parsePathConstraint(rawData: any): ConstraintData | null; - protected _parseSlot(rawData: any, zOrder: number): SlotData; - protected _parseSkin(rawData: any): SkinData; - protected _parseDisplay(rawData: any): DisplayData | null; - protected _parsePath(rawData: any, display: PathDisplayData): void; - protected _parsePivot(rawData: any, display: ImageDisplayData): void; - protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; - protected _parseMeshGlue(rawData: any, mesh: MeshDisplayData): void; - protected _parseBoundingBox(rawData: any): BoundingBoxData | null; - protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; - protected _parseAnimation(rawData: any): AnimationData; - protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; - protected _parseBoneTimeline(rawData: any): void; - protected _parseSlotTimeline(rawData: any): void; - protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; - protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSurfaceFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; - protected _parseTransform(rawData: any, transform: Transform, scale: number): void; - protected _parseColorTransform(rawData: any, color: ColorTransform): void; - protected _parseArray(rawData: any): void; - protected _modifyArray(): void; - parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; - parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; - private static _objectDataParserInstance; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - static getInstance(): ObjectDataParser; - } - /** - * @internal - */ - class ActionFrame { - frameStart: number; - readonly actions: Array; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - class BinaryDataParser extends ObjectDataParser { - private _binaryOffset; - private _binary; - private _intArrayBuffer; - private _floatArrayBuffer; - private _frameIntArrayBuffer; - private _frameFloatArrayBuffer; - private _frameArrayBuffer; - private _timelineArrayBuffer; - private _inRange(a, min, max); - private _decodeUTF8(data); - private _getUTF16Key(value); - private _parseBinaryTimeline(type, offset, timelineData?); - private _parseVertices(rawData, vertices); - protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; - protected _parsePath(rawData: any, path: PathDisplayData): void; - protected _parseAnimation(rawData: any): AnimationData; - protected _parseArray(rawData: any): void; - parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; - private static _binaryDataParserInstance; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - static getInstance(): BinaryDataParser; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) - * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. - * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) - * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 - * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class BaseFactory { - protected static _objectParser: ObjectDataParser; - protected static _binaryParser: BinaryDataParser; - /** - * @private - */ - autoSearch: boolean; - protected readonly _dragonBonesDataMap: Map; - protected readonly _textureAtlasDataMap: Map>; - protected _dragonBones: DragonBones; - protected _dataParser: DataParser; - /** - * - Create a factory instance. (typically only one global factory instance is required) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) - * @version DragonBones 3.0 - * @language zh_CN - */ - constructor(dataParser?: DataParser | null); - protected _isSupportMesh(): boolean; - protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; - protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; - protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; - /** - * @private - */ - protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; - protected _buildConstraints(dataPackage: BuildArmaturePackage, armature: Armature): void; - protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null; - protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; - protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; - protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; - protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; - /** - * - Parse the raw data to a DragonBonesData instance and cache it to the factory. - * @param rawData - The raw data. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for all armatures. (Default: 1.0) - * @returns DragonBonesData instance - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 - * @param rawData - 原始数据。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) - * @returns DragonBonesData 实例 - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language zh_CN - */ - parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; - /** - * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. - * @param rawData - The raw texture atlas data. - * @param textureAtlas - The texture atlas object. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for the map set. (Default: 1.0) - * @returns TextureAtlasData instance - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 - * @param rawData - 原始贴图集数据。 - * @param textureAtlas - 贴图集对象。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) - * @returns TextureAtlasData 实例 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language zh_CN - */ - parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; - /** - * @private - */ - updateTextureAtlasData(name: string, textureAtlases: Array): void; - /** - * - Get a specific DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @returns DragonBonesData instance - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 DragonBonesData 实例。 - * @param name - DragonBonesData 实例的缓存名称。 - * @returns DragonBonesData 实例 - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - getDragonBonesData(name: string): DragonBonesData | null; - /** - * - Cache a DragonBonesData instance to the factory. - * @param data - The DragonBonesData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 DragonBonesData 实例缓存到工厂中。 - * @param data - DragonBonesData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - addDragonBonesData(data: DragonBonesData, name?: string | null): void; - /** - * - Remove a DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @param disposeData - Whether to dispose data. (Default: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 DragonBonesData 实例。 - * @param name - DragonBonesData 实例缓存名称。 - * @param disposeData - 是否释放数据。 (默认: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - removeDragonBonesData(name: string, disposeData?: boolean): void; - /** - * - Get a list of specific TextureAtlasData instances. - * @param name - The TextureAtlasData cahce name. - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 TextureAtlasData 实例列表。 - * @param name - TextureAtlasData 实例缓存名称。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - getTextureAtlasData(name: string): Array | null; - /** - * - Cache a TextureAtlasData instance to the factory. - * @param data - The TextureAtlasData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 TextureAtlasData 实例缓存到工厂中。 - * @param data - TextureAtlasData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; - /** - * - Remove a TextureAtlasData instance. - * @param name - The TextureAtlasData instance cache name. - * @param disposeData - Whether to dispose data. - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 TextureAtlasData 实例。 - * @param name - TextureAtlasData 实例的缓存名称。 - * @param disposeData - 是否释放数据。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - removeTextureAtlasData(name: string, disposeData?: boolean): void; - /** - * - Get a specific armature data. - * @param name - The armature data name. - * @param dragonBonesName - The cached name for DragonbonesData instance. - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param name - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language zh_CN - */ - getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; - /** - * - Clear all cached DragonBonesData instances and TextureAtlasData instances. - * @param disposeData - Whether to dispose data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 - * @param disposeData - 是否释放数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - clear(disposeData?: boolean): void; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. - * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature. - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 - * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架。 - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; - /** - * @private - */ - replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: number): void; - /** - * - Replaces the current display data for a particular slot with a specific display data. - * Specify display data with "dragonBonesName/armatureName/slotName/displayName". - * @param dragonBonesName - The DragonBonesData instance cache name. - * @param armatureName - The armature data name. - * @param slotName - The slot data name. - * @param displayName - The display data name. - * @param slot - The slot. - * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 - * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @param armatureName - 骨架数据名称。 - * @param slotName - 插槽数据名称。 - * @param displayName - 显示对象数据名称。 - * @param slot - 插槽。 - * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; - /** - * @private - */ - replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; - /** - * - Share specific skin data with specific armature. - * @param armature - The armature. - * @param skin - The skin data. - * @param isOverride - Whether it completely override the original skin. (Default: false) - * @param exclude - A list of slot names that do not need to be replace. - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 将特定的皮肤数据共享给特定的骨架使用。 - * @param armature - 骨架。 - * @param skin - 皮肤数据。 - * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) - * @param exclude - 不需要被替换的插槽名称列表。 - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language zh_CN - */ - replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; - /** - * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. - * This enables you to make a armature template so that other armature without animations can share it's animations. - * @param armature - The armtaure. - * @param armatureData - The armature data. - * @param isOverride - Whether to completely overwrite the original animation. (Default: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 - * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 - * @param armature - 骨架。 - * @param armatureData - 骨架数据。 - * @param isOverride - 是否完全覆盖原来的动画。(默认: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language zh_CN - */ - replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; - /** - * @private - */ - getAllDragonBonesData(): Map; - /** - * @private - */ - getAllTextureAtlasData(): Map>; - /** - * - An Worldclock instance updated by engine. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 由引擎驱动的 WorldClock 实例。 - * @version DragonBones 5.7 - * @language zh_CN - */ - readonly clock: WorldClock; - /** - * @private - */ - readonly dragonBones: DragonBones; - /** - * - Deprecated, please refer to {@link #replaceSkin}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #replaceSkin}。 - * @deprecated - * @language zh_CN - */ - changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): boolean; - /** - * - Deprecated, please refer to {@link #replaceAnimation}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #replaceAnimation}。 - * @deprecated - * @language zh_CN - */ - copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, replaceOriginalAnimation?: boolean): boolean; - } - /** - * @internal - */ - class BuildArmaturePackage { - dataName: string; - textureAtlasName: string; - data: DragonBonesData; - armature: ArmatureData; - skin: SkinData | null; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The egret texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class EgretTextureAtlasData extends TextureAtlasData { - static toString(): string; - /** - * @internal - */ - disposeEnabled: boolean; - private _renderTexture; - protected _onClear(): void; - /** - * @inheritDoc - */ - createTexture(): TextureData; - /** - * - The Egret texture. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 贴图。 - * @version DragonBones 3.0 - * @language zh_CN - */ - renderTexture: egret.Texture | null; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#removeTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#removeTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - dispose(): void; - /** - * - Deprecated, please refer to {@link #renderTexture}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #renderTexture}。 - * @deprecated - * @language zh_CN - */ - readonly texture: egret.Texture | null; - } - /** - * @internal - */ - class EgretTextureData extends TextureData { - static toString(): string; - renderTexture: egret.Texture | null; - protected _onClear(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The egret event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - Egret 事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - class EgretEvent extends egret.Event { - /** - * - The event object. - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象。 - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly eventObject: EventObject; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - readonly animationName: string; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#armature}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#armature}。 - * @deprecated - * @language zh_CN - */ - readonly armature: Armature; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#bone}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#bone}。 - * @deprecated - * @language zh_CN - */ - readonly bone: Bone | null; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#slot}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#slot}。 - * @deprecated - * @language zh_CN - */ - readonly slot: Slot | null; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - readonly animationState: AnimationState | null; - /** - * Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#name}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#name}。 - * @deprecated - * @language zh_CN - */ - readonly frameLabel: string; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#name}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#name}。 - * @deprecated - * @language zh_CN - */ - readonly sound: string; - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - readonly movementID: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.START}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.START}。 - * @deprecated - * @language zh_CN - */ - static START: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.LOOP_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.LOOP_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - static LOOP_COMPLETE: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.COMPLETE}。 - * @deprecated - * @language zh_CN - */ - static COMPLETE: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_IN}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_IN}。 - * @deprecated - * @language zh_CN - */ - static FADE_IN: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_IN_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_IN_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - static FADE_IN_COMPLETE: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_OUT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_OUT}。 - * @deprecated - * @language zh_CN - */ - static FADE_OUT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_OUT_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_OUT_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - static FADE_OUT_COMPLETE: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - static FRAME_EVENT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.SOUND_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.SOUND_EVENT}。 - * @deprecated - * @language zh_CN - */ - static SOUND_EVENT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - static ANIMATION_FRAME_EVENT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - static BONE_FRAME_EVENT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - static MOVEMENT_FRAME_EVENT: string; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.SOUND_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.SOUND_EVENT}。 - * @deprecated - * @language zh_CN - */ - static SOUND: string; - } - /** - * @inheritDoc - */ - class EgretArmatureDisplay extends egret.DisplayObjectContainer implements IArmatureProxy { - private static _cleanBeforeRender(); - /** - * @private - */ - debugDraw: boolean; - /** - * @internal - */ - _batchEnabled: boolean; - /** - * @internal - */ - _childDirty: boolean; - private _debugDraw; - private _armature; - private _bounds; - private _debugDrawer; - /** - * @inheritDoc - */ - dbInit(armature: Armature): void; - /** - * @inheritDoc - */ - dbClear(): void; - /** - * @inheritDoc - */ - dbUpdate(): void; - /** - * @inheritDoc - */ - dispose(disposeProxy?: boolean): void; - /** - * @inheritDoc - */ - dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; - /** - * @inheritDoc - */ - hasDBEventListener(type: EventStringType): boolean; - /** - * @inheritDoc - */ - addDBEventListener(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; - /** - * @inheritDoc - */ - removeDBEventListener(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; - /** - * - Disable the batch. - * Batch rendering for performance reasons, the boundary properties of the render object are not updated. - * This will not correctly obtain the wide-height properties of the rendered object and the transformation properties of its internal display objects, - * which can turn off batch rendering if you need to use these properties. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 关闭批次渲染。 - * 批次渲染出于性能考虑,不会更新渲染对象的边界属性。 - * 这样将无法正确获得渲染对象的宽高属性以及其内部显示对象的变换属性,如果需要使用这些属性,可以关闭批次渲染。 - * @version DragonBones 5.1 - * @language zh_CN - */ - disableBatch(): void; - /** - * @inheritDoc - */ - readonly armature: Armature; - /** - * @inheritDoc - */ - readonly animation: Animation; - /** - * @inheritDoc - */ - $measureContentBounds(bounds: egret.Rectangle): void; - /** - * @inheritDoc - */ - hasEvent(type: EventStringType): boolean; - /** - * @inheritDoc - */ - addEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; - /** - * @inheritDoc - */ - removeEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#clock} {@link dragonBones.BaseFactory#clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#clock} {@link dragonBones.BaseFactory#clock}。 - * @deprecated - * @language zh_CN - */ - advanceTimeBySelf(on: boolean): void; - } - /** - * 已废弃,请参考 {@link dragonBones.Armature}。 - * @deprecated - * @language zh_CN - */ - type FastArmature = Armature; - /** - * 已废弃,请参考 {@link dragonBones.Bone}。 - * @deprecated - * @language zh_CN - */ - type FastBone = Bone; - /** - * 已废弃,请参考 {@link dragonBones.Slot}。 - * @deprecated - * @language zh_CN - */ - type FastSlot = Slot; - /** - * 已废弃,请参考 {@link dragonBones.Animation}。 - * @deprecated - * @language zh_CN - */ - type FastAnimation = Animation; - /** - * 已废弃,请参考 {@link dragonBones.AnimationState}。 - * @deprecated - * @language zh_CN - */ - type FastAnimationState = AnimationState; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - class Event extends EgretEvent { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - class ArmatureEvent extends EgretEvent { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - class AnimationEvent extends EgretEvent { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - class FrameEvent extends EgretEvent { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - class SoundEvent extends EgretEvent { - } - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - class EgretTextureAtlas extends EgretTextureAtlasData { - static toString(): string; - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - constructor(texture: egret.Texture, rawData: any, scale?: number); - } - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - class EgretSheetAtlas extends EgretTextureAtlas { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretFactory#soundEventManager}。 - * @deprecated - * @language zh_CN - */ - class SoundEventManager { - /** - * 已废弃,请参考 {@link dragonBones.EgretFactory#soundEventManager}。 - * @deprecated - * @language zh_CN - */ - static getInstance(): EgretArmatureDisplay; - } - /** - * 已废弃,请参考 {@link dragonBones.Armature#cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - class AnimationCacheManager { - /** - * 已废弃,请参考 {@link dragonBones.Armature#cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - constructor(); - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * - The egret slot. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 插槽。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class EgretSlot extends Slot { - static toString(): string; - /** - * - Whether to update the transform properties of the display object. - * For better performance, the transform properties of display object (x, y, rotation, ScaleX, ScaleX) are not updated and need to be set to true if these properties need to be accessed correctly. - * @default false - * @version DragonBones 3.0 - * @language zh_CN - */ - /** - * - 是否更新显示对象的变换属性。 - * 为了更好的性能, 默认并不会更新显示对象的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 - * @default false - * @version DragonBones 3.0 - * @language zh_CN - */ - transformUpdateEnabled: boolean; - private _armatureDisplay; - private _renderDisplay; - private _colorFilter; - /** - * @inheritDoc - */ - init(slotData: SlotData, armatureValue: Armature, rawDisplay: any, meshDisplay: any): void; - protected _onClear(): void; - protected _initDisplay(value: any, isRetain: boolean): void; - protected _disposeDisplay(value: any, isRelease: boolean): void; - protected _onUpdateDisplay(): void; - protected _addDisplay(): void; - protected _replaceDisplay(value: any): void; - protected _removeDisplay(): void; - protected _updateZOrder(): void; - /** - * @internal - */ - _updateVisible(): void; - protected _updateBlendMode(): void; - protected _updateColor(): void; - protected _updateFrame(): void; - protected _updateMesh(): void; - /** - * @internal - */ - _updateGlueMesh(): void; - protected _updateTransform(): void; - protected _identityTransform(): void; - private _updateTransformV4(); - private _updateTransformV5(); - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare namespace dragonBones { - /** - * @internal - */ - const isV5: boolean; - /** - * - The Egret factory. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 工厂。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class EgretFactory extends BaseFactory { - private static _time; - private static _dragonBonesInstance; - private static _factory; - private static _clockHandler(time); - /** - * - A global factory instance that can be used directly. - * @version DragonBones 4.7 - * @language en_US - */ - /** - * - 一个可以直接使用的全局工厂实例。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static readonly factory: EgretFactory; - /** - * @inheritDoc - */ - constructor(dataParser?: DataParser | null); - protected _isSupportMesh(): boolean; - protected _buildTextureAtlasData(textureAtlasData: EgretTextureAtlasData | null, textureAtlas: egret.Texture | HTMLImageElement | null): EgretTextureAtlasData; - protected _buildArmature(dataPackage: BuildArmaturePackage): Armature; - protected _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. - * Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. - * The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature display container. - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - *
-         *     let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
-         * 
- * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架,并用 {@link #clock} 更新该骨架。 - * 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 - * 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架的显示容器。 - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - *
-         *     let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
-         * 
- * @language zh_CN - */ - buildArmatureDisplay(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): EgretArmatureDisplay | null; - /** - * - Create the display object with the specified texture. - * @param textureName - The texture data name. - * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建带有指定贴图的显示对象。 - * @param textureName - 贴图数据名称。 - * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) - * @version DragonBones 3.0 - * @language zh_CN - */ - getTextureDisplay(textureName: string, textureAtlasName?: string | null): egret.Bitmap | null; - /** - * - A global sound event manager. - * Sound events can be listened to uniformly from the manager. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 全局声音事件管理器。 - * 声音事件可以从该管理器统一侦听。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly soundEventManager: EgretArmatureDisplay; - /** - * - Deprecated, please refer to {@link #clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #clock}。 - * @deprecated - * @language zh_CN - */ - static readonly clock: WorldClock; - /** - * - Deprecated, please refer to {@link #addDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #addDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - addSkeletonData(dragonBonesData: DragonBonesData, dragonBonesName?: string | null): void; - /** - * - Deprecated, please refer to {@link #getDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #getDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - getSkeletonData(dragonBonesName: string): DragonBonesData | null; - /** - * - Deprecated, please refer to {@link #removeDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #removeDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - removeSkeletonData(dragonBonesName: string): void; - /** - * - Deprecated, please refer to {@link #addTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #addTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - addTextureAtlas(textureAtlasData: TextureAtlasData, dragonBonesName?: string | null): void; - /** - * - Deprecated, please refer to {@link #getTextureAtlas()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #getTextureAtlas()}。 - * @deprecated - * @language zh_CN - */ - getTextureAtlas(dragonBonesName: string): TextureAtlasData[] | null; - /** - * - Deprecated, please refer to {@link #removeTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #removeTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - removeTextureAtlas(dragonBonesName: string): void; - /** - * - Deprecated, please refer to {@link #buildArmature()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #buildArmature()}。 - * @deprecated - * @language zh_CN - */ - buildFastArmature(armatureName: string, dragonBonesName?: string, skinName?: string): FastArmature | null; - /** - * - Deprecated, please refer to {@link #clear()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #clear()}。 - * @deprecated - * @language zh_CN - */ - dispose(): void; - } -} -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -declare const _super: any; -declare namespace dragonBones { - /** - * 是否包含指定名称的动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function hasMovieGroup(groupName: string): boolean; - /** - * 添加动画组。 - * @param groupData 动画二进制数据。 - * @param textureAtlas 贴图集或贴图集列表。 - * @param groupName 为动画组指定一个名称,如果未设置,则使用数据中的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function addMovieGroup(groupData: ArrayBuffer, textureAtlas: egret.Texture | egret.Texture[], groupName?: string | null): void; - /** - * 移除动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function removeMovieGroup(groupName: string): void; - /** - * 移除所有的动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function removeAllMovieGroup(): void; - /** - * 创建一个动画。 - * @param movieName 动画的名称。 - * @param groupName 动画组的名称,如果未设置,将检索所有的动画组,当多个动画组中包含同名的动画时,可能无法创建出准确的动画。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function buildMovie(movieName: string, groupName?: string | null): Movie | null; - /** - * 获取指定动画组内包含的所有动画名称。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function getMovieNames(groupName: string): string[] | null; - /** - * 动画事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - class MovieEvent extends egret.Event { - /** - * 动画剪辑开始播放。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static START: string; - /** - * 动画剪辑循环播放一次完成。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static LOOP_COMPLETE: string; - /** - * 动画剪辑播放完成。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static COMPLETE: string; - /** - * 动画剪辑帧事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static FRAME_EVENT: string; - /** - * 动画剪辑声音事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static SOUND_EVENT: string; - /** - * 事件名称。 (帧标签的名称或声音的名称) - * @version DragonBones 4.7 - * @language zh_CN - */ - name: string; - /** - * 发出事件的插槽名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - slotName: string; - /** - * 发出事件的动画剪辑名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - clipName: string; - /** - * 发出事件的动画。 - * @version DragonBones 4.7 - * @language zh_CN - */ - movie: Movie; - /** - * @private - */ - constructor(type: string); - /** - * @private - */ - readonly armature: any; - /** - * @private - */ - readonly bone: any; - /** - * @private - */ - readonly animationState: any; - /** - * @private - */ - readonly frameLabel: any; - /** - * @private - */ - readonly movementID: any; - } - /** - * 通过读取缓存的二进制动画数据来更新动画,具有良好的运行性能,同时对内存的占用也非常低。 - * @see dragonBones.buildMovie - * @version DragonBones 4.7 - * @language zh_CN - */ - class Movie extends egret.DisplayObjectContainer implements IAnimatable { - private static _cleanBeforeRender(); - /** - * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1 - * @version DragonBones 4.7 - * @language zh_CN - */ - timeScale: number; - /** - * 动画剪辑的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * (当再次播放其他动画剪辑时,此值将被重置为 1) - * @default 1 - * @version DragonBones 4.7 - * @language zh_CN - */ - clipTimeScale: number; - private _batchEnabled; - private _isLockDispose; - private _isDelayDispose; - private _isStarted; - private _isPlaying; - private _isReversing; - private _isCompleted; - private _playTimes; - private _time; - private _currentTime; - private _currentPlayTimes; - private _cacheFrameIndex; - private _frameSize; - private _cacheRectangle; - private _clock; - private _groupConfig; - private _config; - private _clipConfig; - private _currentFrameConfig; - private _clipArray; - private _clipNames; - private _slots; - private _childMovies; - constructor(createMovieHelper: any); - private _configToEvent(config, event); - private _onCrossFrame(frameConfig); - private _updateSlotBlendMode(slot); - private _updateSlotColor(slot, aM, rM, gM, bM, aO, rO, gO, bO); - private _updateSlotDisplay(slot); - private _getSlot(name); - /** - * @inheritDoc - */ - $render(): void; - /** - * @inheritDoc - */ - $updateRenderNode(): void; - /** - * @inheritDoc - */ - $measureContentBounds(bounds: egret.Rectangle): void; - /** - * @inheritDoc - */ - $doAddChild(child: egret.DisplayObject, index: number, notifyListeners?: boolean): egret.DisplayObject; - /** - * @inheritDoc - */ - $doRemoveChild(index: number, notifyListeners?: boolean): egret.DisplayObject; - /** - * 释放动画。 - * @version DragonBones 3.0 - * @language zh_CN - */ - dispose(): void; - /** - * @inheritDoc - */ - advanceTime(passedTime: number): void; - /** - * 播放动画剪辑。 - * @param clipName 动画剪辑的名称,如果未设置,则播放默认动画剪辑,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画剪辑。 - * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 4.7 - * @language zh_CN - */ - play(clipName?: string | null, playTimes?: number): void; - /** - * 暂停播放动画。 - * @version DragonBones 4.7 - * @language zh_CN - */ - stop(): void; - /** - * 从指定时间播放动画。 - * @param clipName 动画剪辑的名称。 - * @param time 指定时间。(以秒为单位) - * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 5.0 - * @language zh_CN - */ - gotoAndPlay(clipName: string | null | undefined, time: number, playTimes?: number): void; - /** - * 将动画停止到指定时间。 - * @param clipName 动画剪辑的名称。 - * @param time 指定时间。(以秒为单位) - * @version DragonBones 5.0 - * @language zh_CN - */ - gotoAndStop(clipName: string | null | undefined, time: number): void; - /** - * 是否包含指定动画剪辑。 - * @param clipName 动画剪辑的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - hasClip(clipName: string): boolean; - /** - * 动画剪辑是否处正在播放。 - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly isPlaying: boolean; - /** - * 动画剪辑是否均播放完毕。 - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly isComplete: boolean; - /** - * 当前动画剪辑的播放时间。 (以秒为单位) - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly currentTime: number; - /** - * 当前动画剪辑的总时间。 (以秒为单位) - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly totalTime: number; - /** - * 当前动画剪辑的播放次数。 - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly currentPlayTimes: number; - /** - * 当前动画剪辑需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly playTimes: number; - readonly groupName: string; - /** - * 正在播放的动画剪辑名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly clipName: string; - /** - * 所有动画剪辑的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - readonly clipNames: string[]; - /** - * @inheritDoc - */ - clock: WorldClock | null; - /** - * 已废弃,请参考 {@link dragonBones.Movie#clock} {@link dragonBones.Movie#clock} {@link dragonBones.EgretFactory#clock}。 - * @deprecated - * @language zh_CN - */ - advanceTimeBySelf(on: boolean): void; - /** - * @private - */ - readonly display: any; - /** - * @private - */ - readonly animation: any; - /** - * @private - */ - readonly armature: any; - /** - * @private - */ - getAnimation(): any; - /** - * @private - */ - getArmature(): any; - /** - * @private - */ - getDisplay(): any; - /** - * @private - */ - hasAnimation(name: string): boolean; - /** - * @private - */ - invalidUpdate(...args: any[]): void; - /** - * @private - */ - readonly lastAnimationName: string; - /** - * @private - */ - readonly animationNames: string[]; - /** - * @private - */ - readonly animationList: string[]; - } -} diff --git a/demo/libs/modules/dragonBones/dragonBones.js b/demo/libs/modules/dragonBones/dragonBones.js deleted file mode 100644 index 59091a98..00000000 --- a/demo/libs/modules/dragonBones/dragonBones.js +++ /dev/null @@ -1,18213 +0,0 @@ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var dragonBones; -(function (dragonBones) { -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @private - */ - var DragonBones = /** @class */ (function () { - function DragonBones(eventManager) { - this._clock = new dragonBones.WorldClock(); - this._events = []; - this._objects = []; - this._eventManager = null; - this._eventManager = eventManager; - console.info("DragonBones: " + DragonBones.VERSION + "\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/"); - } - DragonBones.prototype.advanceTime = function (passedTime) { - if (this._objects.length > 0) { - for (var _i = 0, _a = this._objects; _i < _a.length; _i++) { - var object = _a[_i]; - object.returnToPool(); - } - this._objects.length = 0; - } - this._clock.advanceTime(passedTime); - if (this._events.length > 0) { - for (var i = 0; i < this._events.length; ++i) { - var eventObject = this._events[i]; - var armature = eventObject.armature; - if (armature._armatureData !== null) { - armature.eventDispatcher.dispatchDBEvent(eventObject.type, eventObject); - if (eventObject.type === dragonBones.EventObject.SOUND_EVENT) { - this._eventManager.dispatchDBEvent(eventObject.type, eventObject); - } - } - this.bufferObject(eventObject); - } - this._events.length = 0; - } - }; - DragonBones.prototype.bufferEvent = function (value) { - if (this._events.indexOf(value) < 0) { - this._events.push(value); - } - }; - DragonBones.prototype.bufferObject = function (object) { - if (this._objects.indexOf(object) < 0) { - this._objects.push(object); - } - }; - Object.defineProperty(DragonBones.prototype, "clock", { - get: function () { - return this._clock; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DragonBones.prototype, "eventManager", { - get: function () { - return this._eventManager; - }, - enumerable: true, - configurable: true - }); - DragonBones.VERSION = "5.6.300"; - DragonBones.yDown = true; - DragonBones.debug = false; - DragonBones.debugDraw = false; - DragonBones.webAssembly = false; - return DragonBones; - }()); - dragonBones.DragonBones = DragonBones; -})(dragonBones || (dragonBones = {})); -// -if (typeof global === "undefined") { - var global = window; -} -// -if (!console.warn) { - console.warn = function () { }; -} -if (!console.assert) { - console.assert = function () { }; -} -// -if (!Date.now) { - Date.now = function now() { - return new Date().getTime(); - }; -} -// Weixin can not support typescript extends. -var __extends = function (t, e) { - function r() { - this.constructor = t; - } - for (var i in e) { - if (e.hasOwnProperty(i)) { - t[i] = e[i]; - } - } - r.prototype = e.prototype, t.prototype = new r(); -}; -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The BaseObject is the base class for all objects in the DragonBones framework. - * All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 基础对象,通常 DragonBones 的对象都继承自该类。 - * 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。 - * @version DragonBones 4.5 - * @language zh_CN - */ - var BaseObject = /** @class */ (function () { - function BaseObject() { - /** - * - A unique identification number assigned to the object. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 分配给此实例的唯一标识号。 - * @version DragonBones 4.5 - * @language zh_CN - */ - this.hashCode = BaseObject._hashCode++; - this._isInPool = false; - } - BaseObject._returnObject = function (object) { - var classType = String(object.constructor); - var maxCount = classType in BaseObject._maxCountMap ? BaseObject._maxCountMap[classType] : BaseObject._defaultMaxCount; - var pool = BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || []; - if (pool.length < maxCount) { - if (!object._isInPool) { - object._isInPool = true; - pool.push(object); - } - else { - console.warn("The object is already in the pool."); - } - } - else { - } - }; - BaseObject.toString = function () { - throw new Error(); - }; - /** - * - Set the maximum cache count of the specify object pool. - * @param objectConstructor - The specify class. (Set all object pools max cache count if not set) - * @param maxCount - Max count. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 设置特定对象池的最大缓存数量。 - * @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量) - * @param maxCount - 最大缓存数量。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseObject.setMaxCount = function (objectConstructor, maxCount) { - if (maxCount < 0 || maxCount !== maxCount) { - maxCount = 0; - } - if (objectConstructor !== null) { - var classType = String(objectConstructor); - var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; - if (pool !== null && pool.length > maxCount) { - pool.length = maxCount; - } - BaseObject._maxCountMap[classType] = maxCount; - } - else { - BaseObject._defaultMaxCount = maxCount; - for (var classType in BaseObject._poolsMap) { - var pool = BaseObject._poolsMap[classType]; - if (pool.length > maxCount) { - pool.length = maxCount; - } - if (classType in BaseObject._maxCountMap) { - BaseObject._maxCountMap[classType] = maxCount; - } - } - } - }; - /** - * - Clear the cached instances of a specify object pool. - * @param objectConstructor - Specify class. (Clear all cached instances if not set) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除特定对象池的缓存实例。 - * @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例) - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseObject.clearPool = function (objectConstructor) { - if (objectConstructor === void 0) { objectConstructor = null; } - if (objectConstructor !== null) { - var classType = String(objectConstructor); - var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; - if (pool !== null && pool.length > 0) { - pool.length = 0; - } - } - else { - for (var k in BaseObject._poolsMap) { - var pool = BaseObject._poolsMap[k]; - pool.length = 0; - } - } - }; - /** - * - Get an instance of the specify class from object pool. - * @param objectConstructor - The specify class. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从对象池中获取特定类的实例。 - * @param objectConstructor - 特定的类。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseObject.borrowObject = function (objectConstructor) { - var classType = String(objectConstructor); - var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; - if (pool !== null && pool.length > 0) { - var object_1 = pool.pop(); - object_1._isInPool = false; - return object_1; - } - var object = new objectConstructor(); - object._onClear(); - return object; - }; - /** - * - Clear the object and return it back to object pool。 - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除该实例的所有数据并将其返还对象池。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseObject.prototype.returnToPool = function () { - this._onClear(); - BaseObject._returnObject(this); - }; - BaseObject._hashCode = 0; - BaseObject._defaultMaxCount = 3000; - BaseObject._maxCountMap = {}; - BaseObject._poolsMap = {}; - return BaseObject; - }()); - dragonBones.BaseObject = BaseObject; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - 2D Transform matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 转换矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var Matrix = /** @class */ (function () { - /** - * @private - */ - function Matrix(a, b, c, d, tx, ty) { - if (a === void 0) { a = 1.0; } - if (b === void 0) { b = 0.0; } - if (c === void 0) { c = 0.0; } - if (d === void 0) { d = 1.0; } - if (tx === void 0) { tx = 0.0; } - if (ty === void 0) { ty = 0.0; } - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.tx = tx; - this.ty = ty; - } - Matrix.prototype.toString = function () { - return "[object dragonBones.Matrix] a:" + this.a + " b:" + this.b + " c:" + this.c + " d:" + this.d + " tx:" + this.tx + " ty:" + this.ty; - }; - /** - * @private - */ - Matrix.prototype.copyFrom = function (value) { - this.a = value.a; - this.b = value.b; - this.c = value.c; - this.d = value.d; - this.tx = value.tx; - this.ty = value.ty; - return this; - }; - /** - * @private - */ - Matrix.prototype.copyFromArray = function (value, offset) { - if (offset === void 0) { offset = 0; } - this.a = value[offset]; - this.b = value[offset + 1]; - this.c = value[offset + 2]; - this.d = value[offset + 3]; - this.tx = value[offset + 4]; - this.ty = value[offset + 5]; - return this; - }; - /** - * - Convert to unit matrix. - * The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 转换为单位矩阵。 - * 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。 - * @version DragonBones 3.0 - * @language zh_CN - */ - Matrix.prototype.identity = function () { - this.a = this.d = 1.0; - this.b = this.c = 0.0; - this.tx = this.ty = 0.0; - return this; - }; - /** - * - Multiplies the current matrix with another matrix. - * @param value - The matrix that needs to be multiplied. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将当前矩阵与另一个矩阵相乘。 - * @param value - 需要相乘的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - Matrix.prototype.concat = function (value) { - var aA = this.a * value.a; - var bA = 0.0; - var cA = 0.0; - var dA = this.d * value.d; - var txA = this.tx * value.a + value.tx; - var tyA = this.ty * value.d + value.ty; - if (this.b !== 0.0 || this.c !== 0.0) { - aA += this.b * value.c; - bA += this.b * value.d; - cA += this.c * value.a; - dA += this.c * value.b; - } - if (value.b !== 0.0 || value.c !== 0.0) { - bA += this.a * value.b; - cA += this.d * value.c; - txA += this.ty * value.c; - tyA += this.tx * value.b; - } - this.a = aA; - this.b = bA; - this.c = cA; - this.d = dA; - this.tx = txA; - this.ty = tyA; - return this; - }; - /** - * - Convert to inverse matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 转换为逆矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - Matrix.prototype.invert = function () { - var aA = this.a; - var bA = this.b; - var cA = this.c; - var dA = this.d; - var txA = this.tx; - var tyA = this.ty; - if (bA === 0.0 && cA === 0.0) { - this.b = this.c = 0.0; - if (aA === 0.0 || dA === 0.0) { - this.a = this.b = this.tx = this.ty = 0.0; - } - else { - aA = this.a = 1.0 / aA; - dA = this.d = 1.0 / dA; - this.tx = -aA * txA; - this.ty = -dA * tyA; - } - return this; - } - var determinant = aA * dA - bA * cA; - if (determinant === 0.0) { - this.a = this.d = 1.0; - this.b = this.c = 0.0; - this.tx = this.ty = 0.0; - return this; - } - determinant = 1.0 / determinant; - var k = this.a = dA * determinant; - bA = this.b = -bA * determinant; - cA = this.c = -cA * determinant; - dA = this.d = aA * determinant; - this.tx = -(k * txA + cA * tyA); - this.ty = -(bA * txA + dA * tyA); - return this; - }; - /** - * - Apply a matrix transformation to a specific point. - * @param x - X coordinate. - * @param y - Y coordinate. - * @param result - The point after the transformation is applied. - * @param delta - Whether to ignore tx, ty's conversion to point. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将矩阵转换应用于特定点。 - * @param x - 横坐标。 - * @param y - 纵坐标。 - * @param result - 应用转换之后的点。 - * @param delta - 是否忽略 tx,ty 对点的转换。 - * @version DragonBones 3.0 - * @language zh_CN - */ - Matrix.prototype.transformPoint = function (x, y, result, delta) { - if (delta === void 0) { delta = false; } - result.x = this.a * x + this.c * y; - result.y = this.b * x + this.d * y; - if (!delta) { - result.x += this.tx; - result.y += this.ty; - } - }; - /** - * @private - */ - Matrix.prototype.transformRectangle = function (rectangle, delta) { - if (delta === void 0) { delta = false; } - var a = this.a; - var b = this.b; - var c = this.c; - var d = this.d; - var tx = delta ? 0.0 : this.tx; - var ty = delta ? 0.0 : this.ty; - var x = rectangle.x; - var y = rectangle.y; - var xMax = x + rectangle.width; - var yMax = y + rectangle.height; - var x0 = a * x + c * y + tx; - var y0 = b * x + d * y + ty; - var x1 = a * xMax + c * y + tx; - var y1 = b * xMax + d * y + ty; - var x2 = a * xMax + c * yMax + tx; - var y2 = b * xMax + d * yMax + ty; - var x3 = a * x + c * yMax + tx; - var y3 = b * x + d * yMax + ty; - var tmp = 0.0; - if (x0 > x1) { - tmp = x0; - x0 = x1; - x1 = tmp; - } - if (x2 > x3) { - tmp = x2; - x2 = x3; - x3 = tmp; - } - rectangle.x = Math.floor(x0 < x2 ? x0 : x2); - rectangle.width = Math.ceil((x1 > x3 ? x1 : x3) - rectangle.x); - if (y0 > y1) { - tmp = y0; - y0 = y1; - y1 = tmp; - } - if (y2 > y3) { - tmp = y2; - y2 = y3; - y3 = tmp; - } - rectangle.y = Math.floor(y0 < y2 ? y0 : y2); - rectangle.height = Math.ceil((y1 > y3 ? y1 : y3) - rectangle.y); - }; - return Matrix; - }()); - dragonBones.Matrix = Matrix; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - 2D Transform. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 变换。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var Transform = /** @class */ (function () { - /** - * @private - */ - function Transform(x, y, skew, rotation, scaleX, scaleY) { - if (x === void 0) { x = 0.0; } - if (y === void 0) { y = 0.0; } - if (skew === void 0) { skew = 0.0; } - if (rotation === void 0) { rotation = 0.0; } - if (scaleX === void 0) { scaleX = 1.0; } - if (scaleY === void 0) { scaleY = 1.0; } - this.x = x; - this.y = y; - this.skew = skew; - this.rotation = rotation; - this.scaleX = scaleX; - this.scaleY = scaleY; - } - /** - * @private - */ - Transform.normalizeRadian = function (value) { - value = (value + Math.PI) % (Math.PI * 2.0); - value += value > 0.0 ? -Math.PI : Math.PI; - return value; - }; - Transform.prototype.toString = function () { - return "[object dragonBones.Transform] x:" + this.x + " y:" + this.y + " skewX:" + this.skew * 180.0 / Math.PI + " skewY:" + this.rotation * 180.0 / Math.PI + " scaleX:" + this.scaleX + " scaleY:" + this.scaleY; - }; - /** - * @private - */ - Transform.prototype.copyFrom = function (value) { - this.x = value.x; - this.y = value.y; - this.skew = value.skew; - this.rotation = value.rotation; - this.scaleX = value.scaleX; - this.scaleY = value.scaleY; - return this; - }; - /** - * @private - */ - Transform.prototype.identity = function () { - this.x = this.y = 0.0; - this.skew = this.rotation = 0.0; - this.scaleX = this.scaleY = 1.0; - return this; - }; - /** - * @private - */ - Transform.prototype.add = function (value) { - this.x += value.x; - this.y += value.y; - this.skew += value.skew; - this.rotation += value.rotation; - this.scaleX *= value.scaleX; - this.scaleY *= value.scaleY; - return this; - }; - /** - * @private - */ - Transform.prototype.minus = function (value) { - this.x -= value.x; - this.y -= value.y; - this.skew -= value.skew; - this.rotation -= value.rotation; - this.scaleX /= value.scaleX; - this.scaleY /= value.scaleY; - return this; - }; - /** - * @private - */ - Transform.prototype.fromMatrix = function (matrix) { - var backupScaleX = this.scaleX, backupScaleY = this.scaleY; - var PI_Q = Transform.PI_Q; - this.x = matrix.tx; - this.y = matrix.ty; - this.rotation = Math.atan(matrix.b / matrix.a); - var skewX = Math.atan(-matrix.c / matrix.d); - this.scaleX = (this.rotation > -PI_Q && this.rotation < PI_Q) ? matrix.a / Math.cos(this.rotation) : matrix.b / Math.sin(this.rotation); - this.scaleY = (skewX > -PI_Q && skewX < PI_Q) ? matrix.d / Math.cos(skewX) : -matrix.c / Math.sin(skewX); - if (backupScaleX >= 0.0 && this.scaleX < 0.0) { - this.scaleX = -this.scaleX; - this.rotation = this.rotation - Math.PI; - } - if (backupScaleY >= 0.0 && this.scaleY < 0.0) { - this.scaleY = -this.scaleY; - skewX = skewX - Math.PI; - } - this.skew = skewX - this.rotation; - return this; - }; - /** - * @private - */ - Transform.prototype.toMatrix = function (matrix) { - if (this.rotation === 0.0) { - matrix.a = 1.0; - matrix.b = 0.0; - } - else { - matrix.a = Math.cos(this.rotation); - matrix.b = Math.sin(this.rotation); - } - if (this.skew === 0.0) { - matrix.c = -matrix.b; - matrix.d = matrix.a; - } - else { - matrix.c = -Math.sin(this.skew + this.rotation); - matrix.d = Math.cos(this.skew + this.rotation); - } - if (this.scaleX !== 1.0) { - matrix.a *= this.scaleX; - matrix.b *= this.scaleX; - } - if (this.scaleY !== 1.0) { - matrix.c *= this.scaleY; - matrix.d *= this.scaleY; - } - matrix.tx = this.x; - matrix.ty = this.y; - return this; - }; - /** - * @private - */ - Transform.PI = Math.PI; - /** - * @private - */ - Transform.PI_D = Math.PI * 2.0; - /** - * @private - */ - Transform.PI_H = Math.PI / 2.0; - /** - * @private - */ - Transform.PI_Q = Math.PI / 4.0; - /** - * @private - */ - Transform.RAD_DEG = 180.0 / Math.PI; - /** - * @private - */ - Transform.DEG_RAD = Math.PI / 180.0; - return Transform; - }()); - dragonBones.Transform = Transform; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var ColorTransform = /** @class */ (function () { - function ColorTransform(alphaMultiplier, redMultiplier, greenMultiplier, blueMultiplier, alphaOffset, redOffset, greenOffset, blueOffset) { - if (alphaMultiplier === void 0) { alphaMultiplier = 1.0; } - if (redMultiplier === void 0) { redMultiplier = 1.0; } - if (greenMultiplier === void 0) { greenMultiplier = 1.0; } - if (blueMultiplier === void 0) { blueMultiplier = 1.0; } - if (alphaOffset === void 0) { alphaOffset = 0; } - if (redOffset === void 0) { redOffset = 0; } - if (greenOffset === void 0) { greenOffset = 0; } - if (blueOffset === void 0) { blueOffset = 0; } - this.alphaMultiplier = alphaMultiplier; - this.redMultiplier = redMultiplier; - this.greenMultiplier = greenMultiplier; - this.blueMultiplier = blueMultiplier; - this.alphaOffset = alphaOffset; - this.redOffset = redOffset; - this.greenOffset = greenOffset; - this.blueOffset = blueOffset; - } - ColorTransform.prototype.copyFrom = function (value) { - this.alphaMultiplier = value.alphaMultiplier; - this.redMultiplier = value.redMultiplier; - this.greenMultiplier = value.greenMultiplier; - this.blueMultiplier = value.blueMultiplier; - this.alphaOffset = value.alphaOffset; - this.redOffset = value.redOffset; - this.greenOffset = value.greenOffset; - this.blueOffset = value.blueOffset; - }; - ColorTransform.prototype.identity = function () { - this.alphaMultiplier = this.redMultiplier = this.greenMultiplier = this.blueMultiplier = 1.0; - this.alphaOffset = this.redOffset = this.greenOffset = this.blueOffset = 0; - }; - return ColorTransform; - }()); - dragonBones.ColorTransform = ColorTransform; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The Point object represents a location in a two-dimensional coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Point 对象表示二维坐标系统中的某个位置。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var Point = /** @class */ (function () { - /** - * - Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @param x - The horizontal coordinate. - * @param y - The vertical coordinate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 - * @param x - 该对象的x属性值,默认为 0.0。 - * @param y - 该对象的y属性值,默认为 0.0。 - * @version DragonBones 3.0 - * @language zh_CN - */ - function Point(x, y) { - if (x === void 0) { x = 0.0; } - if (y === void 0) { y = 0.0; } - this.x = x; - this.y = y; - } - /** - * @private - */ - Point.prototype.copyFrom = function (value) { - this.x = value.x; - this.y = value.y; - }; - /** - * @private - */ - Point.prototype.clear = function () { - this.x = this.y = 0.0; - }; - return Point; - }()); - dragonBones.Point = Point; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its - * width and its height.
- * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of - * one property has no effect on the others. However, the right and bottom properties are integrally related to those - * four properties. For example, if you change the value of the right property, the value of the width property changes; - * if you change the bottom property, the value of the height property changes. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var Rectangle = /** @class */ (function () { - /** - * @private - */ - function Rectangle(x, y, width, height) { - if (x === void 0) { x = 0.0; } - if (y === void 0) { y = 0.0; } - if (width === void 0) { width = 0.0; } - if (height === void 0) { height = 0.0; } - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - /** - * @private - */ - Rectangle.prototype.copyFrom = function (value) { - this.x = value.x; - this.y = value.y; - this.width = value.width; - this.height = value.height; - }; - /** - * @private - */ - Rectangle.prototype.clear = function () { - this.x = this.y = 0.0; - this.width = this.height = 0.0; - }; - return Rectangle; - }()); - dragonBones.Rectangle = Rectangle; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The user custom data. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 用户自定义数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - var UserData = /** @class */ (function (_super) { - __extends(UserData, _super); - function UserData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - The custom int numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - _this.ints = []; - /** - * - The custom float numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - _this.floats = []; - /** - * - The custom strings. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - _this.strings = []; - return _this; - } - UserData.toString = function () { - return "[class dragonBones.UserData]"; - }; - UserData.prototype._onClear = function () { - this.ints.length = 0; - this.floats.length = 0; - this.strings.length = 0; - }; - /** - * @internal - */ - UserData.prototype.addInt = function (value) { - this.ints.push(value); - }; - /** - * @internal - */ - UserData.prototype.addFloat = function (value) { - this.floats.push(value); - }; - /** - * @internal - */ - UserData.prototype.addString = function (value) { - this.strings.push(value); - }; - /** - * - Get the custom int number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - UserData.prototype.getInt = function (index) { - if (index === void 0) { index = 0; } - return index >= 0 && index < this.ints.length ? this.ints[index] : 0; - }; - /** - * - Get the custom float number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - UserData.prototype.getFloat = function (index) { - if (index === void 0) { index = 0; } - return index >= 0 && index < this.floats.length ? this.floats[index] : 0.0; - }; - /** - * - Get the custom string. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - UserData.prototype.getString = function (index) { - if (index === void 0) { index = 0; } - return index >= 0 && index < this.strings.length ? this.strings[index] : ""; - }; - return UserData; - }(dragonBones.BaseObject)); - dragonBones.UserData = UserData; - /** - * @internal - */ - var ActionData = /** @class */ (function (_super) { - __extends(ActionData, _super); - function ActionData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.data = null; // - return _this; - } - ActionData.toString = function () { - return "[class dragonBones.ActionData]"; - }; - ActionData.prototype._onClear = function () { - if (this.data !== null) { - this.data.returnToPool(); - } - this.type = 0 /* Play */; - this.name = ""; - this.bone = null; - this.slot = null; - this.data = null; - }; - return ActionData; - }(dragonBones.BaseObject)); - dragonBones.ActionData = ActionData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The DragonBones data. - * A DragonBones data contains multiple armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 龙骨数据。 - * 一个龙骨数据包含多个骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - var DragonBonesData = /** @class */ (function (_super) { - __extends(DragonBonesData, _super); - function DragonBonesData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @internal - */ - _this.frameIndices = []; - /** - * @internal - */ - _this.cachedFrames = []; - /** - * - All armature data names. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的骨架数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.armatureNames = []; - /** - * @private - */ - _this.armatures = {}; - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - DragonBonesData.toString = function () { - return "[class dragonBones.DragonBonesData]"; - }; - DragonBonesData.prototype._onClear = function () { - for (var k in this.armatures) { - this.armatures[k].returnToPool(); - delete this.armatures[k]; - } - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.autoSearch = false; - this.frameRate = 0; - this.version = ""; - this.name = ""; - this.stage = null; - this.frameIndices.length = 0; - this.cachedFrames.length = 0; - this.armatureNames.length = 0; - //this.armatures.clear(); - this.binary = null; // - this.intArray = null; // - this.floatArray = null; // - this.frameIntArray = null; // - this.frameFloatArray = null; // - this.frameArray = null; // - this.timelineArray = null; // - this.userData = null; - }; - /** - * @internal - */ - DragonBonesData.prototype.addArmature = function (value) { - if (value.name in this.armatures) { - console.warn("Same armature: " + value.name); - return; - } - value.parent = this; - this.armatures[value.name] = value; - this.armatureNames.push(value.name); - }; - /** - * - Get a specific armature data. - * @param armatureName - The armature data name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param armatureName - 骨架数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - DragonBonesData.prototype.getArmature = function (armatureName) { - return armatureName in this.armatures ? this.armatures[armatureName] : null; - }; - /** - * - Deprecated, please refer to {@link #dragonBones.BaseFactory#removeDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.BaseFactory#removeDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - DragonBonesData.prototype.dispose = function () { - console.warn("已废弃"); - this.returnToPool(); - }; - return DragonBonesData; - }(dragonBones.BaseObject)); - dragonBones.DragonBonesData = DragonBonesData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The armature data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var ArmatureData = /** @class */ (function (_super) { - __extends(ArmatureData, _super); - function ArmatureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.aabb = new dragonBones.Rectangle(); - /** - * - The names of all the animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的动画数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.animationNames = []; - /** - * @private - */ - _this.sortedBones = []; - /** - * @private - */ - _this.sortedSlots = []; - /** - * @private - */ - _this.defaultActions = []; - /** - * @private - */ - _this.actions = []; - /** - * @private - */ - _this.bones = {}; - /** - * @private - */ - _this.slots = {}; - /** - * @private - */ - _this.constraints = {}; - /** - * @private - */ - _this.skins = {}; - /** - * @private - */ - _this.animations = {}; - /** - * @private - */ - _this.canvas = null; // Initial value. - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - ArmatureData.toString = function () { - return "[class dragonBones.ArmatureData]"; - }; - ArmatureData.prototype._onClear = function () { - for (var _i = 0, _a = this.defaultActions; _i < _a.length; _i++) { - var action = _a[_i]; - action.returnToPool(); - } - for (var _b = 0, _c = this.actions; _b < _c.length; _b++) { - var action = _c[_b]; - action.returnToPool(); - } - for (var k in this.bones) { - this.bones[k].returnToPool(); - delete this.bones[k]; - } - for (var k in this.slots) { - this.slots[k].returnToPool(); - delete this.slots[k]; - } - for (var k in this.constraints) { - this.constraints[k].returnToPool(); - delete this.constraints[k]; - } - for (var k in this.skins) { - this.skins[k].returnToPool(); - delete this.skins[k]; - } - for (var k in this.animations) { - this.animations[k].returnToPool(); - delete this.animations[k]; - } - if (this.canvas !== null) { - this.canvas.returnToPool(); - } - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.type = 0 /* Armature */; - this.frameRate = 0; - this.cacheFrameRate = 0; - this.scale = 1.0; - this.name = ""; - this.aabb.clear(); - this.animationNames.length = 0; - this.sortedBones.length = 0; - this.sortedSlots.length = 0; - this.defaultActions.length = 0; - this.actions.length = 0; - // this.bones.clear(); - // this.slots.clear(); - // this.constraints.clear(); - // this.skins.clear(); - // this.animations.clear(); - this.defaultSkin = null; - this.defaultAnimation = null; - this.canvas = null; - this.userData = null; - this.parent = null; // - }; - /** - * @internal - */ - ArmatureData.prototype.sortBones = function () { - var total = this.sortedBones.length; - if (total <= 0) { - return; - } - var sortHelper = this.sortedBones.concat(); - var index = 0; - var count = 0; - this.sortedBones.length = 0; - while (count < total) { - var bone = sortHelper[index++]; - if (index >= total) { - index = 0; - } - if (this.sortedBones.indexOf(bone) >= 0) { - continue; - } - var flag = false; - for (var k in this.constraints) { - var constraint = this.constraints[k]; - if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { - flag = true; - break; - } - } - if (flag) { - continue; - } - if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { - continue; - } - this.sortedBones.push(bone); - count++; - } - }; - /** - * @internal - */ - ArmatureData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0) { - return; - } - this.cacheFrameRate = frameRate; - for (var k in this.animations) { - this.animations[k].cacheFrames(this.cacheFrameRate); - } - }; - /** - * @internal - */ - ArmatureData.prototype.setCacheFrame = function (globalTransformMatrix, transform) { - var dataArray = this.parent.cachedFrames; - var arrayOffset = dataArray.length; - dataArray.length += 10; - dataArray[arrayOffset] = globalTransformMatrix.a; - dataArray[arrayOffset + 1] = globalTransformMatrix.b; - dataArray[arrayOffset + 2] = globalTransformMatrix.c; - dataArray[arrayOffset + 3] = globalTransformMatrix.d; - dataArray[arrayOffset + 4] = globalTransformMatrix.tx; - dataArray[arrayOffset + 5] = globalTransformMatrix.ty; - dataArray[arrayOffset + 6] = transform.rotation; - dataArray[arrayOffset + 7] = transform.skew; - dataArray[arrayOffset + 8] = transform.scaleX; - dataArray[arrayOffset + 9] = transform.scaleY; - return arrayOffset; - }; - /** - * @internal - */ - ArmatureData.prototype.getCacheFrame = function (globalTransformMatrix, transform, arrayOffset) { - var dataArray = this.parent.cachedFrames; - globalTransformMatrix.a = dataArray[arrayOffset]; - globalTransformMatrix.b = dataArray[arrayOffset + 1]; - globalTransformMatrix.c = dataArray[arrayOffset + 2]; - globalTransformMatrix.d = dataArray[arrayOffset + 3]; - globalTransformMatrix.tx = dataArray[arrayOffset + 4]; - globalTransformMatrix.ty = dataArray[arrayOffset + 5]; - transform.rotation = dataArray[arrayOffset + 6]; - transform.skew = dataArray[arrayOffset + 7]; - transform.scaleX = dataArray[arrayOffset + 8]; - transform.scaleY = dataArray[arrayOffset + 9]; - transform.x = globalTransformMatrix.tx; - transform.y = globalTransformMatrix.ty; - }; - /** - * @internal - */ - ArmatureData.prototype.addBone = function (value) { - if (value.name in this.bones) { - console.warn("Same bone: " + value.name); - return; - } - this.bones[value.name] = value; - this.sortedBones.push(value); - }; - /** - * @internal - */ - ArmatureData.prototype.addSlot = function (value) { - if (value.name in this.slots) { - console.warn("Same slot: " + value.name); - return; - } - this.slots[value.name] = value; - this.sortedSlots.push(value); - }; - /** - * @internal - */ - ArmatureData.prototype.addConstraint = function (value) { - if (value.name in this.constraints) { - console.warn("Same constraint: " + value.name); - return; - } - this.constraints[value.name] = value; - }; - /** - * @internal - */ - ArmatureData.prototype.addSkin = function (value) { - if (value.name in this.skins) { - console.warn("Same skin: " + value.name); - return; - } - value.parent = this; - this.skins[value.name] = value; - if (this.defaultSkin === null) { - this.defaultSkin = value; - } - if (value.name === "default") { - this.defaultSkin = value; - } - }; - /** - * @internal - */ - ArmatureData.prototype.addAnimation = function (value) { - if (value.name in this.animations) { - console.warn("Same animation: " + value.name); - return; - } - value.parent = this; - this.animations[value.name] = value; - this.animationNames.push(value.name); - if (this.defaultAnimation === null) { - this.defaultAnimation = value; - } - }; - /** - * @internal - */ - ArmatureData.prototype.addAction = function (value, isDefault) { - if (isDefault) { - this.defaultActions.push(value); - } - else { - this.actions.push(value); - } - }; - /** - * - Get a specific done data. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼数据。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getBone = function (boneName) { - return boneName in this.bones ? this.bones[boneName] : null; - }; - /** - * - Get a specific slot data. - * @param slotName - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽数据。 - * @param slotName - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getSlot = function (slotName) { - return slotName in this.slots ? this.slots[slotName] : null; - }; - /** - * @private - */ - ArmatureData.prototype.getConstraint = function (constraintName) { - return constraintName in this.constraints ? this.constraints[constraintName] : null; - }; - /** - * - Get a specific skin data. - * @param skinName - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定皮肤数据。 - * @param skinName - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getSkin = function (skinName) { - return skinName in this.skins ? this.skins[skinName] : null; - }; - /** - * @private - */ - ArmatureData.prototype.getMesh = function (skinName, slotName, meshName) { - var skin = this.getSkin(skinName); - if (skin === null) { - return null; - } - return skin.getDisplay(slotName, meshName); - }; - /** - * - Get a specific animation data. - * @param animationName - The animation animationName. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的动画数据。 - * @param animationName - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getAnimation = function (animationName) { - return animationName in this.animations ? this.animations[animationName] : null; - }; - return ArmatureData; - }(dragonBones.BaseObject)); - dragonBones.ArmatureData = ArmatureData; - /** - * - The bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var BoneData = /** @class */ (function (_super) { - __extends(BoneData, _super); - function BoneData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.transform = new dragonBones.Transform(); - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - BoneData.toString = function () { - return "[class dragonBones.BoneData]"; - }; - BoneData.prototype._onClear = function () { - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.inheritTranslation = false; - this.inheritRotation = false; - this.inheritScale = false; - this.inheritReflection = false; - this.type = 0 /* Bone */; - this.length = 0.0; - this.name = ""; - this.transform.identity(); - this.userData = null; - this.parent = null; - }; - return BoneData; - }(dragonBones.BaseObject)); - dragonBones.BoneData = BoneData; - /** - * @internal - */ - var SurfaceData = /** @class */ (function (_super) { - __extends(SurfaceData, _super); - function SurfaceData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.vertices = []; - return _this; - } - SurfaceData.toString = function () { - return "[class dragonBones.SurfaceData]"; - }; - SurfaceData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 1 /* Surface */; - this.segmentX = 0; - this.segmentY = 0; - this.vertices.length = 0; - }; - return SurfaceData; - }(BoneData)); - dragonBones.SurfaceData = SurfaceData; - /** - * - The slot data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var SlotData = /** @class */ (function (_super) { - __extends(SlotData, _super); - function SlotData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.color = null; // Initial value. - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - /** - * @internal - */ - SlotData.createColor = function () { - return new dragonBones.ColorTransform(); - }; - SlotData.toString = function () { - return "[class dragonBones.SlotData]"; - }; - SlotData.prototype._onClear = function () { - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.blendMode = 0 /* Normal */; - this.displayIndex = 0; - this.zOrder = 0; - this.name = ""; - this.color = null; // - this.userData = null; - this.parent = null; // - }; - /** - * @internal - */ - SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); - return SlotData; - }(dragonBones.BaseObject)); - dragonBones.SlotData = SlotData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var CanvasData = /** @class */ (function (_super) { - __extends(CanvasData, _super); - function CanvasData() { - return _super !== null && _super.apply(this, arguments) || this; - } - CanvasData.toString = function () { - return "[class dragonBones.CanvasData]"; - }; - CanvasData.prototype._onClear = function () { - this.hasBackground = false; - this.color = 0x000000; - this.x = 0; - this.y = 0; - this.width = 0; - this.height = 0; - }; - return CanvasData; - }(dragonBones.BaseObject)); - dragonBones.CanvasData = CanvasData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The skin data, typically a armature data instance contains at least one skinData. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var SkinData = /** @class */ (function (_super) { - __extends(SkinData, _super); - function SkinData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.displays = {}; - return _this; - } - SkinData.toString = function () { - return "[class dragonBones.SkinData]"; - }; - SkinData.prototype._onClear = function () { - for (var k in this.displays) { - var slotDisplays = this.displays[k]; - for (var _i = 0, slotDisplays_1 = slotDisplays; _i < slotDisplays_1.length; _i++) { - var display = slotDisplays_1[_i]; - if (display !== null) { - display.returnToPool(); - } - } - delete this.displays[k]; - } - this.name = ""; - // this.displays.clear(); - this.parent = null; // - }; - /** - * @internal - */ - SkinData.prototype.addDisplay = function (slotName, value) { - if (!(slotName in this.displays)) { - this.displays[slotName] = []; - } - if (value !== null) { - value.parent = this; - } - var slotDisplays = this.displays[slotName]; // TODO clear prev - slotDisplays.push(value); - }; - /** - * @private - */ - SkinData.prototype.getDisplay = function (slotName, displayName) { - var slotDisplays = this.getDisplays(slotName); - if (slotDisplays !== null) { - for (var _i = 0, slotDisplays_2 = slotDisplays; _i < slotDisplays_2.length; _i++) { - var display = slotDisplays_2[_i]; - if (display !== null && display.name === displayName) { - return display; - } - } - } - return null; - }; - /** - * @private - */ - SkinData.prototype.getDisplays = function (slotName) { - if (!(slotName in this.displays)) { - return null; - } - return this.displays[slotName]; - }; - return SkinData; - }(dragonBones.BaseObject)); - dragonBones.SkinData = SkinData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var ConstraintData = /** @class */ (function (_super) { - __extends(ConstraintData, _super); - function ConstraintData() { - return _super !== null && _super.apply(this, arguments) || this; - } - ConstraintData.prototype._onClear = function () { - this.order = 0; - this.name = ""; - this.type = 0 /* IK */; - this.target = null; // - this.root = null; // - this.bone = null; - }; - return ConstraintData; - }(dragonBones.BaseObject)); - dragonBones.ConstraintData = ConstraintData; - /** - * @internal - */ - var IKConstraintData = /** @class */ (function (_super) { - __extends(IKConstraintData, _super); - function IKConstraintData() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraintData.toString = function () { - return "[class dragonBones.IKConstraintData]"; - }; - IKConstraintData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.scaleEnabled = false; - this.bendPositive = false; - this.weight = 1.0; - }; - return IKConstraintData; - }(ConstraintData)); - dragonBones.IKConstraintData = IKConstraintData; - /** - * @internal - */ - var PathConstraintData = /** @class */ (function (_super) { - __extends(PathConstraintData, _super); - function PathConstraintData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.bones = []; - return _this; - } - PathConstraintData.toString = function () { - return "[class dragonBones.PathConstraintData]"; - }; - PathConstraintData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.pathSlot = null; - this.pathDisplayData = null; - this.bones.length = 0; - this.positionMode = 0 /* Fixed */; - this.spacingMode = 1 /* Fixed */; - this.rotateMode = 1 /* Chain */; - this.position = 0.0; - this.spacing = 0.0; - this.rotateOffset = 0.0; - this.rotateMix = 0.0; - this.translateMix = 0.0; - }; - PathConstraintData.prototype.AddBone = function (value) { - this.bones.push(value); - }; - return PathConstraintData; - }(ConstraintData)); - dragonBones.PathConstraintData = PathConstraintData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var VerticesData = /** @class */ (function () { - function VerticesData() { - this.weight = null; // Initial value. - } - VerticesData.prototype.clear = function () { - if (!this.isShared && this.weight !== null) { - this.weight.returnToPool(); - } - this.isShared = false; - this.inheritDeform = false; - this.offset = 0; - this.data = null; - this.weight = null; - }; - VerticesData.prototype.shareFrom = function (value) { - this.isShared = true; - this.offset = value.offset; - this.weight = value.weight; - }; - return VerticesData; - }()); - dragonBones.VerticesData = VerticesData; - /** - * @internal - */ - var DisplayData = /** @class */ (function (_super) { - __extends(DisplayData, _super); - function DisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.transform = new dragonBones.Transform(); - return _this; - } - DisplayData.prototype._onClear = function () { - this.name = ""; - this.path = ""; - this.transform.identity(); - this.parent = null; // - }; - return DisplayData; - }(dragonBones.BaseObject)); - dragonBones.DisplayData = DisplayData; - /** - * @internal - */ - var ImageDisplayData = /** @class */ (function (_super) { - __extends(ImageDisplayData, _super); - function ImageDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.pivot = new dragonBones.Point(); - return _this; - } - ImageDisplayData.toString = function () { - return "[class dragonBones.ImageDisplayData]"; - }; - ImageDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 0 /* Image */; - this.pivot.clear(); - this.texture = null; - }; - return ImageDisplayData; - }(DisplayData)); - dragonBones.ImageDisplayData = ImageDisplayData; - /** - * @internal - */ - var ArmatureDisplayData = /** @class */ (function (_super) { - __extends(ArmatureDisplayData, _super); - function ArmatureDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.actions = []; - return _this; - } - ArmatureDisplayData.toString = function () { - return "[class dragonBones.ArmatureDisplayData]"; - }; - ArmatureDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - for (var _i = 0, _a = this.actions; _i < _a.length; _i++) { - var action = _a[_i]; - action.returnToPool(); - } - this.type = 1 /* Armature */; - this.inheritAnimation = false; - this.actions.length = 0; - this.armature = null; - }; - /** - * @private - */ - ArmatureDisplayData.prototype.addAction = function (value) { - this.actions.push(value); - }; - return ArmatureDisplayData; - }(DisplayData)); - dragonBones.ArmatureDisplayData = ArmatureDisplayData; - /** - * @internal - */ - var MeshDisplayData = /** @class */ (function (_super) { - __extends(MeshDisplayData, _super); - function MeshDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.vertices = new VerticesData(); - return _this; - } - MeshDisplayData.toString = function () { - return "[class dragonBones.MeshDisplayData]"; - }; - MeshDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 2 /* Mesh */; - this.vertices.clear(); - this.texture = null; - }; - return MeshDisplayData; - }(DisplayData)); - dragonBones.MeshDisplayData = MeshDisplayData; - /** - * @internal - */ - var BoundingBoxDisplayData = /** @class */ (function (_super) { - __extends(BoundingBoxDisplayData, _super); - function BoundingBoxDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.boundingBox = null; // Initial value. - return _this; - } - BoundingBoxDisplayData.toString = function () { - return "[class dragonBones.BoundingBoxDisplayData]"; - }; - BoundingBoxDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.boundingBox !== null) { - this.boundingBox.returnToPool(); - } - this.type = 3 /* BoundingBox */; - this.boundingBox = null; - }; - return BoundingBoxDisplayData; - }(DisplayData)); - dragonBones.BoundingBoxDisplayData = BoundingBoxDisplayData; - /** - * @internal - */ - var PathDisplayData = /** @class */ (function (_super) { - __extends(PathDisplayData, _super); - function PathDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.vertices = new VerticesData(); - _this.curveLengths = []; - return _this; - } - PathDisplayData.toString = function () { - return "[class dragonBones.PathDisplayData]"; - }; - PathDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 4 /* Path */; - this.closed = false; - this.constantSpeed = false; - this.vertices.clear(); - this.curveLengths.length = 0; - }; - return PathDisplayData; - }(DisplayData)); - dragonBones.PathDisplayData = PathDisplayData; - /** - * @internal - */ - var WeightData = /** @class */ (function (_super) { - __extends(WeightData, _super); - function WeightData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.bones = []; - return _this; - } - WeightData.toString = function () { - return "[class dragonBones.WeightData]"; - }; - WeightData.prototype._onClear = function () { - this.count = 0; - this.offset = 0; - this.bones.length = 0; - }; - WeightData.prototype.addBone = function (value) { - this.bones.push(value); - }; - return WeightData; - }(dragonBones.BaseObject)); - dragonBones.WeightData = WeightData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The base class of bounding box data. - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框数据基类。 - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language zh_CN - */ - var BoundingBoxData = /** @class */ (function (_super) { - __extends(BoundingBoxData, _super); - function BoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoundingBoxData.prototype._onClear = function () { - this.color = 0x000000; - this.width = 0.0; - this.height = 0.0; - }; - return BoundingBoxData; - }(dragonBones.BaseObject)); - dragonBones.BoundingBoxData = BoundingBoxData; - /** - * - The rectangle bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 矩形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var RectangleBoundingBoxData = /** @class */ (function (_super) { - __extends(RectangleBoundingBoxData, _super); - function RectangleBoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - RectangleBoundingBoxData.toString = function () { - return "[class dragonBones.RectangleBoundingBoxData]"; - }; - /** - * - Compute the bit code for a point (x, y) using the clip rectangle - */ - RectangleBoundingBoxData._computeOutCode = function (x, y, xMin, yMin, xMax, yMax) { - var code = 0 /* InSide */; // initialised as being inside of [[clip window]] - if (x < xMin) { - code |= 1 /* Left */; - } - else if (x > xMax) { - code |= 2 /* Right */; - } - if (y < yMin) { - code |= 4 /* Top */; - } - else if (y > yMax) { - code |= 8 /* Bottom */; - } - return code; - }; - /** - * @private - */ - RectangleBoundingBoxData.rectangleIntersectsSegment = function (xA, yA, xB, yB, xMin, yMin, xMax, yMax, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; - var inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; - if (inSideA && inSideB) { - return -1; - } - var intersectionCount = 0; - var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); - var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); - while (true) { - if ((outcode0 | outcode1) === 0) { - intersectionCount = 2; - break; - } - else if ((outcode0 & outcode1) !== 0) { - break; - } - // failed both tests, so calculate the line segment to clip - // from an outside point to an intersection with clip edge - var x = 0.0; - var y = 0.0; - var normalRadian = 0.0; - // At least one endpoint is outside the clip rectangle; pick it. - var outcodeOut = outcode0 !== 0 ? outcode0 : outcode1; - // Now find the intersection point; - if ((outcodeOut & 4 /* Top */) !== 0) { - x = xA + (xB - xA) * (yMin - yA) / (yB - yA); - y = yMin; - if (normalRadians !== null) { - normalRadian = -Math.PI * 0.5; - } - } - else if ((outcodeOut & 8 /* Bottom */) !== 0) { - x = xA + (xB - xA) * (yMax - yA) / (yB - yA); - y = yMax; - if (normalRadians !== null) { - normalRadian = Math.PI * 0.5; - } - } - else if ((outcodeOut & 2 /* Right */) !== 0) { - y = yA + (yB - yA) * (xMax - xA) / (xB - xA); - x = xMax; - if (normalRadians !== null) { - normalRadian = 0; - } - } - else if ((outcodeOut & 1 /* Left */) !== 0) { - y = yA + (yB - yA) * (xMin - xA) / (xB - xA); - x = xMin; - if (normalRadians !== null) { - normalRadian = Math.PI; - } - } - // Now we move outside point to intersection point to clip - // and get ready for next pass. - if (outcodeOut === outcode0) { - xA = x; - yA = y; - outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); - if (normalRadians !== null) { - normalRadians.x = normalRadian; - } - } - else { - xB = x; - yB = y; - outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); - if (normalRadians !== null) { - normalRadians.y = normalRadian; - } - } - } - if (intersectionCount) { - if (inSideA) { - intersectionCount = 2; // 10 - if (intersectionPointA !== null) { - intersectionPointA.x = xB; - intersectionPointA.y = yB; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = xB; - } - if (normalRadians !== null) { - normalRadians.x = normalRadians.y + Math.PI; - } - } - else if (inSideB) { - intersectionCount = 1; // 01 - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA; - intersectionPointB.y = yA; - } - if (normalRadians !== null) { - normalRadians.y = normalRadians.x + Math.PI; - } - } - else { - intersectionCount = 3; // 11 - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = yB; - } - } - } - return intersectionCount; - }; - RectangleBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 0 /* Rectangle */; - }; - /** - * @inheritDoc - */ - RectangleBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var widthH = this.width * 0.5; - if (pX >= -widthH && pX <= widthH) { - var heightH = this.height * 0.5; - if (pY >= -heightH && pY <= heightH) { - return true; - } - } - return false; - }; - /** - * @inheritDoc - */ - RectangleBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var widthH = this.width * 0.5; - var heightH = this.height * 0.5; - var intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, -widthH, -heightH, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians); - return intersectionCount; - }; - return RectangleBoundingBoxData; - }(BoundingBoxData)); - dragonBones.RectangleBoundingBoxData = RectangleBoundingBoxData; - /** - * - The ellipse bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 椭圆边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var EllipseBoundingBoxData = /** @class */ (function (_super) { - __extends(EllipseBoundingBoxData, _super); - function EllipseBoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - EllipseBoundingBoxData.toString = function () { - return "[class dragonBones.EllipseData]"; - }; - /** - * @private - */ - EllipseBoundingBoxData.ellipseIntersectsSegment = function (xA, yA, xB, yB, xC, yC, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var d = widthH / heightH; - var dd = d * d; - yA *= d; - yB *= d; - var dX = xB - xA; - var dY = yB - yA; - var lAB = Math.sqrt(dX * dX + dY * dY); - var xD = dX / lAB; - var yD = dY / lAB; - var a = (xC - xA) * xD + (yC - yA) * yD; - var aa = a * a; - var ee = xA * xA + yA * yA; - var rr = widthH * widthH; - var dR = rr - ee + aa; - var intersectionCount = 0; - if (dR >= 0.0) { - var dT = Math.sqrt(dR); - var sA = a - dT; - var sB = a + dT; - var inSideA = sA < 0.0 ? -1 : (sA <= lAB ? 0 : 1); - var inSideB = sB < 0.0 ? -1 : (sB <= lAB ? 0 : 1); - var sideAB = inSideA * inSideB; - if (sideAB < 0) { - return -1; - } - else if (sideAB === 0) { - if (inSideA === -1) { - intersectionCount = 2; // 10 - xB = xA + sB * xD; - yB = (yA + sB * yD) / d; - if (intersectionPointA !== null) { - intersectionPointA.x = xB; - intersectionPointA.y = yB; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = yB; - } - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yB / rr * dd, xB / rr); - normalRadians.y = normalRadians.x + Math.PI; - } - } - else if (inSideB === 1) { - intersectionCount = 1; // 01 - xA = xA + sA * xD; - yA = (yA + sA * yD) / d; - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA; - intersectionPointB.y = yA; - } - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yA / rr * dd, xA / rr); - normalRadians.y = normalRadians.x + Math.PI; - } - } - else { - intersectionCount = 3; // 11 - if (intersectionPointA !== null) { - intersectionPointA.x = xA + sA * xD; - intersectionPointA.y = (yA + sA * yD) / d; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(intersectionPointA.y / rr * dd, intersectionPointA.x / rr); - } - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA + sB * xD; - intersectionPointB.y = (yA + sB * yD) / d; - if (normalRadians !== null) { - normalRadians.y = Math.atan2(intersectionPointB.y / rr * dd, intersectionPointB.x / rr); - } - } - } - } - } - return intersectionCount; - }; - EllipseBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 1 /* Ellipse */; - }; - /** - * @inheritDoc - */ - EllipseBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var widthH = this.width * 0.5; - if (pX >= -widthH && pX <= widthH) { - var heightH = this.height * 0.5; - if (pY >= -heightH && pY <= heightH) { - pY *= widthH / heightH; - return Math.sqrt(pX * pX + pY * pY) <= widthH; - } - } - return false; - }; - /** - * @inheritDoc - */ - EllipseBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var intersectionCount = EllipseBoundingBoxData.ellipseIntersectsSegment(xA, yA, xB, yB, 0.0, 0.0, this.width * 0.5, this.height * 0.5, intersectionPointA, intersectionPointB, normalRadians); - return intersectionCount; - }; - return EllipseBoundingBoxData; - }(BoundingBoxData)); - dragonBones.EllipseBoundingBoxData = EllipseBoundingBoxData; - /** - * - The polygon bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var PolygonBoundingBoxData = /** @class */ (function (_super) { - __extends(PolygonBoundingBoxData, _super); - function PolygonBoundingBoxData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - The polygon vertices. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形顶点。 - * @version DragonBones 5.1 - * @language zh_CN - */ - _this.vertices = []; - return _this; - } - PolygonBoundingBoxData.toString = function () { - return "[class dragonBones.PolygonBoundingBoxData]"; - }; - /** - * @private - */ - PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - if (xA === xB) { - xA = xB + 0.000001; - } - if (yA === yB) { - yA = yB + 0.000001; - } - var count = vertices.length; - var dXAB = xA - xB; - var dYAB = yA - yB; - var llAB = xA * yB - yA * xB; - var intersectionCount = 0; - var xC = vertices[count - 2]; - var yC = vertices[count - 1]; - var dMin = 0.0; - var dMax = 0.0; - var xMin = 0.0; - var yMin = 0.0; - var xMax = 0.0; - var yMax = 0.0; - for (var i = 0; i < count; i += 2) { - var xD = vertices[i]; - var yD = vertices[i + 1]; - if (xC === xD) { - xC = xD + 0.0001; - } - if (yC === yD) { - yC = yD + 0.0001; - } - var dXCD = xC - xD; - var dYCD = yC - yD; - var llCD = xC * yD - yC * xD; - var ll = dXAB * dYCD - dYAB * dXCD; - var x = (llAB * dXCD - dXAB * llCD) / ll; - if (((x >= xC && x <= xD) || (x >= xD && x <= xC)) && (dXAB === 0.0 || (x >= xA && x <= xB) || (x >= xB && x <= xA))) { - var y = (llAB * dYCD - dYAB * llCD) / ll; - if (((y >= yC && y <= yD) || (y >= yD && y <= yC)) && (dYAB === 0.0 || (y >= yA && y <= yB) || (y >= yB && y <= yA))) { - if (intersectionPointB !== null) { - var d = x - xA; - if (d < 0.0) { - d = -d; - } - if (intersectionCount === 0) { - dMin = d; - dMax = d; - xMin = x; - yMin = y; - xMax = x; - yMax = y; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - normalRadians.y = normalRadians.x; - } - } - else { - if (d < dMin) { - dMin = d; - xMin = x; - yMin = y; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - } - } - if (d > dMax) { - dMax = d; - xMax = x; - yMax = y; - if (normalRadians !== null) { - normalRadians.y = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - } - } - } - intersectionCount++; - } - else { - xMin = x; - yMin = y; - xMax = x; - yMax = y; - intersectionCount++; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - normalRadians.y = normalRadians.x; - } - break; - } - } - } - xC = xD; - yC = yD; - } - if (intersectionCount === 1) { - if (intersectionPointA !== null) { - intersectionPointA.x = xMin; - intersectionPointA.y = yMin; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xMin; - intersectionPointB.y = yMin; - } - if (normalRadians !== null) { - normalRadians.y = normalRadians.x + Math.PI; - } - } - else if (intersectionCount > 1) { - intersectionCount++; - if (intersectionPointA !== null) { - intersectionPointA.x = xMin; - intersectionPointA.y = yMin; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xMax; - intersectionPointB.y = yMax; - } - } - return intersectionCount; - }; - PolygonBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 2 /* Polygon */; - this.x = 0.0; - this.y = 0.0; - this.vertices.length = 0; - }; - /** - * @inheritDoc - */ - PolygonBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var isInSide = false; - if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { - for (var i = 0, l = this.vertices.length, iP = l - 2; i < l; i += 2) { - var yA = this.vertices[iP + 1]; - var yB = this.vertices[i + 1]; - if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { - var xA = this.vertices[iP]; - var xB = this.vertices[i]; - if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { - isInSide = !isInSide; - } - } - iP = i; - } - } - return isInSide; - }; - /** - * @inheritDoc - */ - PolygonBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var intersectionCount = 0; - if (RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.x + this.width, this.y + this.height, null, null, null) !== 0) { - intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, intersectionPointA, intersectionPointB, normalRadians); - } - return intersectionCount; - }; - return PolygonBoundingBoxData; - }(BoundingBoxData)); - dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var AnimationData = /** @class */ (function (_super) { - __extends(AnimationData, _super); - function AnimationData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.cachedFrames = []; - /** - * @private - */ - _this.boneTimelines = {}; - /** - * @private - */ - _this.surfaceTimelines = {}; - /** - * @private - */ - _this.slotTimelines = {}; - /** - * @private - */ - _this.constraintTimelines = {}; - /** - * @private - */ - _this.animationTimelines = {}; - /** - * @private - */ - _this.boneCachedFrameIndices = {}; - /** - * @private - */ - _this.slotCachedFrameIndices = {}; - /** - * @private - */ - _this.actionTimeline = null; // Initial value. - /** - * @private - */ - _this.zOrderTimeline = null; // Initial value. - return _this; - } - AnimationData.toString = function () { - return "[class dragonBones.AnimationData]"; - }; - AnimationData.prototype._onClear = function () { - for (var k in this.boneTimelines) { - for (var _i = 0, _a = this.boneTimelines[k]; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.returnToPool(); - } - delete this.boneTimelines[k]; - } - for (var k in this.surfaceTimelines) { - for (var _b = 0, _c = this.surfaceTimelines[k]; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.returnToPool(); - } - delete this.surfaceTimelines[k]; - } - for (var k in this.slotTimelines) { - for (var _d = 0, _e = this.slotTimelines[k]; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.returnToPool(); - } - delete this.slotTimelines[k]; - } - for (var k in this.constraintTimelines) { - for (var _f = 0, _g = this.constraintTimelines[k]; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.returnToPool(); - } - delete this.constraintTimelines[k]; - } - for (var k in this.animationTimelines) { - for (var _h = 0, _j = this.animationTimelines[k]; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.returnToPool(); - } - delete this.animationTimelines[k]; - } - for (var k in this.boneCachedFrameIndices) { - delete this.boneCachedFrameIndices[k]; - } - for (var k in this.slotCachedFrameIndices) { - delete this.slotCachedFrameIndices[k]; - } - if (this.actionTimeline !== null) { - this.actionTimeline.returnToPool(); - } - if (this.zOrderTimeline !== null) { - this.zOrderTimeline.returnToPool(); - } - this.frameIntOffset = 0; - this.frameFloatOffset = 0; - this.frameOffset = 0; - this.frameCount = 0; - this.playTimes = 0; - this.duration = 0.0; - this.scale = 1.0; - this.fadeInTime = 0.0; - this.cacheFrameRate = 0.0; - this.name = ""; - this.cachedFrames.length = 0; - // this.boneTimelines.clear(); - // this.surfaceTimelines.clear(); - // this.slotTimelines.clear(); - // this.constraintTimelines.clear(); - // this.animationTimelines.clear(); - // this.boneCachedFrameIndices.clear(); - // this.slotCachedFrameIndices.clear(); - this.actionTimeline = null; - this.zOrderTimeline = null; - this.parent = null; // - }; - /** - * @internal - */ - AnimationData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0.0) { - return; - } - this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1.0); - var cacheFrameCount = Math.ceil(this.cacheFrameRate * this.duration) + 1; // Cache one more frame. - this.cachedFrames.length = cacheFrameCount; - for (var i = 0, l = this.cacheFrames.length; i < l; ++i) { - this.cachedFrames[i] = false; - } - for (var _i = 0, _a = this.parent.sortedBones; _i < _a.length; _i++) { - var bone = _a[_i]; - var indices = new Array(cacheFrameCount); - for (var i = 0, l = indices.length; i < l; ++i) { - indices[i] = -1; - } - this.boneCachedFrameIndices[bone.name] = indices; - } - for (var _b = 0, _c = this.parent.sortedSlots; _b < _c.length; _b++) { - var slot = _c[_b]; - var indices = new Array(cacheFrameCount); - for (var i = 0, l = indices.length; i < l; ++i) { - indices[i] = -1; - } - this.slotCachedFrameIndices[slot.name] = indices; - } - }; - /** - * @private - */ - AnimationData.prototype.addBoneTimeline = function (bone, timeline) { - var timelines = bone.name in this.boneTimelines ? this.boneTimelines[bone.name] : (this.boneTimelines[bone.name] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addSurfaceTimeline = function (surface, timeline) { - var timelines = surface.name in this.surfaceTimelines ? this.surfaceTimelines[surface.name] : (this.surfaceTimelines[surface.name] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addSlotTimeline = function (slot, timeline) { - var timelines = slot.name in this.slotTimelines ? this.slotTimelines[slot.name] : (this.slotTimelines[slot.name] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addConstraintTimeline = function (constraint, timeline) { - var timelines = constraint.name in this.constraintTimelines ? this.constraintTimelines[constraint.name] : (this.constraintTimelines[constraint.name] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addAnimationTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : (this.animationTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.getBoneTimelines = function (timelineName) { - return timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSurfaceTimelines = function (timelineName) { - return timelineName in this.surfaceTimelines ? this.surfaceTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSlotTimelines = function (timelineName) { - return timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getConstraintTimelines = function (timelineName) { - return timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getAnimationTimelines = function (timelineName) { - return timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getBoneCachedFrameIndices = function (boneName) { - return boneName in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[boneName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSlotCachedFrameIndices = function (slotName) { - return slotName in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[slotName] : null; - }; - return AnimationData; - }(dragonBones.BaseObject)); - dragonBones.AnimationData = AnimationData; - /** - * @internal - */ - var TimelineData = /** @class */ (function (_super) { - __extends(TimelineData, _super); - function TimelineData() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimelineData.toString = function () { - return "[class dragonBones.TimelineData]"; - }; - TimelineData.prototype._onClear = function () { - this.type = 10 /* BoneAll */; - this.offset = 0; - this.frameIndicesOffset = -1; - }; - return TimelineData; - }(dragonBones.BaseObject)); - dragonBones.TimelineData = TimelineData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The animation config is used to describe all the information needed to play an animation state. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画配置用来描述播放一个动画状态所需要的全部信息。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - var AnimationConfig = /** @class */ (function (_super) { - __extends(AnimationConfig, _super); - function AnimationConfig() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.boneMask = []; - return _this; - } - AnimationConfig.toString = function () { - return "[class dragonBones.AnimationConfig]"; - }; - AnimationConfig.prototype._onClear = function () { - this.pauseFadeOut = true; - this.fadeOutMode = 4 /* All */; - this.fadeOutTweenType = 1 /* Line */; - this.fadeOutTime = -1.0; - this.actionEnabled = true; - this.additiveBlending = false; - this.displayControl = true; - this.pauseFadeIn = true; - this.resetToPose = true; - this.fadeInTweenType = 1 /* Line */; - this.playTimes = -1; - this.layer = 0; - this.position = 0.0; - this.duration = -1.0; - this.timeScale = -100.0; - this.weight = 1.0; - this.fadeInTime = -1.0; - this.autoFadeOutTime = -1.0; - this.name = ""; - this.animation = ""; - this.group = ""; - this.boneMask.length = 0; - }; - /** - * @private - */ - AnimationConfig.prototype.clear = function () { - this._onClear(); - }; - /** - * @private - */ - AnimationConfig.prototype.copyFrom = function (value) { - this.pauseFadeOut = value.pauseFadeOut; - this.fadeOutMode = value.fadeOutMode; - this.autoFadeOutTime = value.autoFadeOutTime; - this.fadeOutTweenType = value.fadeOutTweenType; - this.actionEnabled = value.actionEnabled; - this.additiveBlending = value.additiveBlending; - this.displayControl = value.displayControl; - this.pauseFadeIn = value.pauseFadeIn; - this.resetToPose = value.resetToPose; - this.playTimes = value.playTimes; - this.layer = value.layer; - this.position = value.position; - this.duration = value.duration; - this.timeScale = value.timeScale; - this.fadeInTime = value.fadeInTime; - this.fadeOutTime = value.fadeOutTime; - this.fadeInTweenType = value.fadeInTweenType; - this.weight = value.weight; - this.name = value.name; - this.animation = value.animation; - this.group = value.group; - this.boneMask.length = value.boneMask.length; - for (var i = 0, l = this.boneMask.length; i < l; ++i) { - this.boneMask[i] = value.boneMask[i]; - } - }; - /** - * @private - */ - AnimationConfig.prototype.containsBoneMask = function (boneName) { - return this.boneMask.length === 0 || this.boneMask.indexOf(boneName) >= 0; - }; - /** - * @private - */ - AnimationConfig.prototype.addBoneMask = function (armature, boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var currentBone = armature.getBone(boneName); - if (currentBone === null) { - return; - } - if (this.boneMask.indexOf(boneName) < 0) { - this.boneMask.push(boneName); - } - if (recursive) { - for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (this.boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { - this.boneMask.push(bone.name); - } - } - } - }; - /** - * @private - */ - AnimationConfig.prototype.removeBoneMask = function (armature, boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var index = this.boneMask.indexOf(boneName); - if (index >= 0) { - this.boneMask.splice(index, 1); - } - if (recursive) { - var currentBone = armature.getBone(boneName); - if (currentBone !== null) { - if (this.boneMask.length > 0) { - for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - var index_1 = this.boneMask.indexOf(bone.name); - if (index_1 >= 0 && currentBone.contains(bone)) { - this.boneMask.splice(index_1, 1); - } - } - } - else { - for (var _b = 0, _c = armature.getBones(); _b < _c.length; _b++) { - var bone = _c[_b]; - if (bone === currentBone) { - continue; - } - if (!currentBone.contains(bone)) { - this.boneMask.push(bone.name); - } - } - } - } - } - }; - return AnimationConfig; - }(dragonBones.BaseObject)); - dragonBones.AnimationConfig = AnimationConfig; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var TextureAtlasData = /** @class */ (function (_super) { - __extends(TextureAtlasData, _super); - function TextureAtlasData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.textures = {}; - return _this; - } - TextureAtlasData.prototype._onClear = function () { - for (var k in this.textures) { - this.textures[k].returnToPool(); - delete this.textures[k]; - } - this.autoSearch = false; - this.width = 0; - this.height = 0; - this.scale = 1.0; - // this.textures.clear(); - this.name = ""; - this.imagePath = ""; - }; - /** - * @private - */ - TextureAtlasData.prototype.copyFrom = function (value) { - this.autoSearch = value.autoSearch; - this.scale = value.scale; - this.width = value.width; - this.height = value.height; - this.name = value.name; - this.imagePath = value.imagePath; - for (var k in this.textures) { - this.textures[k].returnToPool(); - delete this.textures[k]; - } - // this.textures.clear(); - for (var k in value.textures) { - var texture = this.createTexture(); - texture.copyFrom(value.textures[k]); - this.textures[k] = texture; - } - }; - /** - * @internal - */ - TextureAtlasData.prototype.addTexture = function (value) { - if (value.name in this.textures) { - console.warn("Same texture: " + value.name); - return; - } - value.parent = this; - this.textures[value.name] = value; - }; - /** - * @private - */ - TextureAtlasData.prototype.getTexture = function (textureName) { - return textureName in this.textures ? this.textures[textureName] : null; - }; - return TextureAtlasData; - }(dragonBones.BaseObject)); - dragonBones.TextureAtlasData = TextureAtlasData; - /** - * @internal - */ - var TextureData = /** @class */ (function (_super) { - __extends(TextureData, _super); - function TextureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.region = new dragonBones.Rectangle(); - _this.frame = null; // Initial value. - return _this; - } - TextureData.createRectangle = function () { - return new dragonBones.Rectangle(); - }; - TextureData.prototype._onClear = function () { - this.rotated = false; - this.name = ""; - this.region.clear(); - this.parent = null; // - this.frame = null; - }; - TextureData.prototype.copyFrom = function (value) { - this.rotated = value.rotated; - this.name = value.name; - this.region.copyFrom(value.region); - this.parent = value.parent; - if (this.frame === null && value.frame !== null) { - this.frame = TextureData.createRectangle(); - } - else if (this.frame !== null && value.frame === null) { - this.frame = null; - } - if (this.frame !== null && value.frame !== null) { - this.frame.copyFrom(value.frame); - } - }; - return TextureData; - }(dragonBones.BaseObject)); - dragonBones.TextureData = TextureData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var DeformVertices = /** @class */ (function (_super) { - __extends(DeformVertices, _super); - function DeformVertices() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.vertices = []; - _this.bones = []; - return _this; - } - DeformVertices.toString = function () { - return "[class dragonBones.DeformVertices]"; - }; - DeformVertices.prototype._onClear = function () { - this.verticesDirty = false; - this.vertices.length = 0; - this.bones.length = 0; - this.verticesData = null; - }; - DeformVertices.prototype.init = function (verticesDataValue, armature) { - this.verticesData = verticesDataValue; - if (this.verticesData !== null) { - var vertexCount = 0; - if (this.verticesData.weight !== null) { - vertexCount = this.verticesData.weight.count * 2; - } - else { - vertexCount = this.verticesData.data.intArray[this.verticesData.offset + 0 /* MeshVertexCount */] * 2; - } - this.verticesDirty = true; - this.vertices.length = vertexCount; - this.bones.length = 0; - // - for (var i = 0, l = this.vertices.length; i < l; ++i) { - this.vertices[i] = 0.0; - } - if (this.verticesData.weight !== null) { - for (var i = 0, l = this.verticesData.weight.bones.length; i < l; ++i) { - var bone = armature.getBone(this.verticesData.weight.bones[i].name); - this.bones.push(bone); - } - } - } - else { - this.verticesDirty = false; - this.vertices.length = 0; - this.bones.length = 0; - this.verticesData = null; - } - }; - DeformVertices.prototype.isBonesUpdate = function () { - for (var _i = 0, _a = this.bones; _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone !== null && bone._childrenTransformDirty) { - return true; - } - } - return false; - }; - return DeformVertices; - }(dragonBones.BaseObject)); - dragonBones.DeformVertices = DeformVertices; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones_1) { - /** - * - Armature is the core of the skeleton animation system. - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架是骨骼动画系统的核心。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - var Armature = /** @class */ (function (_super) { - __extends(Armature, _super); - function Armature() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._bones = []; - _this._slots = []; - /** - * @internal - */ - _this._constraints = []; - _this._actions = []; - _this._animation = null; // Initial value. - _this._proxy = null; // Initial value. - /** - * @internal - */ - _this._replaceTextureAtlasData = null; // Initial value. - _this._clock = null; // Initial value. - return _this; - } - Armature.toString = function () { - return "[class dragonBones.Armature]"; - }; - Armature._onSortSlots = function (a, b) { - return a._zOrder > b._zOrder ? 1 : -1; - }; - Armature.prototype._onClear = function () { - if (this._clock !== null) { - this._clock.remove(this); - } - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - bone.returnToPool(); - } - for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { - var slot = _c[_b]; - slot.returnToPool(); - } - for (var _d = 0, _e = this._constraints; _d < _e.length; _d++) { - var constraint = _e[_d]; - constraint.returnToPool(); - } - for (var _f = 0, _g = this._actions; _f < _g.length; _f++) { - var action = _g[_f]; - action.returnToPool(); - } - if (this._animation !== null) { - this._animation.returnToPool(); - } - if (this._proxy !== null) { - this._proxy.dbClear(); - } - if (this._replaceTextureAtlasData !== null) { - this._replaceTextureAtlasData.returnToPool(); - } - this.inheritAnimation = true; - this.userData = null; - this._lockUpdate = false; - this._slotsDirty = true; - this._zOrderDirty = false; - this._flipX = false; - this._flipY = false; - this._cacheFrameIndex = -1; - this._bones.length = 0; - this._slots.length = 0; - this._constraints.length = 0; - this._actions.length = 0; - this._armatureData = null; // - this._animation = null; // - this._proxy = null; // - this._display = null; - this._replaceTextureAtlasData = null; - this._replacedTexture = null; - this._dragonBones = null; // - this._clock = null; - this._parent = null; - }; - /** - * @internal - */ - Armature.prototype._sortZOrder = function (slotIndices, offset) { - var slotDatas = this._armatureData.sortedSlots; - var isOriginal = slotIndices === null; - if (this._zOrderDirty || !isOriginal) { - for (var i = 0, l = slotDatas.length; i < l; ++i) { - var slotIndex = isOriginal ? i : slotIndices[offset + i]; - if (slotIndex < 0 || slotIndex >= l) { - continue; - } - var slotData = slotDatas[slotIndex]; - var slot = this.getSlot(slotData.name); - if (slot !== null) { - slot._setZorder(i); - } - } - this._slotsDirty = true; - this._zOrderDirty = !isOriginal; - } - }; - /** - * @internal - */ - Armature.prototype._addBone = function (value) { - if (this._bones.indexOf(value) < 0) { - this._bones.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._addSlot = function (value) { - if (this._slots.indexOf(value) < 0) { - this._slots.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._addConstraint = function (value) { - if (this._constraints.indexOf(value) < 0) { - this._constraints.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._bufferAction = function (action, append) { - if (this._actions.indexOf(action) < 0) { - if (append) { - this._actions.push(action); - } - else { - this._actions.unshift(action); - } - } - }; - /** - * - Dispose the armature. (Return to the object pool) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 释放骨架。 (回收到对象池) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.dispose = function () { - if (this._armatureData !== null) { - this._lockUpdate = true; - this._dragonBones.bufferObject(this); - } - }; - /** - * @internal - */ - Armature.prototype.init = function (armatureData, proxy, display, dragonBones) { - if (this._armatureData !== null) { - return; - } - this._armatureData = armatureData; - this._animation = dragonBones_1.BaseObject.borrowObject(dragonBones_1.Animation); - this._proxy = proxy; - this._display = display; - this._dragonBones = dragonBones; - this._proxy.dbInit(this); - this._animation.init(this); - this._animation.animations = this._armatureData.animations; - }; - /** - * @inheritDoc - */ - Armature.prototype.advanceTime = function (passedTime) { - if (this._lockUpdate) { - return; - } - if (this._armatureData === null) { - console.warn("The armature has been disposed."); - return; - } - else if (this._armatureData.parent === null) { - console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear()."); - return; - } - var prevCacheFrameIndex = this._cacheFrameIndex; - // Update animation. - this._animation.advanceTime(passedTime); - // Sort slots. - if (this._slotsDirty) { - this._slotsDirty = false; - this._slots.sort(Armature._onSortSlots); - } - // Update bones and slots. - if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { - var i = 0, l = 0; - for (i = 0, l = this._bones.length; i < l; ++i) { - this._bones[i].update(this._cacheFrameIndex); - } - for (i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i].update(this._cacheFrameIndex); - } - } - // Do actions. - if (this._actions.length > 0) { - this._lockUpdate = true; - for (var _i = 0, _a = this._actions; _i < _a.length; _i++) { - var action = _a[_i]; - var actionData = action.actionData; - if (actionData !== null) { - if (actionData.type === 0 /* Play */) { - if (action.slot !== null) { - var childArmature = action.slot.childArmature; - if (childArmature !== null) { - childArmature.animation.fadeIn(actionData.name); - } - } - else if (action.bone !== null) { - for (var _b = 0, _c = this.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - if (slot.parent === action.bone) { - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.animation.fadeIn(actionData.name); - } - } - } - } - else { - this._animation.fadeIn(actionData.name); - } - } - } - action.returnToPool(); - } - this._actions.length = 0; - this._lockUpdate = false; - } - this._proxy.dbUpdate(); - }; - /** - * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. - * @param boneName - The bone name. (If not set, all bones will be update) - * @param updateSlot - Whether to update the bone's slots. (Default: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 - * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) - * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.invalidUpdate = function (boneName, updateSlot) { - if (boneName === void 0) { boneName = null; } - if (updateSlot === void 0) { updateSlot = false; } - if (boneName !== null && boneName.length > 0) { - var bone = this.getBone(boneName); - if (bone !== null) { - bone.invalidUpdate(); - if (updateSlot) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === bone) { - slot.invalidUpdate(); - } - } - } - } - } - else { - for (var _b = 0, _c = this._bones; _b < _c.length; _b++) { - var bone = _c[_b]; - bone.invalidUpdate(); - } - if (updateSlot) { - for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { - var slot = _e[_d]; - slot.invalidUpdate(); - } - } - } - }; - /** - * - Check whether a specific point is inside a custom bounding box in a slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在某个插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Armature.prototype.containsPoint = function (x, y) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.containsPoint(x, y)) { - return slot; - } - } - return null; - }; - /** - * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Armature.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var isV = xA === xB; - var dMin = 0.0; - var dMax = 0.0; - var intXA = 0.0; - var intYA = 0.0; - var intXB = 0.0; - var intYB = 0.0; - var intAN = 0.0; - var intBN = 0.0; - var intSlotA = null; - var intSlotB = null; - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); - if (intersectionCount > 0) { - if (intersectionPointA !== null || intersectionPointB !== null) { - if (intersectionPointA !== null) { - var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; - if (d < 0.0) { - d = -d; - } - if (intSlotA === null || d < dMin) { - dMin = d; - intXA = intersectionPointA.x; - intYA = intersectionPointA.y; - intSlotA = slot; - if (normalRadians) { - intAN = normalRadians.x; - } - } - } - if (intersectionPointB !== null) { - var d = intersectionPointB.x - xA; - if (d < 0.0) { - d = -d; - } - if (intSlotB === null || d > dMax) { - dMax = d; - intXB = intersectionPointB.x; - intYB = intersectionPointB.y; - intSlotB = slot; - if (normalRadians !== null) { - intBN = normalRadians.y; - } - } - } - } - else { - intSlotA = slot; - break; - } - } - } - if (intSlotA !== null && intersectionPointA !== null) { - intersectionPointA.x = intXA; - intersectionPointA.y = intYA; - if (normalRadians !== null) { - normalRadians.x = intAN; - } - } - if (intSlotB !== null && intersectionPointB !== null) { - intersectionPointB.x = intXB; - intersectionPointB.y = intYB; - if (normalRadians !== null) { - normalRadians.y = intBN; - } - } - return intSlotA; - }; - /** - * - Get a specific bone. - * @param name - The bone name. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼。 - * @param name - 骨骼名称。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBone = function (name) { - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone.name === name) { - return bone; - } - } - return null; - }; - /** - * - Get a specific bone by the display. - * @param display - The display object. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的骨骼。 - * @param display - 显示对象。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBoneByDisplay = function (display) { - var slot = this.getSlotByDisplay(display); - return slot !== null ? slot.parent : null; - }; - /** - * - Get a specific slot. - * @param name - The slot name. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽。 - * @param name - 插槽名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlot = function (name) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.name === name) { - return slot; - } - } - return null; - }; - /** - * - Get a specific slot by the display. - * @param display - The display object. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的插槽。 - * @param display - 显示对象。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlotByDisplay = function (display) { - if (display !== null) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.display === display) { - return slot; - } - } - } - return null; - }; - /** - * - Get all bones. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBones = function () { - return this._bones; - }; - /** - * - Get all slots. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlots = function () { - return this._slots; - }; - Object.defineProperty(Armature.prototype, "flipX", { - /** - * - Whether to flip the armature horizontally. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架水平翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - get: function () { - return this._flipX; - }, - set: function (value) { - if (this._flipX === value) { - return; - } - this._flipX = value; - this.invalidUpdate(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "flipY", { - /** - * - Whether to flip the armature vertically. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架垂直翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - get: function () { - return this._flipY; - }, - set: function (value) { - if (this._flipY === value) { - return; - } - this._flipY = value; - this.invalidUpdate(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "cacheFrameRate", { - /** - * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. - * There is a certain amount of memory overhead to improve performance by caching animation data in memory. - * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. - * When the animation cache is turned on, some features will fail, such as the offset property of bone. - * @example - *
-             *     armature.cacheFrameRate = 24;
-             * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 - * @example - *
-             *     armature.cacheFrameRate = 24;
-             * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._armatureData.cacheFrameRate; - }, - set: function (value) { - if (this._armatureData.cacheFrameRate !== value) { - this._armatureData.cacheFrames(value); - // Set child armature frameRate. - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.cacheFrameRate = value; - } - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "name", { - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._armatureData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "armatureData", { - /** - * - The armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._armatureData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "animation", { - /** - * - The animation player. - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._animation; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "proxy", { - /** - * @pivate - */ - get: function () { - return this._proxy; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "eventDispatcher", { - /** - * - The EventDispatcher instance of the armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架的 EventDispatcher 实例。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._proxy; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "display", { - /** - * - The display container. - * The display of the slot is displayed as the parent. - * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 显示容器实例。 - * 插槽的显示对象都会以此显示容器为父级。 - * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._display; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "replacedTexture", { - /** - * @private - */ - get: function () { - return this._replacedTexture; - }, - set: function (value) { - if (this._replacedTexture === value) { - return; - } - if (this._replaceTextureAtlasData !== null) { - this._replaceTextureAtlasData.returnToPool(); - this._replaceTextureAtlasData = null; - } - this._replacedTexture = value; - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - slot.invalidUpdate(); - slot.update(-1); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - if (this._clock !== null) { - this._clock.remove(this); - } - this._clock = value; - if (this._clock) { - this._clock.add(this); - } - // Update childArmature clock. - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.clock = this._clock; - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "parent", { - /** - * - Get the parent slot which the armature belongs to. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架所属的父插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * @deprecated - * @private - */ - Armature.prototype.replaceTexture = function (texture) { - this.replacedTexture = texture; - }; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.hasEventListener = function (type) { - console.warn("Deprecated."); - return this._proxy.hasDBEventListener(type); - }; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.addEventListener = function (type, listener, target) { - console.warn("Deprecated."); - this._proxy.addDBEventListener(type, listener, target); - }; - /** - * - Deprecated, please refer to {@link #eventDispatcher}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventDispatcher}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.removeEventListener = function (type, listener, target) { - console.warn("Deprecated."); - this._proxy.removeDBEventListener(type, listener, target); - }; - /** - * - Deprecated, please refer to {@link #cacheFrameRate}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.enableAnimationCache = function (frameRate) { - console.warn("Deprecated."); - this.cacheFrameRate = frameRate; - }; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.getDisplay = function () { - return this._display; - }; - return Armature; - }(dragonBones_1.BaseObject)); - dragonBones_1.Armature = Armature; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The base class of the transform object. - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 变换对象的基类。 - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language zh_CN - */ - var TransformObject = /** @class */ (function (_super) { - __extends(TransformObject, _super); - function TransformObject() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - A matrix relative to the armature coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.globalTransformMatrix = new dragonBones.Matrix(); - /** - * - A transform relative to the armature coordinate system. - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的变换。 - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.global = new dragonBones.Transform(); - /** - * - The offset transform relative to the armature or the parent bone coordinate system. - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架或父骨骼坐标系的偏移变换。 - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.offset = new dragonBones.Transform(); - return _this; - } - /** - */ - TransformObject.prototype._onClear = function () { - this.globalTransformMatrix.identity(); - this.global.identity(); - this.offset.identity(); - this.origin = null; - this.userData = null; - this._globalDirty = false; - this._armature = null; // - }; - /** - * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, - * some engines do not rely on these attributes to update rendering, such as Egret. - * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 - * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - TransformObject.prototype.updateGlobalTransform = function () { - if (this._globalDirty) { - this._globalDirty = false; - this.global.fromMatrix(this.globalTransformMatrix); - } - }; - Object.defineProperty(TransformObject.prototype, "armature", { - /** - * - The armature to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的骨架。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._armature; - }, - enumerable: true, - configurable: true - }); - TransformObject._helpMatrix = new dragonBones.Matrix(); - TransformObject._helpTransform = new dragonBones.Transform(); - TransformObject._helpPoint = new dragonBones.Point(); - return TransformObject; - }(dragonBones.BaseObject)); - dragonBones.TransformObject = TransformObject; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - Bone is one of the most important logical units in the armature animation system, - * and is responsible for the realization of translate, rotation, scaling in the animations. - * A armature can contain multiple bones. - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 - * 一个骨架中可以包含多个骨骼。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - var Bone = /** @class */ (function (_super) { - __extends(Bone, _super); - function Bone() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @internal - */ - _this.animationPose = new dragonBones.Transform(); - /** - * @internal - */ - _this._blendState = new dragonBones.BlendState(); - return _this; - } - Bone.toString = function () { - return "[class dragonBones.Bone]"; - }; - Bone.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.offsetMode = 1 /* Additive */; - this.animationPose.identity(); - this._transformDirty = false; - this._childrenTransformDirty = false; - this._localDirty = true; - this._hasConstraint = false; - this._visible = true; - this._cachedFrameIndex = -1; - this._blendState.clear(); - this._boneData = null; // - this._parent = null; // - this._cachedFrameIndices = null; - }; - Bone.prototype._updateGlobalTransformMatrix = function (isCache) { - // For typescript. - var boneData = this._boneData; - var global = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - var origin = this.origin; - var offset = this.offset; - var animationPose = this.animationPose; - var parent = this._parent; // - var flipX = this._armature.flipX; - var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; - var inherit = parent !== null; - var rotation = 0.0; - if (this.offsetMode === 1 /* Additive */) { - if (origin !== null) { - // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); - global.x = origin.x + offset.x + animationPose.x; - global.y = origin.y + offset.y + animationPose.y; - global.skew = origin.skew + offset.skew + animationPose.skew; - global.rotation = origin.rotation + offset.rotation + animationPose.rotation; - global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX; - global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY; - } - else { - global.copyFrom(offset).add(animationPose); - } - } - else if (this.offsetMode === 0 /* None */) { - if (origin !== null) { - global.copyFrom(origin).add(animationPose); - } - else { - global.copyFrom(animationPose); - } - } - else { - inherit = false; - global.copyFrom(offset); - } - if (inherit) { - var parentMatrix = parent._boneData.type === 0 /* Bone */ ? parent.globalTransformMatrix : parent._getGlobalTransformMatrix(global.x, global.y); - if (boneData.inheritScale) { - if (!boneData.inheritRotation) { - parent.updateGlobalTransform(); - if (flipX && flipY) { - rotation = global.rotation - (parent.global.rotation + Math.PI); - } - else if (flipX) { - rotation = global.rotation + parent.global.rotation + Math.PI; - } - else if (flipY) { - rotation = global.rotation + parent.global.rotation; - } - else { - rotation = global.rotation - parent.global.rotation; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - globalTransformMatrix.concat(parentMatrix); - if (boneData.inheritTranslation) { - global.x = globalTransformMatrix.tx; - global.y = globalTransformMatrix.ty; - } - else { - globalTransformMatrix.tx = global.x; - globalTransformMatrix.ty = global.y; - } - if (isCache) { - global.fromMatrix(globalTransformMatrix); - } - else { - this._globalDirty = true; - } - } - else { - if (boneData.inheritTranslation) { - var x = global.x; - var y = global.y; - global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - global.y = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; - } - else { - if (flipX) { - global.x = -global.x; - } - if (flipY) { - global.y = -global.y; - } - } - if (boneData.inheritRotation) { - parent.updateGlobalTransform(); - if (parent.global.scaleX < 0.0) { - rotation = global.rotation + parent.global.rotation + Math.PI; - } - else { - rotation = global.rotation + parent.global.rotation; - } - if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { - rotation -= global.rotation * 2.0; - if (flipX !== flipY || boneData.inheritReflection) { - global.skew += Math.PI; - } - } - global.rotation = rotation; - } - else if (flipX || flipY) { - if (flipX && flipY) { - rotation = global.rotation + Math.PI; - } - else { - if (flipX) { - rotation = Math.PI - global.rotation; - } - else { - rotation = -global.rotation; - } - global.skew += Math.PI; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - } - } - else { - if (flipX || flipY) { - if (flipX) { - global.x = -global.x; - } - if (flipY) { - global.y = -global.y; - } - if (flipX && flipY) { - rotation = global.rotation + Math.PI; - } - else { - if (flipX) { - rotation = Math.PI - global.rotation; - } - else { - rotation = -global.rotation; - } - global.skew += Math.PI; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - } - }; - /** - * @internal - */ - Bone.prototype.init = function (boneData, armatureValue) { - if (this._boneData !== null) { - return; - } - this._boneData = boneData; - this._armature = armatureValue; - if (this._boneData.parent !== null) { - this._parent = this._armature.getBone(this._boneData.parent.name); - } - this._armature._addBone(this); - // - this.origin = this._boneData.transform; - }; - /** - * @internal - */ - Bone.prototype.update = function (cacheFrameIndex) { - this._blendState.dirty = false; - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else { - if (this._hasConstraint) { - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - } - else { - if (this._hasConstraint) { - for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { - var constraint = _c[_b]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - if (this._transformDirty) { - this._transformDirty = false; - this._childrenTransformDirty = true; - // - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - if (this._localDirty) { - this._updateGlobalTransformMatrix(isCache); - } - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - // - } - else if (this._childrenTransformDirty) { - this._childrenTransformDirty = false; - } - this._localDirty = true; - }; - /** - * @internal - */ - Bone.prototype.updateByConstraint = function () { - if (this._localDirty) { - this._localDirty = false; - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - this._updateGlobalTransformMatrix(true); - } - this._transformDirty = true; - } - }; - /** - * - Forces the bone to update the transform in the next frame. - * When the bone is not animated or its animation state is finished, the bone will not continue to update, - * and when the skeleton must be updated for some reason, the method needs to be called explicitly. - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制骨骼在下一帧更新变换。 - * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Bone.prototype.invalidUpdate = function () { - this._transformDirty = true; - }; - /** - * - Check whether the bone contains a specific bone. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查该骨骼是否包含特定的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Bone.prototype.contains = function (value) { - if (value === this) { - return false; - } - var ancestor = value; - while (ancestor !== this && ancestor !== null) { - ancestor = ancestor.parent; - } - return ancestor === this; - }; - Object.defineProperty(Bone.prototype, "boneData", { - /** - * - The bone data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._boneData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "visible", { - /** - * - The visible of all slots in the bone. - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 此骨骼所有插槽的可见。 - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible === value) { - return; - } - this._visible = value; - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === this) { - slot._updateVisible(); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "name", { - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._boneData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "parent", { - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getBones()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getBones()}。 - * @deprecated - * @language zh_CN - */ - Bone.prototype.getBones = function () { - console.warn("Deprecated."); - var bones = new Array(); - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone.parent === this) { - bones.push(bone); - } - } - return bones; - }; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getSlots()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getSlots()}。 - * @deprecated - * @language zh_CN - */ - Bone.prototype.getSlots = function () { - console.warn("Deprecated."); - var slots = new Array(); - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === this) { - slots.push(slot); - } - } - return slots; - }; - Object.defineProperty(Bone.prototype, "slot", { - /** - * - Deprecated, please refer to {@link dragonBones.Armature#getSlot()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#getSlot()}。 - * @deprecated - * @language zh_CN - */ - get: function () { - console.warn("Deprecated."); - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === this) { - return slot; - } - } - return null; - }, - enumerable: true, - configurable: true - }); - return Bone; - }(dragonBones.TransformObject)); - dragonBones.Bone = Bone; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var Surface = /** @class */ (function (_super) { - __extends(Surface, _super); - function Surface() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._vertices = []; - _this._deformVertices = []; - /** - * - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y - */ - _this._hullCache = []; - /** - * - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] - */ - _this._matrixCahce = []; - return _this; - } - Surface.toString = function () { - return "[class dragonBones.Surface]"; - }; - Surface.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._dX = 0.0; - this._dY = 0.0; - this._k = 0.0; - this._kX = 0.0; - this._kY = 0.0; - this._vertices.length = 0; - this._deformVertices.length = 0; - this._matrixCahce.length = 0; - this._hullCache.length = 0; - }; - Surface.prototype._getAffineTransform = function (x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) { - var dabX = bX - aX; - var dabY = bY - aY; - var dacX = cX - aX; - var dacY = cY - aY; - transform.rotation = Math.atan2(dabY, dabX); - transform.skew = Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation; - if (isDown) { - transform.rotation += Math.PI; - } - transform.scaleX = Math.sqrt(dabX * dabX + dabY * dabY) / lX; - transform.scaleY = Math.sqrt(dacX * dacX + dacY * dacY) / lY; - transform.toMatrix(matrix); - transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y); - transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y); - }; - Surface.prototype._updateVertices = function () { - var originalVertices = this._boneData.vertices; - var vertices = this._vertices; - var animationVertices = this._deformVertices; - if (this._parent !== null) { - if (this._parent._boneData.type === 1 /* Surface */) { - for (var i = 0, l = originalVertices.length; i < l; i += 2) { - var x = originalVertices[i] + animationVertices[i]; - var y = originalVertices[i + 1] + animationVertices[i]; - var matrix = this._parent._getGlobalTransformMatrix(x, y); - // - vertices[i] = matrix.a * x + matrix.c * y + matrix.tx; - vertices[i + 1] = matrix.b * x + matrix.d * y + matrix.ty; - } - } - else { - var parentMatrix = this._parent.globalTransformMatrix; - for (var i = 0, l = originalVertices.length; i < l; i += 2) { - var x = originalVertices[i] + animationVertices[i]; - var y = originalVertices[i + 1] + animationVertices[i + 1]; - // - vertices[i] = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - vertices[i + 1] = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; - } - } - } - else { - for (var i = 0, l = originalVertices.length; i < l; i += 2) { - vertices[i] = originalVertices[i] + animationVertices[i]; - vertices[i + 1] = originalVertices[i + 1] + animationVertices[i + 1]; - } - } - }; - Surface.prototype._updateGlobalTransformMatrix = function (isCache) { - // tslint:disable-next-line:no-unused-expression - isCache; - var segmentXD = this._boneData.segmentX * 2; - var lastIndex = this._vertices.length - 2; - var lA = 200.0; - // - var raX = this._vertices[0]; - var raY = this._vertices[1]; - var rbX = this._vertices[segmentXD]; - var rbY = this._vertices[segmentXD + 1]; - var rcX = this._vertices[lastIndex]; - var rcY = this._vertices[lastIndex + 1]; - var rdX = this._vertices[lastIndex - segmentXD]; - var rdY = this._vertices[lastIndex - segmentXD + 1]; - // - var dacX = raX + (rcX - raX) * 0.5; - var dacY = raY + (rcY - raY) * 0.5; - var dbdX = rbX + (rdX - rbX) * 0.5; - var dbdY = rbY + (rdY - rbY) * 0.5; - var aX = dacX + (dbdX - dacX) * 0.5; - var aY = dacY + (dbdY - dacY) * 0.5; - var bX = rbX + (rcX - rbX) * 0.5; - var bY = rbY + (rcY - rbY) * 0.5; - var cX = rdX + (rcX - rdX) * 0.5; - var cY = rdY + (rcY - rdY) * 0.5; - // - this._globalDirty = false; - this._getAffineTransform(0.0, 0.0, lA, lA, aX, aY, bX, bY, cX, cY, this.global, this.globalTransformMatrix, false); - }; - Surface.prototype._getGlobalTransformMatrix = function (x, y) { - var lB = 1000.0; - if (x < -lB || lB < x || y < -lB || lB < y) { - return this.globalTransformMatrix; - } - var isDown = false; - var lA = 200.0; - var surfaceData = this._boneData; - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var segmentXD = surfaceData.segmentX * 2; - var dX = this._dX; - var dY = this._dY; - var indexX = Math.floor((x + lA) / dX); // -1 ~ segmentX - 1 - var indexY = Math.floor((y + lA) / dY); // -1 ~ segmentY - 1 - var matrixIndex = 0; - var pX = indexX * dX - lA; - var pY = indexY * dY - lA; - var matrices = this._matrixCahce; - var helpMatrix = Surface._helpMatrix; - if (x < -lA) { - if (y < -lA || y >= lA) { - return this.globalTransformMatrix; - } - // Left. - isDown = y > this._kX * (x + lA) + pY; - matrixIndex = ((segmentX * (segmentY + 1) + segmentX * 2 + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (this._matrixCahce[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexY * (segmentXD + 2); - var ddX = this._hullCache[4]; - var ddY = this._hullCache[5]; - var sX = this._hullCache[2] - (segmentY - indexY) * ddX; - var sY = this._hullCache[3] - (segmentY - indexY) * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(-lA, pY + dY, lB - lA, dY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(-lB, pY, lB - lA, dY, sX, sY, vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (x >= lA) { - if (y < -lA || y >= lA) { - return this.globalTransformMatrix; - } - // Right. - isDown = y > this._kX * (x - lB) + pY; - matrixIndex = ((segmentX * (segmentY + 1) + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (this._matrixCahce[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = (indexY + 1) * (segmentXD + 2) - 2; - var ddX = this._hullCache[4]; - var ddY = this._hullCache[5]; - var sX = this._hullCache[0] + indexY * ddX; - var sY = this._hullCache[1] + indexY * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(lB, pY + dY, lB - lA, dY, sX + ddX, sY + ddY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX, sY, Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(lA, pY, lB - lA, dY, vertices[vertexIndex], vertices[vertexIndex + 1], sX, sY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (y < -lA) { - if (x < -lA || x >= lA) { - return this.globalTransformMatrix; - } - // Up. - isDown = y > this._kY * (x - pX - dX) - lB; - matrixIndex = (segmentX * (segmentY + 1) + indexX * 2 + (isDown ? 1 : 0)) * 7; - if (this._matrixCahce[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexX * 2; - var ddX = this._hullCache[10]; - var ddY = this._hullCache[11]; - var sX = this._hullCache[8] + indexX * ddX; - var sY = this._hullCache[9] + indexX * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, -lA, dX, lB - lA, vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, -lB, dX, lB - lA, sX, sY, sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (y >= lA) { - if (x < -lA || x >= lA) { - return this.globalTransformMatrix; - } - // Down - isDown = y > this._kY * (x - pX - dX) + lA; - matrixIndex = ((segmentX * (segmentY + 1) + segmentX + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (this._matrixCahce[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = segmentY * (segmentXD + 2) + indexX * 2; - var ddX = this._hullCache[10]; - var ddY = this._hullCache[11]; - var sX = this._hullCache[6] - (segmentX - indexX) * ddX; - var sY = this._hullCache[7] - (segmentX - indexX) * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, lB, dX, lB - lA, sX + ddX, sY + ddY, sX, sY, vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, lA, dX, lB - lA, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], sX, sY, Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else { - isDown = y > this._k * (x - pX - dX) + pY; - matrixIndex = ((segmentX * indexY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (this._matrixCahce[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexX * 2 + indexY * (segmentXD + 2); - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, pY + dY, dX, dY, vertices[vertexIndex + segmentXD + 4], vertices[vertexIndex + segmentXD + 5], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, pY, dX, dY, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - return helpMatrix; - }; - /** - * @internal - * @private - */ - Surface.prototype.init = function (surfaceData, armatureValue) { - if (this._boneData !== null) { - return; - } - _super.prototype.init.call(this, surfaceData, armatureValue); - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var vertexCount = surfaceData.vertices.length; - var lB = 1000.0; - var lA = 200.0; - // - this._dX = lA * 2.0 / segmentX; - this._dY = lA * 2.0 / segmentY; - this._k = -this._dY / this._dX; - this._kX = -this._dY / (lB - lA); - this._kY = -(lB - lA) / this._dX; - this._vertices.length = vertexCount; - this._deformVertices.length = vertexCount; - this._matrixCahce.length = (segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7; - this._hullCache.length = 10; - for (var i = 0; i < vertexCount; ++i) { - this._deformVertices[i] = 0.0; - } - }; - /** - * @internal - */ - Surface.prototype.update = function (cacheFrameIndex) { - this._blendState.dirty = false; - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else { - if (this._hasConstraint) { - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - } - else { - if (this._hasConstraint) { - for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { - var constraint = _c[_b]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - if (this._transformDirty) { - this._transformDirty = false; - this._childrenTransformDirty = true; - // - for (var i = 0, l = this._matrixCahce.length; i < l; i += 7) { - this._matrixCahce[i] = -1.0; - } - // - this._updateVertices(); - // - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - if (this._localDirty) { - this._updateGlobalTransformMatrix(isCache); - } - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - // Update hull vertices. - var lB = 1000.0; - var lA = 200.0; - var ddX = 2 * this.global.x; - var ddY = 2 * this.global.y; - // - var helpPoint = Surface._helpPoint; - this.globalTransformMatrix.transformPoint(lB, -lA, helpPoint); - this._hullCache[0] = helpPoint.x; - this._hullCache[1] = helpPoint.y; - this._hullCache[2] = ddX - helpPoint.x; - this._hullCache[3] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint(0.0, this._dY, helpPoint, true); - this._hullCache[4] = helpPoint.x; - this._hullCache[5] = helpPoint.y; - // - this.globalTransformMatrix.transformPoint(lA, lB, helpPoint); - this._hullCache[6] = helpPoint.x; - this._hullCache[7] = helpPoint.y; - this._hullCache[8] = ddX - helpPoint.x; - this._hullCache[9] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint(this._dX, 0.0, helpPoint, true); - this._hullCache[10] = helpPoint.x; - this._hullCache[11] = helpPoint.y; - } - else if (this._childrenTransformDirty) { - this._childrenTransformDirty = false; - } - this._localDirty = true; - }; - return Surface; - }(dragonBones.Bone)); - dragonBones.Surface = Surface; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The slot attached to the armature, controls the display status and properties of the display object. - * A bone can contain multiple slots. - * A slot can contain multiple display objects, displaying only one of the display objects at a time, - * but you can toggle the display object into frame animation while the animation is playing. - * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, - * and a custom other display object. - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language zh_CN - */ - var Slot = /** @class */ (function (_super) { - __extends(Slot, _super); - function Slot() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._localMatrix = new dragonBones.Matrix(); - /** - * @internal - */ - _this._colorTransform = new dragonBones.ColorTransform(); - _this._displayDatas = []; - _this._displayList = []; - /** - * @internal - */ - _this._deformVertices = null; - _this._rawDisplay = null; // Initial value. - _this._meshDisplay = null; // Initial value. - return _this; - } - Slot.prototype._onClear = function () { - _super.prototype._onClear.call(this); - var disposeDisplayList = []; - for (var _i = 0, _a = this._displayList; _i < _a.length; _i++) { - var eachDisplay = _a[_i]; - if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && - disposeDisplayList.indexOf(eachDisplay) < 0) { - disposeDisplayList.push(eachDisplay); - } - } - for (var _b = 0, disposeDisplayList_1 = disposeDisplayList; _b < disposeDisplayList_1.length; _b++) { - var eachDisplay = disposeDisplayList_1[_b]; - if (eachDisplay instanceof dragonBones.Armature) { - eachDisplay.dispose(); - } - else { - this._disposeDisplay(eachDisplay, true); - } - } - if (this._deformVertices !== null) { - this._deformVertices.returnToPool(); - } - if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { - this._disposeDisplay(this._meshDisplay, false); - } - if (this._rawDisplay !== null) { - this._disposeDisplay(this._rawDisplay, false); - } - this.displayController = null; - this._displayDirty = false; - this._zOrderDirty = false; - this._blendModeDirty = false; - this._colorDirty = false; - this._transformDirty = false; - this._visible = true; - this._blendMode = 0 /* Normal */; - this._displayIndex = -1; - this._animationDisplayIndex = -1; - this._zOrder = 0; - this._cachedFrameIndex = -1; - this._pivotX = 0.0; - this._pivotY = 0.0; - this._localMatrix.identity(); - this._colorTransform.identity(); - this._displayList.length = 0; - this._displayDatas.length = 0; - this._slotData = null; // - this._rawDisplayDatas = null; - this._displayData = null; - this._boundingBoxData = null; - this._textureData = null; - this._deformVertices = null; - this._rawDisplay = null; - this._meshDisplay = null; - this._display = null; - this._childArmature = null; - this._parent = null; // - this._cachedFrameIndices = null; - }; - /** - * - Support default skin data. - */ - Slot.prototype._getDefaultRawDisplayData = function (displayIndex) { - var defaultSkin = this._armature._armatureData.defaultSkin; - if (defaultSkin !== null) { - var defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name); - if (defaultRawDisplayDatas !== null) { - return displayIndex < defaultRawDisplayDatas.length ? defaultRawDisplayDatas[displayIndex] : null; - } - } - return null; - }; - Slot.prototype._updateDisplayData = function () { - var prevDisplayData = this._displayData; - var prevVerticesData = this._deformVertices !== null ? this._deformVertices.verticesData : null; - var prevTextureData = this._textureData; - var rawDisplayData = null; - var currentVerticesData = null; - this._displayData = null; - this._boundingBoxData = null; - this._textureData = null; - if (this._displayIndex >= 0) { - if (this._rawDisplayDatas !== null) { - rawDisplayData = this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; - } - if (rawDisplayData === null) { - rawDisplayData = this._getDefaultRawDisplayData(this._displayIndex); - } - if (this._displayIndex < this._displayDatas.length) { - this._displayData = this._displayDatas[this._displayIndex]; - } - } - if (this._displayData !== null) { - if (this._displayData.type === 2 /* Mesh */) { - currentVerticesData = this._displayData.vertices; - } - else if (this._displayData.type === 4 /* Path */) { - currentVerticesData = this._displayData.vertices; - } - else if (rawDisplayData !== null) { - if (rawDisplayData.type === 2 /* Mesh */) { - currentVerticesData = rawDisplayData.vertices; - } - else if (rawDisplayData.type === 4 /* Path */) { - currentVerticesData = rawDisplayData.vertices; - } - } - if (this._displayData.type === 3 /* BoundingBox */) { - this._boundingBoxData = this._displayData.boundingBox; - } - else if (rawDisplayData !== null) { - if (rawDisplayData.type === 3 /* BoundingBox */) { - this._boundingBoxData = rawDisplayData.boundingBox; - } - } - if (this._displayData.type === 0 /* Image */) { - this._textureData = this._displayData.texture; - } - else if (this._displayData.type === 2 /* Mesh */) { - this._textureData = this._displayData.texture; - } - } - if (this._displayData !== prevDisplayData || currentVerticesData !== prevVerticesData || this._textureData !== prevTextureData) { - // Update pivot offset. - if (currentVerticesData === null && this._textureData !== null) { - var imageDisplayData = this._displayData; - var scale = this._textureData.parent.scale * this._armature._armatureData.scale; - var frame = this._textureData.frame; - this._pivotX = imageDisplayData.pivot.x; - this._pivotY = imageDisplayData.pivot.y; - var rect = frame !== null ? frame : this._textureData.region; - var width = rect.width; - var height = rect.height; - if (this._textureData.rotated && frame === null) { - width = rect.height; - height = rect.width; - } - this._pivotX *= width * scale; - this._pivotY *= height * scale; - if (frame !== null) { - this._pivotX += frame.x * scale; - this._pivotY += frame.y * scale; - } - // Update replace pivot. TODO - if (this._displayData !== null && rawDisplayData !== null && this._displayData !== rawDisplayData) { - rawDisplayData.transform.toMatrix(Slot._helpMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); - this._pivotX -= Slot._helpPoint.x; - this._pivotY -= Slot._helpPoint.y; - this._displayData.transform.toMatrix(Slot._helpMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); - this._pivotX += Slot._helpPoint.x; - this._pivotY += Slot._helpPoint.y; - } - if (!dragonBones.DragonBones.yDown) { - this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY; - } - } - else { - this._pivotX = 0.0; - this._pivotY = 0.0; - } - // Update original transform. - if (rawDisplayData !== null) { - this.origin = rawDisplayData.transform; - } - else if (this._displayData !== null) { - this.origin = this._displayData.transform; - } - else { - this.origin = null; - } - // Update vertices. - if (currentVerticesData !== prevVerticesData) { - if (this._deformVertices === null) { - this._deformVertices = dragonBones.BaseObject.borrowObject(dragonBones.DeformVertices); - } - this._deformVertices.init(currentVerticesData, this._armature); - } - else if (this._deformVertices !== null && this._textureData !== prevTextureData) { - this._deformVertices.verticesDirty = true; - } - this._displayDirty = true; - this._transformDirty = true; - } - }; - Slot.prototype._updateDisplay = function () { - var prevDisplay = this._display !== null ? this._display : this._rawDisplay; - var prevChildArmature = this._childArmature; - // Update display and child armature. - if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { - this._display = this._displayList[this._displayIndex]; - if (this._display !== null && this._display instanceof dragonBones.Armature) { - this._childArmature = this._display; - this._display = this._childArmature.display; - } - else { - this._childArmature = null; - } - } - else { - this._display = null; - this._childArmature = null; - } - // Update display. - var currentDisplay = this._display !== null ? this._display : this._rawDisplay; - if (currentDisplay !== prevDisplay) { - this._onUpdateDisplay(); - this._replaceDisplay(prevDisplay); - this._transformDirty = true; - this._visibleDirty = true; - this._blendModeDirty = true; - this._colorDirty = true; - } - // Update frame. - if (currentDisplay === this._rawDisplay || currentDisplay === this._meshDisplay) { - this._updateFrame(); - } - // Update child armature. - if (this._childArmature !== prevChildArmature) { - if (prevChildArmature !== null) { - prevChildArmature._parent = null; // Update child armature parent. - prevChildArmature.clock = null; - if (prevChildArmature.inheritAnimation) { - prevChildArmature.animation.reset(); - } - } - if (this._childArmature !== null) { - this._childArmature._parent = this; // Update child armature parent. - this._childArmature.clock = this._armature.clock; - if (this._childArmature.inheritAnimation) { - if (this._childArmature.cacheFrameRate === 0) { - var cacheFrameRate = this._armature.cacheFrameRate; - if (cacheFrameRate !== 0) { - this._childArmature.cacheFrameRate = cacheFrameRate; - } - } - // Child armature action. - var actions = null; - if (this._displayData !== null && this._displayData.type === 1 /* Armature */) { - actions = this._displayData.actions; - } - else if (this._displayIndex >= 0 && this._rawDisplayDatas !== null) { - var rawDisplayData = this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; - if (rawDisplayData === null) { - rawDisplayData = this._getDefaultRawDisplayData(this._displayIndex); - } - if (rawDisplayData !== null && rawDisplayData.type === 1 /* Armature */) { - actions = rawDisplayData.actions; - } - } - if (actions !== null && actions.length > 0) { - for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { - var action = actions_1[_i]; - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - eventObject.slot = this; - this._armature._bufferAction(eventObject, false); - } - } - else { - this._childArmature.animation.play(); - } - } - } - } - }; - Slot.prototype._updateGlobalTransformMatrix = function (isCache) { - var parentMatrix = this._parent._boneData.type === 0 /* Bone */ ? this._parent.globalTransformMatrix : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); - this.globalTransformMatrix.copyFrom(this._localMatrix); - this.globalTransformMatrix.concat(parentMatrix); - if (isCache) { - this.global.fromMatrix(this.globalTransformMatrix); - } - else { - this._globalDirty = true; - } - }; - /** - * @internal - */ - Slot.prototype._setDisplayIndex = function (value, isAnimation) { - if (isAnimation === void 0) { isAnimation = false; } - if (isAnimation) { - if (this._animationDisplayIndex === value) { - return false; - } - this._animationDisplayIndex = value; - } - if (this._displayIndex === value) { - return false; - } - this._displayIndex = value; - this._displayDirty = true; - this._updateDisplayData(); - return this._displayDirty; - }; - /** - * @internal - */ - Slot.prototype._setZorder = function (value) { - if (this._zOrder === value) { - //return false; - } - this._zOrder = value; - this._zOrderDirty = true; - return this._zOrderDirty; - }; - /** - * @internal - */ - Slot.prototype._setColor = function (value) { - this._colorTransform.copyFrom(value); - this._colorDirty = true; - return this._colorDirty; - }; - /** - * @internal - */ - Slot.prototype._setDisplayList = function (value) { - if (value !== null && value.length > 0) { - if (this._displayList.length !== value.length) { - this._displayList.length = value.length; - } - for (var i = 0, l = value.length; i < l; ++i) { - var eachDisplay = value[i]; - if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && - !(eachDisplay instanceof dragonBones.Armature) && this._displayList.indexOf(eachDisplay) < 0) { - this._initDisplay(eachDisplay, true); - } - this._displayList[i] = eachDisplay; - } - } - else if (this._displayList.length > 0) { - this._displayList.length = 0; - } - if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { - this._displayDirty = this._display !== this._displayList[this._displayIndex]; - } - else { - this._displayDirty = this._display !== null; - } - this._updateDisplayData(); - return this._displayDirty; - }; - /** - * @internal - */ - Slot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { - if (this._slotData !== null) { - return; - } - this._slotData = slotData; - // - this._visibleDirty = true; - this._blendModeDirty = true; - this._colorDirty = true; - this._blendMode = this._slotData.blendMode; - this._zOrder = this._slotData.zOrder; - this._colorTransform.copyFrom(this._slotData.color); - this._rawDisplay = rawDisplay; - this._meshDisplay = meshDisplay; - // - this._armature = armatureValue; - // - var slotParent = this._armature.getBone(this._slotData.parent.name); - if (slotParent !== null) { - this._parent = slotParent; - } - else { - // Never; - } - this._armature._addSlot(this); - // - this._initDisplay(this._rawDisplay, false); - if (this._rawDisplay !== this._meshDisplay) { - this._initDisplay(this._meshDisplay, false); - } - this._onUpdateDisplay(); - this._addDisplay(); - }; - /** - * @internal - */ - Slot.prototype.update = function (cacheFrameIndex) { - if (this._displayDirty) { - this._displayDirty = false; - this._updateDisplay(); - // TODO remove slot offset. - if (this._transformDirty) { - if (this.origin !== null) { - this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); - } - else { - this.global.copyFrom(this.offset).toMatrix(this._localMatrix); - } - } - } - if (this._zOrderDirty) { - this._zOrderDirty = false; - this._updateZOrder(); - } - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else if (this._transformDirty || this._parent._childrenTransformDirty) { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - else if (this._transformDirty || this._parent._childrenTransformDirty) { - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - if (this._display === null) { - return; - } - if (this._visibleDirty) { - this._visibleDirty = false; - this._updateVisible(); - } - if (this._blendModeDirty) { - this._blendModeDirty = false; - this._updateBlendMode(); - } - if (this._colorDirty) { - this._colorDirty = false; - this._updateColor(); - } - if (this._deformVertices !== null && this._deformVertices.verticesData !== null && this._display === this._meshDisplay) { - var isSkinned = this._deformVertices.verticesData.weight !== null; - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - if (this._deformVertices.verticesDirty || - (isSkinned && this._deformVertices.isBonesUpdate()) || - (isSurface && this._parent._childrenTransformDirty)) { - this._deformVertices.verticesDirty = false; - this._updateMesh(); - } - if (isSkinned || isSurface) { - return; - } - } - if (this._transformDirty) { - this._transformDirty = false; - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - this._updateGlobalTransformMatrix(isCache); - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - this._updateTransform(); - } - }; - /** - * @private - */ - Slot.prototype.updateTransformAndMatrix = function () { - if (this._transformDirty) { - this._transformDirty = false; - this._updateGlobalTransformMatrix(false); - } - }; - /** - * @private - */ - Slot.prototype.replaceDisplayData = function (value, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - if (displayIndex < 0) { - if (this._displayIndex < 0) { - displayIndex = 0; - } - else { - displayIndex = this._displayIndex; - } - } - if (this._displayDatas.length <= displayIndex) { - this._displayDatas.length = displayIndex + 1; - for (var i = 0, l = this._displayDatas.length; i < l; ++i) { - if (!this._displayDatas[i]) { - this._displayDatas[i] = null; - } - } - } - this._displayDatas[displayIndex] = value; - }; - /** - * - Check whether a specific point is inside a custom bounding box in the slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Slot.prototype.containsPoint = function (x, y) { - if (this._boundingBoxData === null) { - return false; - } - this.updateTransformAndMatrix(); - Slot._helpMatrix.copyFrom(this.globalTransformMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint); - return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y); - }; - /** - * - Check whether a specific segment intersects a custom bounding box for the slot. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] - * @version DragonBones 5.0 - * @language zh_CN - */ - Slot.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - if (this._boundingBoxData === null) { - return 0; - } - this.updateTransformAndMatrix(); - Slot._helpMatrix.copyFrom(this.globalTransformMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(xA, yA, Slot._helpPoint); - xA = Slot._helpPoint.x; - yA = Slot._helpPoint.y; - Slot._helpMatrix.transformPoint(xB, yB, Slot._helpPoint); - xB = Slot._helpPoint.x; - yB = Slot._helpPoint.y; - var intersectionCount = this._boundingBoxData.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); - if (intersectionCount > 0) { - if (intersectionCount === 1 || intersectionCount === 2) { - if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); - if (intersectionPointB !== null) { - intersectionPointB.x = intersectionPointA.x; - intersectionPointB.y = intersectionPointA.y; - } - } - else if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); - } - } - else { - if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); - } - if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); - } - } - if (normalRadians !== null) { - this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.x), Math.sin(normalRadians.x), Slot._helpPoint, true); - normalRadians.x = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); - this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.y), Math.sin(normalRadians.y), Slot._helpPoint, true); - normalRadians.y = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); - } - } - return intersectionCount; - }; - /** - * - Forces the slot to update the state of the display object in the next frame. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 强制插槽在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Slot.prototype.invalidUpdate = function () { - this._displayDirty = true; - this._transformDirty = true; - }; - Object.defineProperty(Slot.prototype, "visible", { - /** - * - The visible of slot's display object. - * @default true - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 插槽的显示对象的可见。 - * @default true - * @version DragonBones 5.6 - * @language zh_CN - */ - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible === value) { - return; - } - this._visible = value; - this._updateVisible(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayIndex", { - /** - * - The index of the display object displayed in the display list. - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     slot.displayIndex = 3;
-             *     slot.displayController = "none";
-             * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 此时显示的显示对象在显示列表中的索引。 - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     slot.displayIndex = 3;
-             *     slot.displayController = "none";
-             * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._displayIndex; - }, - set: function (value) { - if (this._setDisplayIndex(value)) { - this.update(-1); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "name", { - /** - * - The slot name. - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._slotData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayList", { - /** - * - Contains a display list of display objects or child armatures. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 包含显示对象或子骨架的显示列表。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._displayList.concat(); - }, - set: function (value) { - var backupDisplayList = this._displayList.concat(); // Copy. - var disposeDisplayList = new Array(); - if (this._setDisplayList(value)) { - this.update(-1); - } - // Release replaced displays. - for (var _i = 0, backupDisplayList_1 = backupDisplayList; _i < backupDisplayList_1.length; _i++) { - var eachDisplay = backupDisplayList_1[_i]; - if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && - this._displayList.indexOf(eachDisplay) < 0 && - disposeDisplayList.indexOf(eachDisplay) < 0) { - disposeDisplayList.push(eachDisplay); - } - } - for (var _a = 0, disposeDisplayList_2 = disposeDisplayList; _a < disposeDisplayList_2.length; _a++) { - var eachDisplay = disposeDisplayList_2[_a]; - if (eachDisplay instanceof dragonBones.Armature) { - // (eachDisplay as Armature).dispose(); - } - else { - this._disposeDisplay(eachDisplay, true); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "slotData", { - /** - * - The slot data. - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._slotData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "rawDisplayDatas", { - /** - * @private - */ - get: function () { - return this._rawDisplayDatas; - }, - set: function (value) { - if (this._rawDisplayDatas === value) { - return; - } - this._displayDirty = true; - this._rawDisplayDatas = value; - if (this._rawDisplayDatas !== null) { - this._displayDatas.length = this._rawDisplayDatas.length; - for (var i = 0, l = this._displayDatas.length; i < l; ++i) { - var rawDisplayData = this._rawDisplayDatas[i]; - if (rawDisplayData === null) { - rawDisplayData = this._getDefaultRawDisplayData(i); - } - this._displayDatas[i] = rawDisplayData; - } - } - else { - this._displayDatas.length = 0; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayData", { - /** - * @private - */ - get: function () { - return this._displayData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "boundingBoxData", { - /** - * - The custom bounding box data for the slot at current time. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 插槽此时的自定义包围盒数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - get: function () { - return this._boundingBoxData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "rawDisplay", { - /** - * @private - */ - get: function () { - return this._rawDisplay; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "meshDisplay", { - /** - * @private - */ - get: function () { - return this._meshDisplay; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "display", { - /** - * - The display object that the slot displays at this time. - * @example - *
-             *     let slot = armature.getSlot("text");
-             *     slot.display = new yourEngine.TextField();
-             * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的显示对象。 - * @example - *
-             *     let slot = armature.getSlot("text");
-             *     slot.display = new yourEngine.TextField();
-             * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._display; - }, - set: function (value) { - if (this._display === value) { - return; - } - var displayListLength = this._displayList.length; - if (this._displayIndex < 0 && displayListLength === 0) { - this._displayIndex = 0; - } - if (this._displayIndex < 0) { - return; - } - else { - var replaceDisplayList = this.displayList; // Copy. - if (displayListLength <= this._displayIndex) { - replaceDisplayList.length = this._displayIndex + 1; - } - replaceDisplayList[this._displayIndex] = value; - this.displayList = replaceDisplayList; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "childArmature", { - /** - * - The child armature that the slot displayed at current time. - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             * let prevChildArmature = slot.childArmature;
-             * if (prevChildArmature) {
-             * prevChildArmature.dispose();
-             *     }
-             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-             * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的子骨架。 - * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             * let prevChildArmature = slot.childArmature;
-             * if (prevChildArmature) {
-             * prevChildArmature.dispose();
-             *     }
-             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-             * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._childArmature; - }, - set: function (value) { - if (this._childArmature === value) { - return; - } - this.display = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "parent", { - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Slot.prototype.getDisplay = function () { - return this._display; - }; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Slot.prototype.setDisplay = function (value) { - this.display = value; - }; - return Slot; - }(dragonBones.TransformObject)); - dragonBones.Slot = Slot; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var Constraint = /** @class */ (function (_super) { - __extends(Constraint, _super); - function Constraint() { - return _super !== null && _super.apply(this, arguments) || this; - } - Constraint.prototype._onClear = function () { - this._armature = null; // - this._target = null; // - this._root = null; // - this._bone = null; - }; - Object.defineProperty(Constraint.prototype, "name", { - get: function () { - return this._constraintData.name; - }, - enumerable: true, - configurable: true - }); - Constraint._helpMatrix = new dragonBones.Matrix(); - Constraint._helpTransform = new dragonBones.Transform(); - Constraint._helpPoint = new dragonBones.Point(); - return Constraint; - }(dragonBones.BaseObject)); - dragonBones.Constraint = Constraint; - /** - * @internal - */ - var IKConstraint = /** @class */ (function (_super) { - __extends(IKConstraint, _super); - function IKConstraint() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraint.toString = function () { - return "[class dragonBones.IKConstraint]"; - }; - IKConstraint.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._scaleEnabled = false; - this._bendPositive = false; - this._weight = 1.0; - this._constraintData = null; - }; - IKConstraint.prototype._computeA = function () { - var ikGlobal = this._target.global; - var global = this._root.global; - var globalTransformMatrix = this._root.globalTransformMatrix; - var radian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); - if (global.scaleX < 0.0) { - radian += Math.PI; - } - global.rotation += dragonBones.Transform.normalizeRadian(radian - global.rotation) * this._weight; - global.toMatrix(globalTransformMatrix); - }; - IKConstraint.prototype._computeB = function () { - var boneLength = this._bone._boneData.length; - var parent = this._root; - var ikGlobal = this._target.global; - var parentGlobal = parent.global; - var global = this._bone.global; - var globalTransformMatrix = this._bone.globalTransformMatrix; - var x = globalTransformMatrix.a * boneLength; - var y = globalTransformMatrix.b * boneLength; - var lLL = x * x + y * y; - var lL = Math.sqrt(lLL); - var dX = global.x - parentGlobal.x; - var dY = global.y - parentGlobal.y; - var lPP = dX * dX + dY * dY; - var lP = Math.sqrt(lPP); - var rawRadian = global.rotation; - var rawParentRadian = parentGlobal.rotation; - var rawRadianA = Math.atan2(dY, dX); - dX = ikGlobal.x - parentGlobal.x; - dY = ikGlobal.y - parentGlobal.y; - var lTT = dX * dX + dY * dY; - var lT = Math.sqrt(lTT); - var radianA = 0.0; - if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { - radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); - if (lL + lP <= lT) { - } - else if (lP < lL) { - radianA += Math.PI; - } - } - else { - var h = (lPP - lLL + lTT) / (2.0 * lTT); - var r = Math.sqrt(lPP - h * h * lTT) / lT; - var hX = parentGlobal.x + (dX * h); - var hY = parentGlobal.y + (dY * h); - var rX = -dY * r; - var rY = dX * r; - var isPPR = false; - var parentParent = parent.parent; - if (parentParent !== null) { - var parentParentMatrix = parentParent.globalTransformMatrix; - isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0.0; - } - if (isPPR !== this._bendPositive) { - global.x = hX - rX; - global.y = hY - rY; - } - else { - global.x = hX + rX; - global.y = hY + rY; - } - radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); - } - var dR = dragonBones.Transform.normalizeRadian(radianA - rawRadianA); - parentGlobal.rotation = rawParentRadian + dR * this._weight; - parentGlobal.toMatrix(parent.globalTransformMatrix); - // - var currentRadianA = rawRadianA + dR * this._weight; - global.x = parentGlobal.x + Math.cos(currentRadianA) * lP; - global.y = parentGlobal.y + Math.sin(currentRadianA) * lP; - // - var radianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); - if (global.scaleX < 0.0) { - radianB += Math.PI; - } - global.rotation = parentGlobal.rotation + rawRadian - rawParentRadian + dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight; - global.toMatrix(globalTransformMatrix); - }; - IKConstraint.prototype.init = function (constraintData, armature) { - if (this._constraintData !== null) { - return; - } - this._constraintData = constraintData; - this._armature = armature; - this._target = this._armature.getBone(this._constraintData.target.name); - this._root = this._armature.getBone(this._constraintData.root.name); - this._bone = this._constraintData.bone !== null ? this._armature.getBone(this._constraintData.bone.name) : null; - { - var ikConstraintData = this._constraintData; - this._scaleEnabled = ikConstraintData.scaleEnabled; - this._bendPositive = ikConstraintData.bendPositive; - this._weight = ikConstraintData.weight; - } - this._root._hasConstraint = true; - }; - IKConstraint.prototype.update = function () { - this._root.updateByConstraint(); - if (this._bone !== null) { - this._bone.updateByConstraint(); - this._computeB(); - } - else { - this._computeA(); - } - }; - IKConstraint.prototype.invalidUpdate = function () { - this._root.invalidUpdate(); - if (this._bone !== null) { - this._bone.invalidUpdate(); - } - }; - return IKConstraint; - }(Constraint)); - dragonBones.IKConstraint = IKConstraint; - /** - * @internal - */ - var PathConstraint = /** @class */ (function (_super) { - __extends(PathConstraint, _super); - function PathConstraint() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._bones = []; - _this._spaces = []; - _this._positions = []; - _this._curves = []; - _this._boneLengths = []; - _this._pathGlobalVertices = []; - _this._segments = [10]; - return _this; - } - PathConstraint.toString = function () { - return "[class dragonBones.PathConstraint]"; - }; - PathConstraint.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.dirty = false; - this.pathOffset = 0; - this.position = 0.0; - this.spacing = 0.0; - this.rotateOffset = 0.0; - this.rotateMix = 1.0; - this.translateMix = 1.0; - this._pathSlot = null; - this._bones.length = 0; - this._spaces.length = 0; - this._positions.length = 0; - this._curves.length = 0; - this._boneLengths.length = 0; - this._pathGlobalVertices.length = 0; - }; - PathConstraint.prototype._updatePathVertices = function (verticesData) { - //计算曲线的节点数据 - var armature = this._armature; - var dragonBonesData = armature.armatureData.parent; - var scale = armature.armatureData.scale; - var intArray = dragonBonesData.intArray; - var floatArray = dragonBonesData.floatArray; - var pathOffset = verticesData.offset; - var pathVertexCount = intArray[pathOffset + 0 /* PathVertexCount */]; - var pathVertexOffset = intArray[pathOffset + 2 /* PathFloatOffset */]; - this._pathGlobalVertices.length = pathVertexCount * 2; - var weightData = verticesData.weight; - //没有骨骼约束我,那节点只受自己的Bone控制 - if (weightData === null) { - var parentBone = this._pathSlot.parent; - parentBone.updateByConstraint(); - var matrix = parentBone.globalTransformMatrix; - for (var i = 0, iV_1 = pathVertexOffset; i < pathVertexCount; i += 2) { - var vx = floatArray[iV_1++] * scale; - var vy = floatArray[iV_1++] * scale; - var x = matrix.a * vx + matrix.c * vy + matrix.tx; - var y = matrix.b * vx + matrix.d * vy + matrix.ty; - // - this._pathGlobalVertices[i] = x; - this._pathGlobalVertices[i + 1] = y; - } - return; - } - //有骨骼约束我,那我的节点受骨骼权重控制 - var bones = this._pathSlot._deformVertices.bones; - var weightBoneCount = weightData.bones.length; - var weightOffset = weightData.offset; - var floatOffset = intArray[weightOffset + 1 /* WeigthFloatOffset */]; - var iV = floatOffset; - var iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount; - for (var i = 0, iW = 0; i < pathVertexCount; i++) { - var vertexBoneCount = intArray[iB++]; // - var xG = 0.0, yG = 0.0; - for (var ii = 0, ll = vertexBoneCount; ii < ll; ii++) { - var boneIndex = intArray[iB++]; - var bone = bones[boneIndex]; - if (bone === null) { - continue; - } - bone.updateByConstraint(); - var matrix = bone.globalTransformMatrix; - var weight = floatArray[iV++]; - var vx = floatArray[iV++] * scale; - var vy = floatArray[iV++] * scale; - xG += (matrix.a * vx + matrix.c * vy + matrix.tx) * weight; - yG += (matrix.b * vx + matrix.d * vy + matrix.ty) * weight; - } - this._pathGlobalVertices[iW++] = xG; - this._pathGlobalVertices[iW++] = yG; - } - }; - PathConstraint.prototype._computeVertices = function (start, count, offset, out) { - //TODO优化 - for (var i = offset, iW = start; i < count; i += 2) { - out[i] = this._pathGlobalVertices[iW++]; - out[i + 1] = this._pathGlobalVertices[iW++]; - } - }; - PathConstraint.prototype._computeBezierCurve = function (pathDisplayDta, spaceCount, tangents, percentPosition, percentSpacing) { - //计算当前的骨骼在曲线上的位置 - var armature = this._armature; - var intArray = armature.armatureData.parent.intArray; - var vertexCount = intArray[pathDisplayDta.vertices.offset + 0 /* PathVertexCount */]; - var positions = this._positions; - var spaces = this._spaces; - var isClosed = pathDisplayDta.closed; - var curveVertices = Array(); - var verticesLength = vertexCount * 2; - var curveCount = verticesLength / 6; - var preCurve = -1; - var position = this.position; - positions.length = spaceCount * 3 + 2; - var pathLength = 0.0; - //不需要匀速运动,效率高些 - if (!pathDisplayDta.constantSpeed) { - var lenghts = pathDisplayDta.curveLengths; - curveCount -= isClosed ? 1 : 2; - pathLength = lenghts[curveCount]; - if (percentPosition) { - position *= pathLength; - } - if (percentSpacing) { - for (var i = 0; i < spaceCount; i++) { - spaces[i] *= pathLength; - } - } - curveVertices.length = 8; - for (var i = 0, o = 0, curve = 0; i < spaceCount; i++, o += 3) { - var space = spaces[i]; - position += space; - if (isClosed) { - position %= pathLength; - if (position < 0) { - position += pathLength; - } - curve = 0; - } - else if (position < 0) { - //TODO - continue; - } - else if (position > pathLength) { - //TODO - continue; - } - var percent = 0.0; - for (;; curve++) { - var len = lenghts[curve]; - if (position > len) { - continue; - } - if (curve === 0) { - percent = position / len; - } - else { - var preLen = lenghts[curve - 1]; - percent = (position - preLen) / (len - preLen); - } - break; - } - if (curve !== preCurve) { - preCurve = curve; - if (isClosed && curve === curveCount) { - //计算曲线 - this._computeVertices(verticesLength - 4, 4, 0, curveVertices); - this._computeVertices(0, 4, 4, curveVertices); - } - else { - this._computeVertices(curve * 6 + 2, 8, 0, curveVertices); - } - } - // - this.addCurvePosition(percent, curveVertices[0], curveVertices[1], curveVertices[2], curveVertices[3], curveVertices[4], curveVertices[5], curveVertices[6], curveVertices[7], positions, o, tangents); - } - return; - } - //匀速的 - if (isClosed) { - verticesLength += 2; - curveVertices.length = vertexCount; - this._computeVertices(2, verticesLength - 4, 0, curveVertices); - this._computeVertices(0, 2, verticesLength - 4, curveVertices); - curveVertices[verticesLength - 2] = curveVertices[0]; - curveVertices[verticesLength - 1] = curveVertices[1]; - } - else { - curveCount--; - verticesLength -= 4; - curveVertices.length = verticesLength; - this._computeVertices(2, verticesLength, 0, curveVertices); - } - // - var curves = new Array(curveCount); - pathLength = 0; - var x1 = curveVertices[0], y1 = curveVertices[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; - var tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy; - for (var i = 0, w = 2; i < curveCount; i++, w += 6) { - cx1 = curveVertices[w]; - cy1 = curveVertices[w + 1]; - cx2 = curveVertices[w + 2]; - cy2 = curveVertices[w + 3]; - x2 = curveVertices[w + 4]; - y2 = curveVertices[w + 5]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; - tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - curves[i] = pathLength; - x1 = x2; - y1 = y2; - } - if (percentPosition) { - position *= pathLength; - } - if (percentSpacing) { - for (var i = 0; i < spaceCount; i++) { - spaces[i] *= pathLength; - } - } - var segments = this._segments; - var curveLength = 0; - for (var i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) { - var space = spaces[i]; - position += space; - var p = position; - if (isClosed) { - p %= pathLength; - if (p < 0) - p += pathLength; - curve = 0; - } - else if (p < 0) { - continue; - } - else if (p > pathLength) { - continue; - } - // Determine curve containing position. - for (;; curve++) { - var length_1 = curves[curve]; - if (p > length_1) - continue; - if (curve === 0) - p /= length_1; - else { - var prev = curves[curve - 1]; - p = (p - prev) / (length_1 - prev); - } - break; - } - if (curve !== preCurve) { - preCurve = curve; - var ii = curve * 6; - x1 = curveVertices[ii]; - y1 = curveVertices[ii + 1]; - cx1 = curveVertices[ii + 2]; - cy1 = curveVertices[ii + 3]; - cx2 = curveVertices[ii + 4]; - cy2 = curveVertices[ii + 5]; - x2 = curveVertices[ii + 6]; - y2 = curveVertices[ii + 7]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.03; - tmpy = (y1 - cy1 * 2 + cy2) * 0.03; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; - curveLength = Math.sqrt(dfx * dfx + dfy * dfy); - segments[0] = curveLength; - for (ii = 1; ii < 8; ii++) { - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[ii] = curveLength; - } - dfx += ddfx; - dfy += ddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[8] = curveLength; - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[9] = curveLength; - segment = 0; - } - // Weight by segment length. - p *= curveLength; - for (;; segment++) { - var length_2 = segments[segment]; - if (p > length_2) - continue; - if (segment === 0) - p /= length_2; - else { - var prev = segments[segment - 1]; - p = segment + (p - prev) / (length_2 - prev); - } - break; - } - this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents); - } - }; - //Calculates a point on the curve, for a given t value between 0 and 1. - PathConstraint.prototype.addCurvePosition = function (t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents) { - if (t === 0) { - out[offset] = x1; - out[offset + 1] = y1; - out[offset + 2] = 0; - return; - } - if (t === 1) { - out[offset] = x2; - out[offset + 1] = y2; - out[offset + 2] = 0; - return; - } - var mt = 1 - t; - var mt2 = mt * mt; - var t2 = t * t; - var a = mt2 * mt; - var b = mt2 * t * 3; - var c = mt * t2 * 3; - var d = t * t2; - var x = a * x1 + b * cx1 + c * cx2 + d * x2; - var y = a * y1 + b * cy1 + c * cy2 + d * y2; - out[offset] = x; - out[offset + 1] = y; - if (tangents) { - //Calculates the curve tangent at the specified t value - out[offset + 2] = Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2)); - } - else { - out[offset + 2] = 0; - } - }; - PathConstraint.prototype.init = function (constraintData, armature) { - this._constraintData = constraintData; - this._armature = armature; - var data = constraintData; - this.pathOffset = data.pathDisplayData.vertices.offset; - // - this.position = data.position; - this.spacing = data.spacing; - this.rotateOffset = data.rotateOffset; - this.rotateMix = data.rotateMix; - this.translateMix = data.translateMix; - // - this._root = this._armature.getBone(data.root.name); - this._target = this._armature.getBone(data.target.name); - this._pathSlot = this._armature.getSlot(data.pathSlot.name); - for (var i = 0, l = data.bones.length; i < l; i++) { - var bone = this._armature.getBone(data.bones[i].name); - if (bone !== null) { - this._bones.push(bone); - } - } - if (data.rotateMode === 2 /* ChainScale */) { - this._boneLengths.length = this._bones.length; - } - this._root._hasConstraint = true; - }; - PathConstraint.prototype.update = function () { - var pathSlot = this._pathSlot; - if (pathSlot._deformVertices === null || - pathSlot._deformVertices.verticesData === null || - pathSlot._deformVertices.verticesData.offset !== this.pathOffset) { - return; - } - var constraintData = this._constraintData; - var pathDisplayData = pathSlot._displayData; // TODO - // - //曲线节点数据改变:父亲bone改变,权重bones改变,变形顶点改变 - var isPathVerticeDirty = false; - var deformVertices = pathSlot._deformVertices; - if (this._root._childrenTransformDirty) { - this._updatePathVertices(pathDisplayData.vertices); - isPathVerticeDirty = true; - } - else if (deformVertices !== null && (deformVertices.verticesDirty || deformVertices.isBonesUpdate())) { - this._updatePathVertices(pathDisplayData.vertices); - deformVertices.verticesDirty = false; - isPathVerticeDirty = true; - } - if (!isPathVerticeDirty && !this.dirty) { - return; - } - // - var positionMode = constraintData.positionMode; - var spacingMode = constraintData.spacingMode; - var rotateMode = constraintData.rotateMode; - var bones = this._bones; - var isLengthMode = spacingMode === 0 /* Length */; - var isChainScaleMode = rotateMode === 2 /* ChainScale */; - var isTangentMode = rotateMode === 0 /* Tangent */; - var boneCount = bones.length; - var spacesCount = isTangentMode ? boneCount : boneCount + 1; - var spacing = this.spacing; - var spaces = this._spaces; - spaces.length = spacesCount; - //计曲线间隔和长度 - if (isChainScaleMode || isLengthMode) { - //Bone改变和spacing改变触发 - spaces[0] = 0; - for (var i = 0, l = spacesCount - 1; i < l; i++) { - var bone = bones[i]; - bone.updateByConstraint(); - var boneLength = bone._boneData.length; - var matrix = bone.globalTransformMatrix; - var x = boneLength * matrix.a; - var y = boneLength * matrix.b; - var len = Math.sqrt(x * x + y * y); - if (isChainScaleMode) { - this._boneLengths[i] = len; - } - spaces[i + 1] = (boneLength + spacing) * len / boneLength; - } - } - else { - for (var i = 0; i < spacesCount; i++) { - spaces[i] = spacing; - } - } - // - this._computeBezierCurve(pathDisplayData, spacesCount, isTangentMode, positionMode === 1 /* Percent */, spacingMode === 2 /* Percent */); - //根据新的节点数据重新采样 - var positions = this._positions; - var rotateOffset = this.rotateOffset; - var boneX = positions[0], boneY = positions[1]; - var tip; - if (rotateOffset === 0) { - tip = rotateMode === 1 /* Chain */; - } - else { - tip = false; - var bone = pathSlot.parent; - if (bone !== null) { - var matrix = bone.globalTransformMatrix; - rotateOffset *= matrix.a * matrix.d - matrix.b * matrix.c > 0 ? dragonBones.Transform.DEG_RAD : -dragonBones.Transform.DEG_RAD; - } - } - // - var rotateMix = this.rotateMix; - var translateMix = this.translateMix; - for (var i = 0, p = 3; i < boneCount; i++, p += 3) { - var bone = bones[i]; - bone.updateByConstraint(); - var matrix = bone.globalTransformMatrix; - matrix.tx += (boneX - matrix.tx) * translateMix; - matrix.ty += (boneY - matrix.ty) * translateMix; - var x = positions[p], y = positions[p + 1]; - var dx = x - boneX, dy = y - boneY; - if (isChainScaleMode) { - var lenght = this._boneLengths[i]; - var s = (Math.sqrt(dx * dx + dy * dy) / lenght - 1) * rotateMix + 1; - matrix.a *= s; - matrix.b *= s; - } - boneX = x; - boneY = y; - if (rotateMix > 0) { - var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, r = void 0, cos = void 0, sin = void 0; - if (isTangentMode) { - r = positions[p - 1]; - } - else { - r = Math.atan2(dy, dx); - } - r -= Math.atan2(b, a); - if (tip) { - cos = Math.cos(r); - sin = Math.sin(r); - var length_3 = bone._boneData.length; - boneX += (length_3 * (cos * a - sin * b) - dx) * rotateMix; - boneY += (length_3 * (sin * a + cos * b) - dy) * rotateMix; - } - else { - r += rotateOffset; - } - if (r > dragonBones.Transform.PI) { - r -= dragonBones.Transform.PI_D; - } - else if (r < -dragonBones.Transform.PI) { - r += dragonBones.Transform.PI_D; - } - r *= rotateMix; - cos = Math.cos(r); - sin = Math.sin(r); - matrix.a = cos * a - sin * b; - matrix.b = sin * a + cos * b; - matrix.c = cos * c - sin * d; - matrix.d = sin * c + cos * d; - } - bone.global.fromMatrix(matrix); - } - this.dirty = false; - }; - PathConstraint.prototype.invalidUpdate = function () { - }; - return PathConstraint; - }(Constraint)); - dragonBones.PathConstraint = PathConstraint; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - var WorldClock = /** @class */ (function () { - /** - * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. - * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 - * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 - * @version DragonBones 3.0 - * @language zh_CN - */ - function WorldClock(time) { - if (time === void 0) { time = 0.0; } - /** - * - Current time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - this.time = 0.0; - /** - * - The play speed, used to control animation speed-shift play. - * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度,用于控制动画变速播放。 - * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - this.timeScale = 1.0; - this._systemTime = 0.0; - this._animatebles = []; - this._clock = null; - this.time = time; - this._systemTime = new Date().getTime() * 0.001; - } - /** - * - Advance time for all IAnimatable instances. - * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 为所有的 IAnimatable 实例更新时间。 - * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.advanceTime = function (passedTime) { - if (passedTime !== passedTime) { - passedTime = 0.0; - } - var currentTime = Date.now() * 0.001; - if (passedTime < 0.0) { - passedTime = currentTime - this._systemTime; - } - this._systemTime = currentTime; - if (this.timeScale !== 1.0) { - passedTime *= this.timeScale; - } - if (passedTime === 0.0) { - return; - } - if (passedTime < 0.0) { - this.time -= passedTime; - } - else { - this.time += passedTime; - } - var i = 0, r = 0, l = this._animatebles.length; - for (; i < l; ++i) { - var animatable = this._animatebles[i]; - if (animatable !== null) { - if (r > 0) { - this._animatebles[i - r] = animatable; - this._animatebles[i] = null; - } - animatable.advanceTime(passedTime); - } - else { - r++; - } - } - if (r > 0) { - l = this._animatebles.length; - for (; i < l; ++i) { - var animateble = this._animatebles[i]; - if (animateble !== null) { - this._animatebles[i - r] = animateble; - } - else { - r++; - } - } - this._animatebles.length -= r; - } - }; - /** - * - Check whether contains a specific instance of IAnimatable. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.contains = function (value) { - if (value === this) { - return false; - } - var ancestor = value; - while (ancestor !== this && ancestor !== null) { - ancestor = ancestor.clock; - } - return ancestor === this; - }; - /** - * - Add IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.add = function (value) { - if (this._animatebles.indexOf(value) < 0) { - this._animatebles.push(value); - value.clock = this; - } - }; - /** - * - Removes a specified IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.remove = function (value) { - var index = this._animatebles.indexOf(value); - if (index >= 0) { - this._animatebles[index] = null; - value.clock = null; - } - }; - /** - * - Clear all IAnimatable instances. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.clear = function () { - for (var _i = 0, _a = this._animatebles; _i < _a.length; _i++) { - var animatable = _a[_i]; - if (animatable !== null) { - animatable.clock = null; - } - } - }; - Object.defineProperty(WorldClock.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - if (this._clock !== null) { - this._clock.remove(this); - } - this._clock = value; - if (this._clock !== null) { - this._clock.add(this); - } - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#clock}。 - * @deprecated - * @language zh_CN - */ - WorldClock.clock = new WorldClock(); - return WorldClock; - }()); - dragonBones.WorldClock = WorldClock; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The animation player is used to play the animation data and manage the animation states. - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器用来播放动画数据和管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - var Animation = /** @class */ (function (_super) { - __extends(Animation, _super); - function Animation() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._animationNames = []; - _this._animationStates = []; - _this._animations = {}; - _this._animationConfig = null; // Initial value. - return _this; - } - Animation.toString = function () { - return "[class dragonBones.Animation]"; - }; - Animation.prototype._onClear = function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.returnToPool(); - } - for (var k in this._animations) { - delete this._animations[k]; - } - if (this._animationConfig !== null) { - this._animationConfig.returnToPool(); - } - this.timeScale = 1.0; - this._lockUpdate = false; - this._animationDirty = false; - this._inheritTimeScale = 1.0; - this._animationNames.length = 0; - this._animationStates.length = 0; - //this._animations.clear(); - this._armature = null; // - this._animationConfig = null; // - this._lastAnimationState = null; - }; - Animation.prototype._fadeOut = function (animationConfig) { - switch (animationConfig.fadeOutMode) { - case 1 /* SameLayer */: - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (animationState._parent !== null) { - continue; - } - if (animationState.layer === animationConfig.layer) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 2 /* SameGroup */: - for (var _b = 0, _c = this._animationStates; _b < _c.length; _b++) { - var animationState = _c[_b]; - if (animationState._parent !== null) { - continue; - } - if (animationState.group === animationConfig.group) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 3 /* SameLayerAndGroup */: - for (var _d = 0, _e = this._animationStates; _d < _e.length; _d++) { - var animationState = _e[_d]; - if (animationState._parent !== null) { - continue; - } - if (animationState.layer === animationConfig.layer && - animationState.group === animationConfig.group) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 4 /* All */: - for (var _f = 0, _g = this._animationStates; _f < _g.length; _f++) { - var animationState = _g[_f]; - if (animationState._parent !== null) { - continue; - } - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - break; - case 0 /* None */: - case 5 /* Single */: - default: - break; - } - }; - /** - * @internal - */ - Animation.prototype.init = function (armature) { - if (this._armature !== null) { - return; - } - this._armature = armature; - this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); - }; - /** - * @internal - */ - Animation.prototype.advanceTime = function (passedTime) { - if (passedTime < 0.0) { - passedTime = -passedTime; - } - if (this._armature.inheritAnimation && this._armature._parent !== null) { - this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale; - } - else { - this._inheritTimeScale = this.timeScale; - } - if (this._inheritTimeScale !== 1.0) { - passedTime *= this._inheritTimeScale; - } - var animationStateCount = this._animationStates.length; - if (animationStateCount === 1) { - var animationState = this._animationStates[0]; - if (animationState._fadeState > 0 && animationState._subFadeState > 0) { - this._armature._dragonBones.bufferObject(animationState); - this._animationStates.length = 0; - this._lastAnimationState = null; - } - else { - var animationData = animationState._animationData; - var cacheFrameRate = animationData.cacheFrameRate; - if (this._animationDirty && cacheFrameRate > 0.0) { - this._animationDirty = false; - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); - } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - var rawDisplayDatas = slot.rawDisplayDatas; - if (rawDisplayDatas !== null && rawDisplayDatas.length > 0) { - var rawDsplayData = rawDisplayDatas[0]; - if (rawDsplayData !== null) { - if (rawDsplayData.parent === this._armature.armatureData.defaultSkin) { - slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); - continue; - } - } - } - slot._cachedFrameIndices = null; - } - } - animationState.advanceTime(passedTime, cacheFrameRate); - } - } - else if (animationStateCount > 1) { - for (var i = 0, r = 0; i < animationStateCount; ++i) { - var animationState = this._animationStates[i]; - if (animationState._fadeState > 0 && animationState._subFadeState > 0) { - r++; - this._armature._dragonBones.bufferObject(animationState); - this._animationDirty = true; - if (this._lastAnimationState === animationState) { - this._lastAnimationState = null; - } - } - else { - if (r > 0) { - this._animationStates[i - r] = animationState; - } - animationState.advanceTime(passedTime, 0.0); - } - if (i === animationStateCount - 1 && r > 0) { - this._animationStates.length -= r; - if (this._lastAnimationState === null && this._animationStates.length > 0) { - this._lastAnimationState = this._animationStates[this._animationStates.length - 1]; - } - } - } - this._armature._cacheFrameIndex = -1; - } - else { - this._armature._cacheFrameIndex = -1; - } - }; - /** - * - Clear all animations states. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除所有的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.reset = function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.returnToPool(); - } - this._animationDirty = false; - this._animationConfig.clear(); - this._animationStates.length = 0; - this._lastAnimationState = null; - }; - /** - * - Pause a specific animation state. - * @param animationName - The name of animation state. (If not set, it will pause all animations) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停指定动画状态的播放。 - * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.stop = function (animationName) { - if (animationName === void 0) { animationName = null; } - if (animationName !== null) { - var animationState = this.getState(animationName); - if (animationState !== null) { - animationState.stop(); - } - } - else { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.stop(); - } - } - }; - /** - * - Play animation with a specific animation config. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @param animationConfig - The animation config. - * @returns The playing animation state. - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 通过指定的动画配置来播放动画。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @param animationConfig - 动画配置。 - * @returns 播放的动画状态。 - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - Animation.prototype.playConfig = function (animationConfig) { - var animationName = animationConfig.animation; - if (!(animationName in this._animations)) { - console.warn("Non-existent animation.\n", "DragonBones name: " + this._armature.armatureData.parent.name, "Armature name: " + this._armature.name, "Animation name: " + animationName); - return null; - } - var animationData = this._animations[animationName]; - if (animationConfig.fadeOutMode === 5 /* Single */) { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState_1 = _a[_i]; - if (animationState_1._animationData === animationData) { - return animationState_1; - } - } - } - if (this._animationStates.length === 0) { - animationConfig.fadeInTime = 0.0; - } - else if (animationConfig.fadeInTime < 0.0) { - animationConfig.fadeInTime = animationData.fadeInTime; - } - if (animationConfig.fadeOutTime < 0.0) { - animationConfig.fadeOutTime = animationConfig.fadeInTime; - } - if (animationConfig.timeScale <= -100.0) { - animationConfig.timeScale = 1.0 / animationData.scale; - } - if (animationData.frameCount > 1) { - if (animationConfig.position < 0.0) { - animationConfig.position %= animationData.duration; - animationConfig.position = animationData.duration - animationConfig.position; - } - else if (animationConfig.position === animationData.duration) { - animationConfig.position -= 0.000001; // Play a little time before end. - } - else if (animationConfig.position > animationData.duration) { - animationConfig.position %= animationData.duration; - } - if (animationConfig.duration > 0.0 && animationConfig.position + animationConfig.duration > animationData.duration) { - animationConfig.duration = animationData.duration - animationConfig.position; - } - if (animationConfig.playTimes < 0) { - animationConfig.playTimes = animationData.playTimes; - } - } - else { - animationConfig.playTimes = 1; - animationConfig.position = 0.0; - if (animationConfig.duration > 0.0) { - animationConfig.duration = 0.0; - } - } - if (animationConfig.duration === 0.0) { - animationConfig.duration = -1.0; - } - this._fadeOut(animationConfig); - var animationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); - animationState.init(this._armature, animationData, animationConfig); - this._animationDirty = true; - this._armature._cacheFrameIndex = -1; - if (this._animationStates.length > 0) { - var added = false; - for (var i = 0, l = this._animationStates.length; i < l; ++i) { - if (animationState.layer > this._animationStates[i].layer) { - added = true; - this._animationStates.splice(i, 0, animationState); - break; - } - else if (i !== l - 1 && animationState.layer > this._animationStates[i + 1].layer) { - added = true; - this._animationStates.splice(i + 1, 0, animationState); - break; - } - } - if (!added) { - this._animationStates.push(animationState); - } - } - else { - this._animationStates.push(animationState); - } - // Child armature play same name animation. - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - var childArmature = slot.childArmature; - if (childArmature !== null && childArmature.inheritAnimation && - childArmature.animation.hasAnimation(animationName) && - childArmature.animation.getState(animationName) === null) { - childArmature.animation.fadeIn(animationName); // - } - } - var isLocked = false; - for (var k in animationData.animationTimelines) { - if (!this._lockUpdate) { - isLocked = true; - this._lockUpdate = true; - } - var childAnimatiionState = this.fadeIn(k, animationConfig.fadeInTime, 1, animationState.layer, null, 0 /* None */); - if (childAnimatiionState !== null) { - childAnimatiionState.resetToPose = false; - childAnimatiionState._parent = animationState; - childAnimatiionState.stop(); - } - } - if (isLocked) { - this._lockUpdate = false; - } - if (!this._lockUpdate) { - if (animationConfig.fadeInTime <= 0.0) { - this._armature.advanceTime(0.0); - } - this._lastAnimationState = animationState; - } - return animationState; - }; - /** - * - Play a specific animation. - * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) - * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放指定动画。 - * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.play = function (animationName, playTimes) { - if (animationName === void 0) { animationName = null; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName !== null ? animationName : ""; - if (animationName !== null && animationName.length > 0) { - this.playConfig(this._animationConfig); - } - else if (this._lastAnimationState === null) { - var defaultAnimation = this._armature.armatureData.defaultAnimation; - if (defaultAnimation !== null) { - this._animationConfig.animation = defaultAnimation.name; - this.playConfig(this._animationConfig); - } - } - else if (!this._lastAnimationState.isPlaying && !this._lastAnimationState.isCompleted) { - this._lastAnimationState.play(); - } - else { - this._animationConfig.animation = this._lastAnimationState.name; - this.playConfig(this._animationConfig); - } - return this._lastAnimationState; - }; - /** - * - Fade in a specific animation. - * @param animationName - The name of animation data. - * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) - * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) - * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) - * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 淡入播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) - * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) - * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode) { - if (fadeInTime === void 0) { fadeInTime = -1.0; } - if (playTimes === void 0) { playTimes = -1; } - if (layer === void 0) { layer = 0; } - if (group === void 0) { group = null; } - if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } - this._animationConfig.clear(); - this._animationConfig.fadeOutMode = fadeOutMode; - this._animationConfig.playTimes = playTimes; - this._animationConfig.layer = layer; - this._animationConfig.fadeInTime = fadeInTime; - this._animationConfig.animation = animationName; - this._animationConfig.group = group !== null ? group : ""; - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific time. - * @param animationName - The name of animation data. - * @param time - The start time point of playing. (In seconds) - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定时间开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param time - 播放开始的时间。 (以秒为单位) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByTime = function (animationName, time, playTimes) { - if (time === void 0) { time = 0.0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.position = time; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific frame. - * @param animationName - The name of animation data. - * @param frame - The start frame of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定帧开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param frame - 播放开始的帧数。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByFrame = function (animationName, frame, playTimes) { - if (frame === void 0) { frame = 0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - var animationData = animationName in this._animations ? this._animations[animationName] : null; - if (animationData !== null) { - this._animationConfig.position = animationData.duration * frame / animationData.frameCount; - } - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific progress. - * @param animationName - The name of animation data. - * @param progress - The start progress value of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定进度开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param progress - 开始播放的进度。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByProgress = function (animationName, progress, playTimes) { - if (progress === void 0) { progress = 0.0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - var animationData = animationName in this._animations ? this._animations[animationName] : null; - if (animationData !== null) { - this._animationConfig.position = animationData.duration * (progress > 0.0 ? progress : 0.0); - } - return this.playConfig(this._animationConfig); - }; - /** - * - Stop a specific animation at the specific time. - * @param animationName - The name of animation data. - * @param time - The stop time. (In seconds) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定时间停止指定动画播放 - * @param animationName - 动画数据名称。 - * @param time - 停止的时间。 (以秒为单位) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByTime = function (animationName, time) { - if (time === void 0) { time = 0.0; } - var animationState = this.gotoAndPlayByTime(animationName, time, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Stop a specific animation at the specific frame. - * @param animationName - The name of animation data. - * @param frame - The stop frame. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定帧停止指定动画的播放 - * @param animationName - 动画数据名称。 - * @param frame - 停止的帧数。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByFrame = function (animationName, frame) { - if (frame === void 0) { frame = 0; } - var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Stop a specific animation at the specific progress. - * @param animationName - The name of animation data. - * @param progress - The stop progress value. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定的进度停止指定的动画播放。 - * @param animationName - 动画数据名称。 - * @param progress - 停止进度。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByProgress = function (animationName, progress) { - if (progress === void 0) { progress = 0.0; } - var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Get a specific animation state. - * @param animationName - The name of animation state. - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取指定的动画状态 - * @param animationName - 动画状态名称。 - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.getState = function (animationName) { - var i = this._animationStates.length; - while (i--) { - var animationState = this._animationStates[i]; - if (animationState.name === animationName) { - return animationState; - } - } - return null; - }; - /** - * - Check whether a specific animation data is included. - * @param animationName - The name of animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含指定的动画数据 - * @param animationName - 动画数据名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.hasAnimation = function (animationName) { - return animationName in this._animations; - }; - /** - * - Get all the animation states. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取所有的动画状态 - * @version DragonBones 5.1 - * @language zh_CN - */ - Animation.prototype.getStates = function () { - return this._animationStates; - }; - Object.defineProperty(Animation.prototype, "isPlaying", { - /** - * - Check whether there is an animation state is playing - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否有动画状态正在播放 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (animationState.isPlaying) { - return true; - } - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "isCompleted", { - /** - * - Check whether all the animation states' playing were finished. - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否所有的动画状态均已播放完毕。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (!animationState.isCompleted) { - return false; - } - } - return this._animationStates.length > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "lastAnimationName", { - /** - * - The name of the last playing animation state. - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态名称 - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._lastAnimationState !== null ? this._lastAnimationState.name : ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationNames", { - /** - * - The name of all animation data - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有动画数据的名称 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._animationNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animations", { - /** - * - All animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有的动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._animations; - }, - set: function (value) { - if (this._animations === value) { - return; - } - this._animationNames.length = 0; - for (var k in this._animations) { - delete this._animations[k]; - } - for (var k in value) { - this._animationNames.push(k); - this._animations[k] = value[k]; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationConfig", { - /** - * - An AnimationConfig instance that can be used quickly. - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 一个可以快速使用的动画配置实例。 - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language zh_CN - */ - get: function () { - this._animationConfig.clear(); - return this._animationConfig; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "lastAnimationState", { - /** - * - The last playing animation state - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._lastAnimationState; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #play()} {@link #fadeIn()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #play()} {@link #fadeIn()}。 - * @deprecated - * @language zh_CN - */ - Animation.prototype.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) { - if (fadeInTime === void 0) { fadeInTime = -1; } - if (duration === void 0) { duration = -1; } - if (playTimes === void 0) { playTimes = -1; } - if (layer === void 0) { layer = 0; } - if (group === void 0) { group = null; } - if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } - if (pauseFadeOut === void 0) { pauseFadeOut = true; } - if (pauseFadeIn === void 0) { pauseFadeIn = true; } - console.warn("Deprecated."); - // tslint:disable-next-line:no-unused-expression - pauseFadeOut; - // tslint:disable-next-line:no-unused-expression - pauseFadeIn; - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.fadeOutMode = fadeOutMode; - this._animationConfig.playTimes = playTimes; - this._animationConfig.layer = layer; - this._animationConfig.fadeInTime = fadeInTime; - this._animationConfig.animation = animationName; - this._animationConfig.group = group !== null ? group : ""; - var animationData = this._animations[animationName]; - if (animationData && duration > 0.0) { - this._animationConfig.timeScale = animationData.duration / duration; - } - return this.playConfig(this._animationConfig); - }; - /** - * - Deprecated, please refer to {@link #gotoAndStopByTime()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #gotoAndStopByTime()}。 - * @deprecated - * @language zh_CN - */ - Animation.prototype.gotoAndStop = function (animationName, time) { - if (time === void 0) { time = 0; } - console.warn("Deprecated."); - return this.gotoAndStopByTime(animationName, time); - }; - Object.defineProperty(Animation.prototype, "animationList", { - /** - * - Deprecated, please refer to {@link #animationNames}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #animationNames}。 - * @deprecated - * @language zh_CN - */ - get: function () { - console.warn("Deprecated."); - return this._animationNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationDataList", { - /** - * - Deprecated, please refer to {@link #animationNames}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #animationNames}。 - * @deprecated - * @language zh_CN - */ - get: function () { - console.warn("Deprecated."); - var list = []; - for (var i = 0, l = this._animationNames.length; i < l; ++i) { - list.push(this._animations[this._animationNames[i]]); - } - return list; - }, - enumerable: true, - configurable: true - }); - return Animation; - }(dragonBones.BaseObject)); - dragonBones.Animation = Animation; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The animation state is generated when the animation data is played. - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画状态由播放动画数据时产生。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - var AnimationState = /** @class */ (function (_super) { - __extends(AnimationState, _super); - function AnimationState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @internal - */ - _this._blendState = new BlendState(); - _this._boneMask = []; - _this._boneTimelines = []; - _this._surfaceTimelines = []; - _this._slotTimelines = []; - _this._constraintTimelines = []; - _this._animationTimelines = []; - _this._poseTimelines = []; - _this._bonePoses = {}; - /** - * @internal - */ - _this._actionTimeline = null; // Initial value. - _this._zOrderTimeline = null; // Initial value. - /** - * @internal - */ - _this._parent = null; // Initial value. - return _this; - } - AnimationState.toString = function () { - return "[class dragonBones.AnimationState]"; - }; - AnimationState.prototype._onClear = function () { - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.returnToPool(); - } - for (var _b = 0, _c = this._surfaceTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.returnToPool(); - } - for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.returnToPool(); - } - for (var _f = 0, _g = this._constraintTimelines; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.returnToPool(); - } - for (var _h = 0, _j = this._animationTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.returnToPool(); - } - for (var k in this._bonePoses) { - this._bonePoses[k].returnToPool(); - delete this._bonePoses[k]; - } - if (this._actionTimeline !== null) { - this._actionTimeline.returnToPool(); - } - if (this._zOrderTimeline !== null) { - this._zOrderTimeline.returnToPool(); - } - this.actionEnabled = false; - this.additiveBlending = false; - this.displayControl = false; - this.resetToPose = false; - this.playTimes = 1; - this.layer = 0; - this.timeScale = 1.0; - this.weight = 1.0; - this.autoFadeOutTime = 0.0; - this.fadeTotalTime = 0.0; - this.name = ""; - this.group = ""; - this._timelineDirty = 2; - this._playheadState = 0; - this._fadeState = -1; - this._subFadeState = -1; - this._position = 0.0; - this._duration = 0.0; - this._fadeTime = 0.0; - this._time = 0.0; - this._fadeProgress = 0.0; - this._weightResult = 0.0; - this._blendState.clear(); - this._boneMask.length = 0; - this._boneTimelines.length = 0; - this._surfaceTimelines.length = 0; - this._slotTimelines.length = 0; - this._constraintTimelines.length = 0; - this._animationTimelines.length = 0; - this._poseTimelines.length = 0; - // this._bonePoses.clear(); - this._animationData = null; // - this._armature = null; // - this._actionTimeline = null; // - this._zOrderTimeline = null; - this._parent = null; // - }; - AnimationState.prototype._updateTimelines = function () { - { - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); - if (timelineDatas !== null) { - for (var _b = 0, timelineDatas_1 = timelineDatas; _b < timelineDatas_1.length; _b++) { - var timelineData = timelineDatas_1[_b]; - switch (timelineData.type) { - case 30 /* IKConstraint */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); - timeline.constraint = constraint; - timeline.init(this._armature, this, timelineData); - this._constraintTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); - timeline.constraint = constraint; - timeline.init(this._armature, this, null); - this._constraintTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - { - for (var _c = 0, _d = this._armature.animation.getStates(); _c < _d.length; _c++) { - var animationState = _d[_c]; - if (animationState._parent !== this) { - continue; - } - var timelineDatas = this._animationData.getAnimationTimelines(animationState.name); - if (timelineDatas === null) { - continue; - } - for (var _e = 0, timelineDatas_2 = timelineDatas; _e < timelineDatas_2.length; _e++) { - var timelineData = timelineDatas_2[_e]; - switch (timelineData.type) { - case 40 /* AnimationTime */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineState); - timeline.animationState = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - break; - } - default: - break; - } - } - } - } - }; - AnimationState.prototype._updateBoneAndSlotTimelines = function () { - { - var boneTimelines = {}; - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - var timelineName = timeline.bone.name; - if (!(timelineName in boneTimelines)) { - boneTimelines[timelineName] = []; - } - boneTimelines[timelineName].push(timeline); - } - for (var _b = 0, _c = this._armature.getBones(); _b < _c.length; _b++) { - var bone = _c[_b]; - var timelineName = bone.name; - if (!this.containsBoneMask(timelineName)) { - continue; - } - if (timelineName in boneTimelines) { - delete boneTimelines[timelineName]; - } - else if (bone._boneData.type === 0 /* Bone */) { - var timelineDatas = this._animationData.getBoneTimelines(timelineName); - var bonePose = timelineName in this._bonePoses ? this._bonePoses[timelineName] : (this._bonePoses[timelineName] = dragonBones.BaseObject.borrowObject(BonePose)); - if (timelineDatas !== null) { - for (var _d = 0, timelineDatas_3 = timelineDatas; _d < timelineDatas_3.length; _d++) { - var timelineData = timelineDatas_3[_d]; - switch (timelineData.type) { - case 10 /* BoneAll */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); - timeline.bone = bone; - timeline.bonePose = bonePose; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 11 /* BoneTranslate */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTranslateTimelineState); - timeline.bone = bone; - timeline.bonePose = bonePose; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 12 /* BoneRotate */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneRotateTimelineState); - timeline.bone = bone; - timeline.bonePose = bonePose; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 13 /* BoneScale */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneScaleTimelineState); - timeline.bone = bone; - timeline.bonePose = bonePose; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); - timeline.bone = bone; - timeline.bonePose = bonePose; - timeline.init(this._armature, this, null); - this._boneTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - else if (bone._boneData.type === 1 /* Surface */) { - var timelineDatas = this._animationData.getSurfaceTimelines(timelineName); - if (timelineDatas !== null) { - for (var _e = 0, timelineDatas_4 = timelineDatas; _e < timelineDatas_4.length; _e++) { - var timelineData = timelineDatas_4[_e]; - switch (timelineData.type) { - case 50 /* Surface */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); - timeline.surface = bone; - timeline.init(this._armature, this, timelineData); - this._surfaceTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); - timeline.surface = bone; - timeline.init(this._armature, this, null); - this._surfaceTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - for (var k in boneTimelines) { - for (var _f = 0, _g = boneTimelines[k]; _f < _g.length; _f++) { - var timeline = _g[_f]; - this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); - timeline.returnToPool(); - } - } - } - { - var slotTimelines = {}; - var ffdFlags = []; - for (var _h = 0, _j = this._slotTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - var timelineName = timeline.slot.name; - if (!(timelineName in slotTimelines)) { - slotTimelines[timelineName] = []; - } - slotTimelines[timelineName].push(timeline); - } - for (var _k = 0, _l = this._armature.getSlots(); _k < _l.length; _k++) { - var slot = _l[_k]; - var boneName = slot.parent.name; - if (!this.containsBoneMask(boneName)) { - continue; - } - var timelineName = slot.name; - var timelineDatas = this._animationData.getSlotTimelines(timelineName); - if (timelineName in slotTimelines) { - delete slotTimelines[timelineName]; - } - else { - var displayIndexFlag = false; - var colorFlag = false; - ffdFlags.length = 0; - if (timelineDatas !== null) { - for (var _m = 0, timelineDatas_5 = timelineDatas; _m < timelineDatas_5.length; _m++) { - var timelineData = timelineDatas_5[_m]; - switch (timelineData.type) { - case 20 /* SlotDisplay */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayTimelineState); - timeline.slot = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - displayIndexFlag = true; - break; - } - case 21 /* SlotColor */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); - timeline.slot = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - colorFlag = true; - break; - } - case 22 /* SlotDeform */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); - timeline.slot = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - ffdFlags.push(timeline.vertexOffset); - break; - } - default: - break; - } - } - } - if (this.resetToPose) { - if (!displayIndexFlag) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayTimelineState); - timeline.slot = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - if (!colorFlag) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); - timeline.slot = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - if (slot.rawDisplayDatas !== null) { - for (var _o = 0, _p = slot.rawDisplayDatas; _o < _p.length; _o++) { - var displayData = _p[_o]; - if (displayData !== null && displayData.type === 2 /* Mesh */) { - var meshOffset = displayData.vertices.offset; - if (ffdFlags.indexOf(meshOffset) < 0) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); - timeline.vertexOffset = meshOffset; // - timeline.slot = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - } - } - } - } - for (var k in slotTimelines) { - for (var _q = 0, _r = slotTimelines[k]; _q < _r.length; _q++) { - var timeline = _r[_q]; - this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); - timeline.returnToPool(); - } - } - } - }; - AnimationState.prototype._advanceFadeTime = function (passedTime) { - var isFadeOut = this._fadeState > 0; - if (this._subFadeState < 0) { - this._subFadeState = 0; - var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; - if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = eventType; - eventObject.armature = this._armature; - eventObject.animationState = this; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - if (passedTime < 0.0) { - passedTime = -passedTime; - } - this._fadeTime += passedTime; - if (this._fadeTime >= this.fadeTotalTime) { - this._subFadeState = 1; - this._fadeProgress = isFadeOut ? 0.0 : 1.0; - } - else if (this._fadeTime > 0.0) { - this._fadeProgress = isFadeOut ? (1.0 - this._fadeTime / this.fadeTotalTime) : (this._fadeTime / this.fadeTotalTime); - } - else { - this._fadeProgress = isFadeOut ? 1.0 : 0.0; - } - if (this._subFadeState > 0) { - if (!isFadeOut) { - this._playheadState |= 1; // x1 - this._fadeState = 0; - } - var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; - if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = eventType; - eventObject.armature = this._armature; - eventObject.animationState = this; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - }; - /** - * @internal - */ - AnimationState.prototype.init = function (armature, animationData, animationConfig) { - if (this._armature !== null) { - return; - } - this._armature = armature; - this._animationData = animationData; - // - this.resetToPose = animationConfig.resetToPose; - this.additiveBlending = animationConfig.additiveBlending; - this.displayControl = animationConfig.displayControl; - this.actionEnabled = animationConfig.actionEnabled; - this.layer = animationConfig.layer; - this.playTimes = animationConfig.playTimes; - this.timeScale = animationConfig.timeScale; - this.fadeTotalTime = animationConfig.fadeInTime; - this.autoFadeOutTime = animationConfig.autoFadeOutTime; - this.weight = animationConfig.weight; - this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; - this.group = animationConfig.group; - if (animationConfig.pauseFadeIn) { - this._playheadState = 2; // 10 - } - else { - this._playheadState = 3; // 11 - } - if (animationConfig.duration < 0.0) { - this._position = 0.0; - this._duration = this._animationData.duration; - if (animationConfig.position !== 0.0) { - if (this.timeScale >= 0.0) { - this._time = animationConfig.position; - } - else { - this._time = animationConfig.position - this._duration; - } - } - else { - this._time = 0.0; - } - } - else { - this._position = animationConfig.position; - this._duration = animationConfig.duration; - this._time = 0.0; - } - if (this.timeScale < 0.0 && this._time === 0.0) { - this._time = -0.000001; // Turn to end. - } - if (this.fadeTotalTime <= 0.0) { - this._fadeProgress = 0.999999; // Make different. - } - if (animationConfig.boneMask.length > 0) { - this._boneMask.length = animationConfig.boneMask.length; - for (var i = 0, l = this._boneMask.length; i < l; ++i) { - this._boneMask[i] = animationConfig.boneMask[i]; - } - } - this._actionTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ActionTimelineState); - this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); - this._actionTimeline.currentTime = this._time; - if (this._actionTimeline.currentTime < 0.0) { - this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime; - } - if (this._animationData.zOrderTimeline !== null) { - this._zOrderTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ZOrderTimelineState); - this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); - } - }; - /** - * @internal - */ - AnimationState.prototype.advanceTime = function (passedTime, cacheFrameRate) { - this._blendState.dirty = false; - // Update fade time. - if (this._fadeState !== 0 || this._subFadeState !== 0) { - this._advanceFadeTime(passedTime); - } - // Update time. - if (this._playheadState === 3) { - if (this.timeScale !== 1.0) { - passedTime *= this.timeScale; - } - this._time += passedTime; - } - // Update timeline. - if (this._timelineDirty !== 0) { - if (this._timelineDirty === 2) { - this._updateTimelines(); - } - this._timelineDirty = 0; - this._updateBoneAndSlotTimelines(); - } - if (this.weight === 0.0) { - return; - } - var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; - var isUpdateTimeline = true; - var isUpdateBoneTimeline = true; - var time = this._time; - this._weightResult = this.weight * this._fadeProgress; - if (this._parent !== null) { - this._weightResult *= this._parent._weightResult / this._parent._fadeProgress; - } - if (this._actionTimeline.playState <= 0) { - this._actionTimeline.update(time); // Update main timeline. - } - if (isCacheEnabled) { - var internval = cacheFrameRate * 2.0; - this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; - } - if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { - this._zOrderTimeline.update(time); - } - if (isCacheEnabled) { - var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); // uint - if (this._armature._cacheFrameIndex === cacheFrameIndex) { - isUpdateTimeline = false; - isUpdateBoneTimeline = false; - } - else { - this._armature._cacheFrameIndex = cacheFrameIndex; - if (this._animationData.cachedFrames[cacheFrameIndex]) { - isUpdateBoneTimeline = false; - } - else { - this._animationData.cachedFrames[cacheFrameIndex] = true; - } - } - } - if (isUpdateTimeline) { - if (isUpdateBoneTimeline) { - for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { - var timeline = this._boneTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (i === l - 1 || timeline.bone !== this._boneTimelines[i + 1].bone) { - var state = timeline.bone._blendState.update(this._weightResult, this.layer); - if (state !== 0) { - timeline.blend(state); - } - } - } - } - for (var i = 0, l = this._surfaceTimelines.length; i < l; ++i) { - var timeline = this._surfaceTimelines[i]; - var state = timeline.surface._blendState.update(this._weightResult, this.layer); - if (timeline.playState <= 0) { - timeline.update(time); - } - if (state !== 0) { - timeline.blend(state); - } - } - if (this.displayControl) { - for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { - var timeline = this._slotTimelines[i]; - var displayController = timeline.slot.displayController; - if (displayController === null || - displayController === this.name || - displayController === this.group) { - if (timeline.playState <= 0) { - timeline.update(time); - } - } - } - } - for (var i = 0, l = this._constraintTimelines.length; i < l; ++i) { - var timeline = this._constraintTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - } - for (var i = 0, l = this._animationTimelines.length; i < l; ++i) { - var timeline = this._animationTimelines[i]; - var state = timeline.animationState._blendState.update(this._weightResult, this.layer); - if (timeline.playState <= 0) { - timeline.update(time); - } - if (state !== 0) { - timeline.blend(state); - } - } - } - if (this._fadeState === 0) { - if (this._subFadeState > 0) { - this._subFadeState = 0; - if (this._poseTimelines.length > 0) { - for (var _i = 0, _a = this._poseTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - if (timeline instanceof dragonBones.BoneTimelineState) { - this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); - } - else if (timeline instanceof dragonBones.SurfaceTimelineState) { - this._surfaceTimelines.splice(this._surfaceTimelines.indexOf(timeline), 1); - } - else if (timeline instanceof dragonBones.SlotTimelineState) { - this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); - } - else if (timeline instanceof dragonBones.ConstraintTimelineState) { - this._constraintTimelines.splice(this._constraintTimelines.indexOf(timeline), 1); - } - timeline.returnToPool(); - } - this._poseTimelines.length = 0; - } - } - if (this._actionTimeline.playState > 0) { - if (this.autoFadeOutTime >= 0.0) { - this.fadeOut(this.autoFadeOutTime); - } - } - } - }; - /** - * - Continue play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 继续播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.play = function () { - this._playheadState = 3; // 11 - }; - /** - * - Stop play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.stop = function () { - this._playheadState &= 1; // 0x - }; - /** - * - Fade out the animation state. - * @param fadeOutTime - The fade out time. (In seconds) - * @param pausePlayhead - Whether to pause the animation playing when fade out. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 淡出动画状态。 - * @param fadeOutTime - 淡出时间。 (以秒为单位) - * @param pausePlayhead - 淡出时是否暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.fadeOut = function (fadeOutTime, pausePlayhead) { - if (pausePlayhead === void 0) { pausePlayhead = true; } - if (fadeOutTime < 0.0) { - fadeOutTime = 0.0; - } - if (pausePlayhead) { - this._playheadState &= 2; // x0 - } - if (this._fadeState > 0) { - if (fadeOutTime > this.fadeTotalTime - this._fadeTime) { - return; - } - } - else { - this._fadeState = 1; - this._subFadeState = -1; - if (fadeOutTime <= 0.0 || this._fadeProgress <= 0.0) { - this._fadeProgress = 0.000001; // Modify fade progress to different value. - } - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.fadeOut(); - } - for (var _b = 0, _c = this._surfaceTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.fadeOut(); - } - for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.fadeOut(); - } - for (var _f = 0, _g = this._constraintTimelines; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.fadeOut(); - } - for (var _h = 0, _j = this._animationTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.animationState.fadeOut(fadeOutTime, pausePlayhead); - timeline.fadeOut(); - } - } - this.displayControl = false; // - this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; - this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); - }; - /** - * - Check if a specific bone mask is included. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.containsBoneMask = function (boneName) { - return this._boneMask.length === 0 || this._boneMask.indexOf(boneName) >= 0; - }; - /** - * - Add a specific bone mask. - * @param boneName - The bone name. - * @param recursive - Whether or not to add a mask to the bone's sub-bone. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加特定的骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.addBoneMask = function (boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var currentBone = this._armature.getBone(boneName); - if (currentBone === null) { - return; - } - if (this._boneMask.indexOf(boneName) < 0) { - this._boneMask.push(boneName); - } - if (recursive) { - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { - this._boneMask.push(bone.name); - } - } - } - this._timelineDirty = 1; - }; - /** - * - Remove the mask of a specific bone. - * @param boneName - The bone name. - * @param recursive - Whether to remove the bone's sub-bone mask. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除特定骨骼的遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否删除该骨骼的子骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.removeBoneMask = function (boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var index = this._boneMask.indexOf(boneName); - if (index >= 0) { - this._boneMask.splice(index, 1); - } - if (recursive) { - var currentBone = this._armature.getBone(boneName); - if (currentBone !== null) { - var bones = this._armature.getBones(); - if (this._boneMask.length > 0) { - for (var _i = 0, bones_1 = bones; _i < bones_1.length; _i++) { - var bone = bones_1[_i]; - var index_2 = this._boneMask.indexOf(bone.name); - if (index_2 >= 0 && currentBone.contains(bone)) { - this._boneMask.splice(index_2, 1); - } - } - } - else { - for (var _a = 0, bones_2 = bones; _a < bones_2.length; _a++) { - var bone = bones_2[_a]; - if (bone === currentBone) { - continue; - } - if (!currentBone.contains(bone)) { - this._boneMask.push(bone.name); - } - } - } - } - } - this._timelineDirty = 1; - }; - /** - * - Remove all bone masks. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除所有骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.removeAllBoneMask = function () { - this._boneMask.length = 0; - this._timelineDirty = 1; - }; - Object.defineProperty(AnimationState.prototype, "isFadeIn", { - /** - * - Whether the animation state is fading in. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡入。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState < 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isFadeOut", { - /** - * - Whether the animation state is fading out. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡出。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isFadeComplete", { - /** - * - Whether the animation state is fade completed. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否淡入或淡出完毕。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState === 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isPlaying", { - /** - * - Whether the animation state is playing. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否正在播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isCompleted", { - /** - * - Whether the animation state is play completed. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否播放完毕。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.playState > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { - /** - * - The times has been played. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 已经循环播放的次数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.currentPlayTimes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "totalTime", { - /** - * - The total time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 总播放时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._duration; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "currentTime", { - /** - * - The time is currently playing. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前播放的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.currentTime; - }, - set: function (value) { - var currentPlayTimes = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); - if (value < 0 || this._duration < value) { - value = (value % this._duration) + currentPlayTimes * this._duration; - if (value < 0) { - value += this._duration; - } - } - if (this.playTimes > 0 && currentPlayTimes === this.playTimes - 1 && value === this._duration) { - value = this._duration - 0.000001; - } - if (this._time === value) { - return; - } - this._time = value; - this._actionTimeline.setCurrentTime(this._time); - if (this._zOrderTimeline !== null) { - this._zOrderTimeline.playState = -1; - } - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.playState = -1; - } - for (var _b = 0, _c = this._slotTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.playState = -1; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "animationData", { - /** - * - The animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._animationData; - }, - enumerable: true, - configurable: true - }); - return AnimationState; - }(dragonBones.BaseObject)); - dragonBones.AnimationState = AnimationState; - /** - * @internal - */ - var BonePose = /** @class */ (function (_super) { - __extends(BonePose, _super); - function BonePose() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.current = new dragonBones.Transform(); - _this.delta = new dragonBones.Transform(); - _this.result = new dragonBones.Transform(); - return _this; - } - BonePose.toString = function () { - return "[class dragonBones.BonePose]"; - }; - BonePose.prototype._onClear = function () { - this.current.identity(); - this.delta.identity(); - this.result.identity(); - }; - return BonePose; - }(dragonBones.BaseObject)); - dragonBones.BonePose = BonePose; - /** - * @internal - */ - var BlendState = /** @class */ (function () { - function BlendState() { - } - /** - * -1: First blending, 0: No blending, 1: Blending. - */ - BlendState.prototype.update = function (weight, p_layer) { - if (this.dirty) { - if (this.leftWeight > 0.0) { - if (this.layer !== p_layer) { - if (this.layerWeight >= this.leftWeight) { - this.leftWeight = 0.0; - return 0; - } - else { - this.layer = p_layer; - this.leftWeight -= this.layerWeight; - this.layerWeight = 0.0; - } - } - } - else { - return 0; - } - weight *= this.leftWeight; - this.layerWeight += weight; - this.blendWeight = weight; - return 2; - } - this.dirty = true; - this.layer = p_layer; - this.layerWeight = weight; - this.leftWeight = 1.0; - this.blendWeight = weight; - return 1; - }; - BlendState.prototype.clear = function () { - this.dirty = false; - this.layer = 0; - this.leftWeight = 0.0; - this.layerWeight = 0.0; - this.blendWeight = 0.0; - }; - return BlendState; - }()); - dragonBones.BlendState = BlendState; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var TimelineState = /** @class */ (function (_super) { - __extends(TimelineState, _super); - function TimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimelineState.prototype._onClear = function () { - this.playState = -1; - this.currentPlayTimes = -1; - this.currentTime = -1.0; - this._tweenState = 0 /* None */; - this._frameRate = 0; - this._frameValueOffset = 0; - this._frameCount = 0; - this._frameOffset = 0; - this._frameIndex = -1; - this._frameRateR = 0.0; - this._position = 0.0; - this._duration = 0.0; - this._timeScale = 1.0; - this._timeOffset = 0.0; - this._dragonBonesData = null; // - this._animationData = null; // - this._timelineData = null; // - this._armature = null; // - this._animationState = null; // - this._actionTimeline = null; // - this._frameArray = null; // - this._frameIntArray = null; // - this._frameFloatArray = null; // - this._timelineArray = null; // - this._frameIndices = null; // - }; - TimelineState.prototype._setCurrentTime = function (passedTime) { - var prevState = this.playState; - var prevPlayTimes = this.currentPlayTimes; - var prevTime = this.currentTime; - if (this._actionTimeline !== null && this._frameCount <= 1) { - this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; - this.currentPlayTimes = 1; - this.currentTime = this._actionTimeline.currentTime; - } - else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { - var playTimes = this._animationState.playTimes; - var totalTime = playTimes * this._duration; - passedTime *= this._timeScale; - if (this._timeOffset !== 0.0) { - passedTime += this._timeOffset * this._animationData.duration; - } - if (playTimes > 0 && (passedTime >= totalTime || passedTime <= -totalTime)) { - if (this.playState <= 0 && this._animationState._playheadState === 3) { - this.playState = 1; - } - this.currentPlayTimes = playTimes; - if (passedTime < 0.0) { - this.currentTime = 0.0; - } - else { - this.currentTime = this._duration + 0.000001; // Precision problem - } - } - else { - if (this.playState !== 0 && this._animationState._playheadState === 3) { - this.playState = 0; - } - if (passedTime < 0.0) { - passedTime = -passedTime; - this.currentPlayTimes = Math.floor(passedTime / this._duration); - this.currentTime = this._duration - (passedTime % this._duration); - } - else { - this.currentPlayTimes = Math.floor(passedTime / this._duration); - this.currentTime = passedTime % this._duration; - } - } - this.currentTime += this._position; - } - else { - this.playState = this._actionTimeline.playState; - this.currentPlayTimes = this._actionTimeline.currentPlayTimes; - this.currentTime = this._actionTimeline.currentTime; - } - if (this.currentPlayTimes === prevPlayTimes && this.currentTime === prevTime) { - return false; - } - // Clear frame flag when timeline start or loopComplete. - if ((prevState < 0 && this.playState !== prevState) || - (this.playState <= 0 && this.currentPlayTimes !== prevPlayTimes)) { - this._frameIndex = -1; - } - return true; - }; - TimelineState.prototype.init = function (armature, animationState, timelineData) { - this._armature = armature; - this._animationState = animationState; - this._timelineData = timelineData; - this._actionTimeline = this._animationState._actionTimeline; - if (this === this._actionTimeline) { - this._actionTimeline = null; // - } - this._animationData = this._animationState._animationData; - this._frameRate = this._animationData.parent.frameRate; - this._frameRateR = 1.0 / this._frameRate; - this._position = this._animationState._position; - this._duration = this._animationState._duration; - this._dragonBonesData = this._animationData.parent.parent; // May by the animation data is not belone to this armature data. - if (this._timelineData !== null) { - this._frameIntArray = this._dragonBonesData.frameIntArray; - this._frameFloatArray = this._dragonBonesData.frameFloatArray; - this._frameArray = this._dragonBonesData.frameArray; - this._timelineArray = this._dragonBonesData.timelineArray; - this._frameIndices = this._dragonBonesData.frameIndices; - this._frameCount = this._timelineArray[this._timelineData.offset + 2 /* TimelineKeyFrameCount */]; - this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4 /* TimelineFrameValueOffset */]; - this._timeScale = 100.0 / this._timelineArray[this._timelineData.offset + 0 /* TimelineScale */]; - this._timeOffset = this._timelineArray[this._timelineData.offset + 1 /* TimelineOffset */] * 0.01; - } - }; - TimelineState.prototype.fadeOut = function () { }; - TimelineState.prototype.update = function (passedTime) { - if (this._setCurrentTime(passedTime)) { - if (this._frameCount > 1) { - var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint - var frameIndex = this._frameIndices[this._timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { - this._frameIndex = frameIndex; - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; - this._onArriveAtFrame(); - } - } - else if (this._frameIndex < 0) { - this._frameIndex = 0; - if (this._timelineData !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; - } - this._onArriveAtFrame(); - } - if (this._tweenState !== 0 /* None */) { - this._onUpdateFrame(); - } - } - }; - return TimelineState; - }(dragonBones.BaseObject)); - dragonBones.TimelineState = TimelineState; - /** - * @internal - */ - var TweenTimelineState = /** @class */ (function (_super) { - __extends(TweenTimelineState, _super); - function TweenTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - TweenTimelineState._getEasingValue = function (tweenType, progress, easing) { - var value = progress; - switch (tweenType) { - case 3 /* QuadIn */: - value = Math.pow(progress, 2.0); - break; - case 4 /* QuadOut */: - value = 1.0 - Math.pow(1.0 - progress, 2.0); - break; - case 5 /* QuadInOut */: - value = 0.5 * (1.0 - Math.cos(progress * Math.PI)); - break; - } - return (value - progress) * easing + progress; - }; - TweenTimelineState._getEasingCurveValue = function (progress, samples, count, offset) { - if (progress <= 0.0) { - return 0.0; - } - else if (progress >= 1.0) { - return 1.0; - } - var segmentCount = count + 1; // + 2 - 1 - var valueIndex = Math.floor(progress * segmentCount); - var fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; - var toValue = (valueIndex === segmentCount - 1) ? 10000.0 : samples[offset + valueIndex]; - return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001; - }; - TweenTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._tweenType = 0 /* None */; - this._curveCount = 0; - this._framePosition = 0.0; - this._frameDurationR = 0.0; - this._tweenProgress = 0.0; - this._tweenEasing = 0.0; - }; - TweenTimelineState.prototype._onArriveAtFrame = function () { - if (this._frameCount > 1 && - (this._frameIndex !== this._frameCount - 1 || - this._animationState.playTimes === 0 || - this._animationState.currentPlayTimes < this._animationState.playTimes - 1)) { - this._tweenType = this._frameArray[this._frameOffset + 1 /* FrameTweenType */]; // TODO recode ture tween type. - this._tweenState = this._tweenType === 0 /* None */ ? 1 /* Once */ : 2 /* Always */; - if (this._tweenType === 2 /* Curve */) { - this._curveCount = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */]; - } - else if (this._tweenType !== 0 /* None */ && this._tweenType !== 1 /* Line */) { - this._tweenEasing = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] * 0.01; - } - this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; - if (this._frameIndex === this._frameCount - 1) { - this._frameDurationR = 1.0 / (this._animationData.duration - this._framePosition); - } - else { - var nextFrameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex + 1]; - var frameDuration = this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition; - if (frameDuration > 0) { - this._frameDurationR = 1.0 / frameDuration; - } - else { - this._frameDurationR = 0.0; - } - } - } - else { - this._tweenState = 1 /* Once */; - } - }; - TweenTimelineState.prototype._onUpdateFrame = function () { - if (this._tweenState === 2 /* Always */) { - this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; - if (this._tweenType === 2 /* Curve */) { - this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + 3 /* FrameCurveSamples */); - } - else if (this._tweenType !== 1 /* Line */) { - this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing); - } - } - else { - this._tweenProgress = 0.0; - } - }; - return TweenTimelineState; - }(TimelineState)); - dragonBones.TweenTimelineState = TweenTimelineState; - /** - * @internal - */ - var BoneTimelineState = /** @class */ (function (_super) { - __extends(BoneTimelineState, _super); - function BoneTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.bone = null; // - this.bonePose = null; // - }; - BoneTimelineState.prototype.blend = function (state) { - var blendWeight = this.bone._blendState.blendWeight; - var animationPose = this.bone.animationPose; - var result = this.bonePose.result; - if (state === 2) { - animationPose.x += result.x * blendWeight; - animationPose.y += result.y * blendWeight; - animationPose.rotation += result.rotation * blendWeight; - animationPose.skew += result.skew * blendWeight; - animationPose.scaleX += (result.scaleX - 1.0) * blendWeight; - animationPose.scaleY += (result.scaleY - 1.0) * blendWeight; - } - else if (blendWeight !== 1.0) { - animationPose.x = result.x * blendWeight; - animationPose.y = result.y * blendWeight; - animationPose.rotation = result.rotation * blendWeight; - animationPose.skew = result.skew * blendWeight; - animationPose.scaleX = (result.scaleX - 1.0) * blendWeight + 1.0; - animationPose.scaleY = (result.scaleY - 1.0) * blendWeight + 1.0; - } - else { - animationPose.x = result.x; - animationPose.y = result.y; - animationPose.rotation = result.rotation; - animationPose.skew = result.skew; - animationPose.scaleX = result.scaleX; - animationPose.scaleY = result.scaleY; - } - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - this.bone._transformDirty = true; - } - }; - return BoneTimelineState; - }(TweenTimelineState)); - dragonBones.BoneTimelineState = BoneTimelineState; - /** - * @internal - */ - var SlotTimelineState = /** @class */ (function (_super) { - __extends(SlotTimelineState, _super); - function SlotTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SlotTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.slot = null; // - }; - return SlotTimelineState; - }(TweenTimelineState)); - dragonBones.SlotTimelineState = SlotTimelineState; - /** - * @internal - */ - var ConstraintTimelineState = /** @class */ (function (_super) { - __extends(ConstraintTimelineState, _super); - function ConstraintTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ConstraintTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.constraint = null; // - }; - return ConstraintTimelineState; - }(TweenTimelineState)); - dragonBones.ConstraintTimelineState = ConstraintTimelineState; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var ActionTimelineState = /** @class */ (function (_super) { - __extends(ActionTimelineState, _super); - function ActionTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ActionTimelineState.toString = function () { - return "[class dragonBones.ActionTimelineState]"; - }; - ActionTimelineState.prototype._onCrossFrame = function (frameIndex) { - var eventDispatcher = this._armature.eventDispatcher; - if (this._animationState.actionEnabled) { - var frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + frameIndex]; - var actionCount = this._frameArray[frameOffset + 1]; - var actions = this._animationData.parent.actions; // May be the animaton data not belong to this armature data. - for (var i = 0; i < actionCount; ++i) { - var actionIndex = this._frameArray[frameOffset + 2 + i]; - var action = actions[actionIndex]; - if (action.type === 0 /* Play */) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = this._frameArray[frameOffset] / this._frameRate; - eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - this._armature._bufferAction(eventObject, true); - } - else { - var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; - if (action.type === 11 /* Sound */ || eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = this._frameArray[frameOffset] / this._frameRate; - eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - } - }; - ActionTimelineState.prototype._onArriveAtFrame = function () { }; - ActionTimelineState.prototype._onUpdateFrame = function () { }; - ActionTimelineState.prototype.update = function (passedTime) { - var prevState = this.playState; - var prevPlayTimes = this.currentPlayTimes; - var prevTime = this.currentTime; - if (this._setCurrentTime(passedTime)) { - var eventDispatcher = this._armature.eventDispatcher; - if (prevState < 0) { - if (this.playState !== prevState) { - if (this._animationState.displayControl && this._animationState.resetToPose) { - this._armature._sortZOrder(null, 0); - } - prevPlayTimes = this.currentPlayTimes; - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.START)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = dragonBones.EventObject.START; - eventObject.armature = this._armature; - eventObject.animationState = this._animationState; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - else { - return; - } - } - var isReverse = this._animationState.timeScale < 0.0; - var loopCompleteEvent = null; - var completeEvent = null; - if (this.currentPlayTimes !== prevPlayTimes) { - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.LOOP_COMPLETE)) { - loopCompleteEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - loopCompleteEvent.type = dragonBones.EventObject.LOOP_COMPLETE; - loopCompleteEvent.armature = this._armature; - loopCompleteEvent.animationState = this._animationState; - } - if (this.playState > 0) { - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.COMPLETE)) { - completeEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - completeEvent.type = dragonBones.EventObject.COMPLETE; - completeEvent.armature = this._armature; - completeEvent.animationState = this._animationState; - } - } - } - if (this._frameCount > 1) { - var timelineData = this._timelineData; - var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint - var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { - var crossedFrameIndex = this._frameIndex; - this._frameIndex = frameIndex; - if (this._timelineArray !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; - if (isReverse) { - if (crossedFrameIndex < 0) { - var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - if (this.currentPlayTimes === prevPlayTimes) { - if (crossedFrameIndex === frameIndex) { - crossedFrameIndex = -1; - } - } - } - while (crossedFrameIndex >= 0) { - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this._position <= framePosition && - framePosition <= this._position + this._duration) { - this._onCrossFrame(crossedFrameIndex); - } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - if (crossedFrameIndex > 0) { - crossedFrameIndex--; - } - else { - crossedFrameIndex = this._frameCount - 1; - } - if (crossedFrameIndex === frameIndex) { - break; - } - } - } - else { - if (crossedFrameIndex < 0) { - var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { - if (prevTime <= framePosition) { - if (crossedFrameIndex > 0) { - crossedFrameIndex--; - } - else { - crossedFrameIndex = this._frameCount - 1; - } - } - else if (crossedFrameIndex === frameIndex) { - crossedFrameIndex = -1; - } - } - } - while (crossedFrameIndex >= 0) { - if (crossedFrameIndex < this._frameCount - 1) { - crossedFrameIndex++; - } - else { - crossedFrameIndex = 0; - } - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this._position <= framePosition && - framePosition <= this._position + this._duration) { - this._onCrossFrame(crossedFrameIndex); - } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - if (crossedFrameIndex === frameIndex) { - break; - } - } - } - } - } - } - else if (this._frameIndex < 0) { - this._frameIndex = 0; - if (this._timelineData !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; - // Arrive at frame. - var framePosition = this._frameArray[this._frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { - if (prevTime <= framePosition) { - this._onCrossFrame(this._frameIndex); - } - } - else if (this._position <= framePosition) { - if (!isReverse && loopCompleteEvent !== null) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - this._onCrossFrame(this._frameIndex); - } - } - } - if (loopCompleteEvent !== null) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - } - if (completeEvent !== null) { - this._armature._dragonBones.bufferEvent(completeEvent); - } - } - }; - ActionTimelineState.prototype.setCurrentTime = function (value) { - this._setCurrentTime(value); - this._frameIndex = -1; - }; - return ActionTimelineState; - }(dragonBones.TimelineState)); - dragonBones.ActionTimelineState = ActionTimelineState; - /** - * @internal - */ - var ZOrderTimelineState = /** @class */ (function (_super) { - __extends(ZOrderTimelineState, _super); - function ZOrderTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ZOrderTimelineState.toString = function () { - return "[class dragonBones.ZOrderTimelineState]"; - }; - ZOrderTimelineState.prototype._onArriveAtFrame = function () { - if (this.playState >= 0) { - var count = this._frameArray[this._frameOffset + 1]; - if (count > 0) { - this._armature._sortZOrder(this._frameArray, this._frameOffset + 2); - } - else { - this._armature._sortZOrder(null, 0); - } - } - }; - ZOrderTimelineState.prototype._onUpdateFrame = function () { }; - return ZOrderTimelineState; - }(dragonBones.TimelineState)); - dragonBones.ZOrderTimelineState = ZOrderTimelineState; - /** - * @internal - */ - var BoneAllTimelineState = /** @class */ (function (_super) { - __extends(BoneAllTimelineState, _super); - function BoneAllTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneAllTimelineState.toString = function () { - return "[class dragonBones.BoneAllTimelineState]"; - }; - BoneAllTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 6; // ...(timeline value offset)|xxxxxx|xxxxxx|(Value offset)xxxxx|(Next offset)xxxxx|xxxxxx|xxxxxx|... - var scale = this._armature._armatureData.scale; - var frameFloatArray = this._frameFloatArray; - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.x = frameFloatArray[valueOffset++] * scale; - current.y = frameFloatArray[valueOffset++] * scale; - current.rotation = frameFloatArray[valueOffset++]; - current.skew = frameFloatArray[valueOffset++]; - current.scaleX = frameFloatArray[valueOffset++]; - current.scaleY = frameFloatArray[valueOffset++]; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; // + 0 * 6 - } - delta.x = frameFloatArray[valueOffset++] * scale - current.x; - delta.y = frameFloatArray[valueOffset++] * scale - current.y; - delta.rotation = frameFloatArray[valueOffset++] - current.rotation; - delta.skew = frameFloatArray[valueOffset++] - current.skew; - delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; - delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; - } - else { - delta.x = 0.0; - delta.y = 0.0; - delta.rotation = 0.0; - delta.skew = 0.0; - delta.scaleX = 0.0; - delta.scaleY = 0.0; - } - } - else { - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.x = 0.0; - current.y = 0.0; - current.rotation = 0.0; - current.skew = 0.0; - current.scaleX = 1.0; - current.scaleY = 1.0; - delta.x = 0.0; - delta.y = 0.0; - delta.rotation = 0.0; - delta.skew = 0.0; - delta.scaleX = 0.0; - delta.scaleY = 0.0; - } - }; - BoneAllTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var current = this.bonePose.current; - var delta = this.bonePose.delta; - var result = this.bonePose.result; - this.bone._transformDirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - result.x = current.x + delta.x * this._tweenProgress; - result.y = current.y + delta.y * this._tweenProgress; - result.rotation = current.rotation + delta.rotation * this._tweenProgress; - result.skew = current.skew + delta.skew * this._tweenProgress; - result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; - result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; - }; - BoneAllTimelineState.prototype.fadeOut = function () { - var result = this.bonePose.result; - result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); - result.skew = dragonBones.Transform.normalizeRadian(result.skew); - }; - return BoneAllTimelineState; - }(dragonBones.BoneTimelineState)); - dragonBones.BoneAllTimelineState = BoneAllTimelineState; - /** - * @internal - */ - var BoneTranslateTimelineState = /** @class */ (function (_super) { - __extends(BoneTranslateTimelineState, _super); - function BoneTranslateTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneTranslateTimelineState.toString = function () { - return "[class dragonBones.BoneTranslateTimelineState]"; - }; - BoneTranslateTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 2; - var scale = this._armature._armatureData.scale; - var frameFloatArray = this._frameFloatArray; - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.x = frameFloatArray[valueOffset++] * scale; - current.y = frameFloatArray[valueOffset++] * scale; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; // + 0 * 2 - } - delta.x = frameFloatArray[valueOffset++] * scale - current.x; - delta.y = frameFloatArray[valueOffset++] * scale - current.y; - } - else { - delta.x = 0.0; - delta.y = 0.0; - } - } - else { - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.x = 0.0; - current.y = 0.0; - delta.x = 0.0; - delta.y = 0.0; - } - }; - BoneTranslateTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var current = this.bonePose.current; - var delta = this.bonePose.delta; - var result = this.bonePose.result; - this.bone._transformDirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - result.x = (current.x + delta.x * this._tweenProgress); - result.y = (current.y + delta.y * this._tweenProgress); - }; - return BoneTranslateTimelineState; - }(dragonBones.BoneTimelineState)); - dragonBones.BoneTranslateTimelineState = BoneTranslateTimelineState; - /** - * @internal - */ - var BoneRotateTimelineState = /** @class */ (function (_super) { - __extends(BoneRotateTimelineState, _super); - function BoneRotateTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneRotateTimelineState.toString = function () { - return "[class dragonBones.BoneRotateTimelineState]"; - }; - BoneRotateTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 2; - var frameFloatArray = this._frameFloatArray; - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.rotation = frameFloatArray[valueOffset++]; - current.skew = frameFloatArray[valueOffset++]; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; // + 0 * 2 - delta.rotation = dragonBones.Transform.normalizeRadian(frameFloatArray[valueOffset++] - current.rotation); - } - else { - delta.rotation = frameFloatArray[valueOffset++] - current.rotation; - } - delta.skew = frameFloatArray[valueOffset++] - current.skew; - } - else { - delta.rotation = 0.0; - delta.skew = 0.0; - } - } - else { - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.rotation = 0.0; - current.skew = 0.0; - delta.rotation = 0.0; - delta.skew = 0.0; - } - }; - BoneRotateTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var current = this.bonePose.current; - var delta = this.bonePose.delta; - var result = this.bonePose.result; - this.bone._transformDirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - result.rotation = current.rotation + delta.rotation * this._tweenProgress; - result.skew = current.skew + delta.skew * this._tweenProgress; - }; - BoneRotateTimelineState.prototype.fadeOut = function () { - var result = this.bonePose.result; - result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); - result.skew = dragonBones.Transform.normalizeRadian(result.skew); - }; - return BoneRotateTimelineState; - }(dragonBones.BoneTimelineState)); - dragonBones.BoneRotateTimelineState = BoneRotateTimelineState; - /** - * @internal - */ - var BoneScaleTimelineState = /** @class */ (function (_super) { - __extends(BoneScaleTimelineState, _super); - function BoneScaleTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneScaleTimelineState.toString = function () { - return "[class dragonBones.BoneScaleTimelineState]"; - }; - BoneScaleTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 2; - var frameFloatArray = this._frameFloatArray; - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.scaleX = frameFloatArray[valueOffset++]; - current.scaleY = frameFloatArray[valueOffset++]; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; // + 0 * 2 - } - delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; - delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; - } - else { - delta.scaleX = 0.0; - delta.scaleY = 0.0; - } - } - else { - var current = this.bonePose.current; - var delta = this.bonePose.delta; - current.scaleX = 1.0; - current.scaleY = 1.0; - delta.scaleX = 0.0; - delta.scaleY = 0.0; - } - }; - BoneScaleTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var current = this.bonePose.current; - var delta = this.bonePose.delta; - var result = this.bonePose.result; - this.bone._transformDirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; - result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; - }; - return BoneScaleTimelineState; - }(dragonBones.BoneTimelineState)); - dragonBones.BoneScaleTimelineState = BoneScaleTimelineState; - /** - * @internal - */ - var SurfaceTimelineState = /** @class */ (function (_super) { - __extends(SurfaceTimelineState, _super); - function SurfaceTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._current = []; - _this._delta = []; - _this._result = []; - return _this; - } - SurfaceTimelineState.toString = function () { - return "[class dragonBones.SurfaceTimelineState]"; - }; - SurfaceTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.surface = null; - this._frameFloatOffset = 0; - this._valueCount = 0; - this._deformCount = 0; - this._valueOffset = 0; - this._current.length = 0; - this._delta.length = 0; - this._result.length = 0; - }; - SurfaceTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; - var scale = this._armature._armatureData.scale; - var frameFloatArray = this._frameFloatArray; - if (this._tweenState === 2 /* Always */) { - var nextValueOffset = valueOffset + this._valueCount; - if (this._frameIndex === this._frameCount - 1) { - nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; - } - for (var i = 0; i < this._valueCount; ++i) { - this._delta[i] = frameFloatArray[nextValueOffset + i] * scale - (this._current[i] = frameFloatArray[valueOffset + i] * scale); - } - } - else { - for (var i = 0; i < this._valueCount; ++i) { - this._current[i] = frameFloatArray[valueOffset + i] * scale; - } - } - } - else { - for (var i = 0; i < this._valueCount; ++i) { - this._current[i] = 0.0; - } - } - }; - SurfaceTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - this.surface._transformDirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - for (var i = 0; i < this._valueCount; ++i) { - this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; - } - }; - SurfaceTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - if (this._timelineData !== null) { - var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; - this._deformCount = this._frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._valueCount = this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; - this._valueOffset = this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; - this._frameFloatOffset = this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; - } - else { - this._deformCount = this.surface._deformVertices.length; - this._valueCount = this._deformCount; - this._valueOffset = 0; - this._frameFloatOffset = 0; - } - this._current.length = this._valueCount; - this._delta.length = this._valueCount; - this._result.length = this._valueCount; - for (var i = 0; i < this._valueCount; ++i) { - this._delta[i] = 0.0; - } - }; - SurfaceTimelineState.prototype.blend = function (state) { - var blendWeight = this.surface._blendState.blendWeight; - var result = this.surface._deformVertices; - for (var i = 0; i < this._deformCount; ++i) { - var value = 0.0; - if (i < this._valueOffset) { - value = this._frameFloatArray[this._frameFloatOffset + i]; - } - else if (i < this._valueOffset + this._valueCount) { - value = this._result[i - this._valueOffset]; - } - else { - value = this._frameFloatArray[this._frameFloatOffset + i - this._valueCount]; - } - if (state === 2) { - result[i] += value * blendWeight; - } - else if (blendWeight !== 1.0) { - result[i] = value * blendWeight; - } - else { - result[i] = value; - } - } - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - this.surface._transformDirty = true; - } - }; - return SurfaceTimelineState; - }(dragonBones.TweenTimelineState)); - dragonBones.SurfaceTimelineState = SurfaceTimelineState; - /** - * @internal - */ - var SlotDislayTimelineState = /** @class */ (function (_super) { - __extends(SlotDislayTimelineState, _super); - function SlotDislayTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SlotDislayTimelineState.toString = function () { - return "[class dragonBones.SlotDislayTimelineState]"; - }; - SlotDislayTimelineState.prototype._onArriveAtFrame = function () { - if (this.playState >= 0) { - var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : this.slot._slotData.displayIndex; - if (this.slot.displayIndex !== displayIndex) { - this.slot._setDisplayIndex(displayIndex, true); - } - } - }; - return SlotDislayTimelineState; - }(dragonBones.SlotTimelineState)); - dragonBones.SlotDislayTimelineState = SlotDislayTimelineState; - /** - * @internal - */ - var SlotColorTimelineState = /** @class */ (function (_super) { - __extends(SlotColorTimelineState, _super); - function SlotColorTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._current = [0, 0, 0, 0, 0, 0, 0, 0]; - _this._delta = [0, 0, 0, 0, 0, 0, 0, 0]; - _this._result = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; - return _this; - } - SlotColorTimelineState.toString = function () { - return "[class dragonBones.SlotColorTimelineState]"; - }; - SlotColorTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._dirty = false; - }; - SlotColorTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var intArray = this._dragonBonesData.intArray; - var frameIntArray = this._frameIntArray; - var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 1; // ...(timeline value offset)|x|x|(Value offset)|(Next offset)|x|x|... - var colorOffset = frameIntArray[valueOffset]; - if (colorOffset < 0) { - colorOffset += 65536; // Fixed out of bouds bug. - } - this._current[0] = intArray[colorOffset++]; - this._current[1] = intArray[colorOffset++]; - this._current[2] = intArray[colorOffset++]; - this._current[3] = intArray[colorOffset++]; - this._current[4] = intArray[colorOffset++]; - this._current[5] = intArray[colorOffset++]; - this._current[6] = intArray[colorOffset++]; - this._current[7] = intArray[colorOffset++]; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; - } - else { - colorOffset = frameIntArray[valueOffset + 1 * 1]; - } - if (colorOffset < 0) { - colorOffset += 65536; // Fixed out of bouds bug. - } - this._delta[0] = intArray[colorOffset++] - this._current[0]; - this._delta[1] = intArray[colorOffset++] - this._current[1]; - this._delta[2] = intArray[colorOffset++] - this._current[2]; - this._delta[3] = intArray[colorOffset++] - this._current[3]; - this._delta[4] = intArray[colorOffset++] - this._current[4]; - this._delta[5] = intArray[colorOffset++] - this._current[5]; - this._delta[6] = intArray[colorOffset++] - this._current[6]; - this._delta[7] = intArray[colorOffset++] - this._current[7]; - } - } - else { - var color = this.slot._slotData.color; - this._current[0] = color.alphaMultiplier * 100.0; - this._current[1] = color.redMultiplier * 100.0; - this._current[2] = color.greenMultiplier * 100.0; - this._current[3] = color.blueMultiplier * 100.0; - this._current[4] = color.alphaOffset; - this._current[5] = color.redOffset; - this._current[6] = color.greenOffset; - this._current[7] = color.blueOffset; - } - }; - SlotColorTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - this._dirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - this._result[0] = (this._current[0] + this._delta[0] * this._tweenProgress) * 0.01; - this._result[1] = (this._current[1] + this._delta[1] * this._tweenProgress) * 0.01; - this._result[2] = (this._current[2] + this._delta[2] * this._tweenProgress) * 0.01; - this._result[3] = (this._current[3] + this._delta[3] * this._tweenProgress) * 0.01; - this._result[4] = this._current[4] + this._delta[4] * this._tweenProgress; - this._result[5] = this._current[5] + this._delta[5] * this._tweenProgress; - this._result[6] = this._current[6] + this._delta[6] * this._tweenProgress; - this._result[7] = this._current[7] + this._delta[7] * this._tweenProgress; - }; - SlotColorTimelineState.prototype.fadeOut = function () { - this._tweenState = 0 /* None */; - this._dirty = false; - }; - SlotColorTimelineState.prototype.update = function (passedTime) { - _super.prototype.update.call(this, passedTime); - // Fade animation. - if (this._tweenState !== 0 /* None */ || this._dirty) { - var result = this.slot._colorTransform; - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - if (result.alphaMultiplier !== this._result[0] || - result.redMultiplier !== this._result[1] || - result.greenMultiplier !== this._result[2] || - result.blueMultiplier !== this._result[3] || - result.alphaOffset !== this._result[4] || - result.redOffset !== this._result[5] || - result.greenOffset !== this._result[6] || - result.blueOffset !== this._result[7]) { - var fadeProgress = Math.pow(this._animationState._fadeProgress, 4); - result.alphaMultiplier += (this._result[0] - result.alphaMultiplier) * fadeProgress; - result.redMultiplier += (this._result[1] - result.redMultiplier) * fadeProgress; - result.greenMultiplier += (this._result[2] - result.greenMultiplier) * fadeProgress; - result.blueMultiplier += (this._result[3] - result.blueMultiplier) * fadeProgress; - result.alphaOffset += (this._result[4] - result.alphaOffset) * fadeProgress; - result.redOffset += (this._result[5] - result.redOffset) * fadeProgress; - result.greenOffset += (this._result[6] - result.greenOffset) * fadeProgress; - result.blueOffset += (this._result[7] - result.blueOffset) * fadeProgress; - this.slot._colorDirty = true; - } - } - else if (this._dirty) { - this._dirty = false; - if (result.alphaMultiplier !== this._result[0] || - result.redMultiplier !== this._result[1] || - result.greenMultiplier !== this._result[2] || - result.blueMultiplier !== this._result[3] || - result.alphaOffset !== this._result[4] || - result.redOffset !== this._result[5] || - result.greenOffset !== this._result[6] || - result.blueOffset !== this._result[7]) { - result.alphaMultiplier = this._result[0]; - result.redMultiplier = this._result[1]; - result.greenMultiplier = this._result[2]; - result.blueMultiplier = this._result[3]; - result.alphaOffset = this._result[4]; - result.redOffset = this._result[5]; - result.greenOffset = this._result[6]; - result.blueOffset = this._result[7]; - this.slot._colorDirty = true; - } - } - } - }; - return SlotColorTimelineState; - }(dragonBones.SlotTimelineState)); - dragonBones.SlotColorTimelineState = SlotColorTimelineState; - /** - * @internal - */ - var DeformTimelineState = /** @class */ (function (_super) { - __extends(DeformTimelineState, _super); - function DeformTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._current = []; - _this._delta = []; - _this._result = []; - return _this; - } - DeformTimelineState.toString = function () { - return "[class dragonBones.DeformTimelineState]"; - }; - DeformTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.vertexOffset = 0; - this._dirty = false; - this._frameFloatOffset = 0; - this._valueCount = 0; - this._deformCount = 0; - this._valueOffset = 0; - this._current.length = 0; - this._delta.length = 0; - this._result.length = 0; - }; - DeformTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; - var scale = this._armature._armatureData.scale; - var frameFloatArray = this._frameFloatArray; - if (this._tweenState === 2 /* Always */) { - var nextValueOffset = valueOffset + this._valueCount; - if (this._frameIndex === this._frameCount - 1) { - nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; - } - for (var i = 0; i < this._valueCount; ++i) { - this._delta[i] = frameFloatArray[nextValueOffset + i] * scale - (this._current[i] = frameFloatArray[valueOffset + i] * scale); - } - } - else { - for (var i = 0; i < this._valueCount; ++i) { - this._current[i] = frameFloatArray[valueOffset + i] * scale; - } - } - } - else { - for (var i = 0; i < this._valueCount; ++i) { - this._current[i] = 0.0; - } - } - }; - DeformTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - this._dirty = true; - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - for (var i = 0; i < this._valueCount; ++i) { - this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; - } - }; - DeformTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - if (this._timelineData !== null) { - var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; - this.vertexOffset = this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */]; - if (this.vertexOffset < 0) { - this.vertexOffset += 65536; // Fixed out of bouds bug. - } - this._deformCount = this._frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._valueCount = this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; - this._valueOffset = this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; - this._frameFloatOffset = this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; - } - else { - var deformVertices = this.slot._deformVertices; - this._deformCount = deformVertices !== null ? deformVertices.vertices.length : 0; - this._valueCount = this._deformCount; - this._valueOffset = 0; - this._frameFloatOffset = 0; - } - this._current.length = this._valueCount; - this._delta.length = this._valueCount; - this._result.length = this._valueCount; - for (var i = 0; i < this._valueCount; ++i) { - this._delta[i] = 0.0; - } - }; - DeformTimelineState.prototype.fadeOut = function () { - this._tweenState = 0 /* None */; - this._dirty = false; - }; - DeformTimelineState.prototype.update = function (passedTime) { - var deformVertices = this.slot._deformVertices; - if (deformVertices === null || deformVertices.verticesData === null || deformVertices.verticesData.offset !== this.vertexOffset) { - return; - } - _super.prototype.update.call(this, passedTime); - // Fade animation. - if (this._tweenState !== 0 /* None */ || this._dirty) { - var result = deformVertices.vertices; - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); - for (var i = 0; i < this._deformCount; ++i) { - if (i < this._valueOffset) { - result[i] += (this._frameFloatArray[this._frameFloatOffset + i] - result[i]) * fadeProgress; - } - else if (i < this._valueOffset + this._valueCount) { - result[i] += (this._result[i - this._valueOffset] - result[i]) * fadeProgress; - } - else { - result[i] += (this._frameFloatArray[this._frameFloatOffset + i - this._valueCount] - result[i]) * fadeProgress; - } - } - deformVertices.verticesDirty = true; - } - else if (this._dirty) { - this._dirty = false; - for (var i = 0; i < this._deformCount; ++i) { - if (i < this._valueOffset) { - result[i] = this._frameFloatArray[this._frameFloatOffset + i]; - } - else if (i < this._valueOffset + this._valueCount) { - result[i] = this._result[i - this._valueOffset]; - } - else { - result[i] = this._frameFloatArray[this._frameFloatOffset + i - this._valueCount]; - } - } - deformVertices.verticesDirty = true; - } - } - }; - return DeformTimelineState; - }(dragonBones.SlotTimelineState)); - dragonBones.DeformTimelineState = DeformTimelineState; - /** - * @internal - */ - var IKConstraintTimelineState = /** @class */ (function (_super) { - __extends(IKConstraintTimelineState, _super); - function IKConstraintTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraintTimelineState.toString = function () { - return "[class dragonBones.IKConstraintTimelineState]"; - }; - IKConstraintTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._current = 0.0; - this._delta = 0.0; - }; - IKConstraintTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - var ikConstraint = this.constraint; - if (this._timelineData !== null) { - var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 2; - var frameIntArray = this._frameIntArray; - var bendPositive = frameIntArray[valueOffset++] !== 0; - this._current = frameIntArray[valueOffset++] * 0.01; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameIntOffset + this._frameValueOffset; // + 0 * 2 - } - this._delta = frameIntArray[valueOffset + 1] * 0.01 - this._current; - } - else { - this._delta = 0.0; - } - ikConstraint._bendPositive = bendPositive; - } - else { - var ikConstraintData = ikConstraint._constraintData; - this._current = ikConstraintData.weight; - this._delta = 0.0; - ikConstraint._bendPositive = ikConstraintData.bendPositive; - } - ikConstraint.invalidUpdate(); - }; - IKConstraintTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - var ikConstraint = this.constraint; - ikConstraint._weight = this._current + this._delta * this._tweenProgress; - ikConstraint.invalidUpdate(); - // TODO fade update. - }; - return IKConstraintTimelineState; - }(dragonBones.ConstraintTimelineState)); - dragonBones.IKConstraintTimelineState = IKConstraintTimelineState; - /** - * @internal - */ - var AnimationTimelineState = /** @class */ (function (_super) { - __extends(AnimationTimelineState, _super); - function AnimationTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._floats = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; - return _this; - } - AnimationTimelineState.toString = function () { - return "[class dragonBones.AnimationTimelineState]"; - }; - AnimationTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.animationState = null; - }; - AnimationTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { - return; - } - var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 2; - var frameRateR = 1.0 / this.animationState._animationData.parent.frameRate; - var frameIntArray = this._frameIntArray; - this._floats[0] = frameIntArray[valueOffset++] * frameRateR; - this._floats[3] = frameIntArray[valueOffset++] * 0.01; - if (this._tweenState === 2 /* Always */) { - if (this._frameIndex === this._frameCount - 1) { - valueOffset = this._animationData.frameIntOffset + this._frameValueOffset; // + 0 * 2 - } - this._floats[1] = frameIntArray[valueOffset++] * frameRateR - this._floats[0]; - this._floats[4] = frameIntArray[valueOffset++] * 0.01 - this._floats[3]; - } - else { - this._floats[1] = 0.0; - this._floats[4] = 0.0; - } - }; - AnimationTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._tweenState !== 2 /* Always */) { - this._tweenState = 0 /* None */; - } - if (this._floats[0] >= 0.0) { - this._floats[2] = this._floats[0] + this._floats[1] * this._tweenProgress; - } - this._floats[5] = this._floats[3] + this._floats[4] * this._tweenProgress; - }; - AnimationTimelineState.prototype.blend = function (state) { - var animationState = this.animationState; - var blendWeight = animationState._blendState.blendWeight; - if (state === 2) { - animationState.weight += this._floats[5] * blendWeight; - animationState.currentTime += this._floats[2] * blendWeight; - } - else { - animationState.weight = this._floats[5] * blendWeight; - animationState.currentTime = this._floats[2] * blendWeight; - } - }; - return AnimationTimelineState; - }(dragonBones.TweenTimelineState)); - dragonBones.AnimationTimelineState = AnimationTimelineState; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The properties of the object carry basic information about an event, - * which are passed as parameter or parameter's parameter to event listeners when an event occurs. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 - * @version DragonBones 4.5 - * @language zh_CN - */ - var EventObject = /** @class */ (function (_super) { - __extends(EventObject, _super); - function EventObject() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @internal - * @private - */ - EventObject.actionDataToInstance = function (data, instance, armature) { - if (data.type === 0 /* Play */) { - instance.type = EventObject.FRAME_EVENT; - } - else { - instance.type = data.type === 10 /* Frame */ ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; - } - instance.name = data.name; - instance.armature = armature; - instance.actionData = data; - instance.data = data.data; - if (data.bone !== null) { - instance.bone = armature.getBone(data.bone.name); - } - if (data.slot !== null) { - instance.slot = armature.getSlot(data.slot.name); - } - }; - EventObject.toString = function () { - return "[class dragonBones.EventObject]"; - }; - EventObject.prototype._onClear = function () { - this.time = 0.0; - this.type = ""; - this.name = ""; - this.armature = null; - this.bone = null; - this.slot = null; - this.animationState = null; - this.actionData = null; - this.data = null; - }; - /** - * - Animation start play. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画开始播放。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.START = "start"; - /** - * - Animation loop play complete once. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画循环播放完成一次。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.LOOP_COMPLETE = "loopComplete"; - /** - * - Animation play complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画播放完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.COMPLETE = "complete"; - /** - * - Animation fade in start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_IN = "fadeIn"; - /** - * - Animation fade in complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_IN_COMPLETE = "fadeInComplete"; - /** - * - Animation fade out start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_OUT = "fadeOut"; - /** - * - Animation fade out complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; - /** - * - Animation frame event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FRAME_EVENT = "frameEvent"; - /** - * - Animation frame sound event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧声音事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.SOUND_EVENT = "soundEvent"; - return EventObject; - }(dragonBones.BaseObject)); - dragonBones.EventObject = EventObject; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var DataParser = /** @class */ (function () { - function DataParser() { - } - DataParser._getArmatureType = function (value) { - switch (value.toLowerCase()) { - case "stage": - return 2 /* Stage */; - case "armature": - return 0 /* Armature */; - case "movieclip": - return 1 /* MovieClip */; - default: - return 0 /* Armature */; - } - }; - DataParser._getBoneType = function (value) { - switch (value.toLowerCase()) { - case "bone": - return 0 /* Bone */; - case "surface": - return 1 /* Surface */; - default: - return 0 /* Bone */; - } - }; - DataParser._getDisplayType = function (value) { - switch (value.toLowerCase()) { - case "image": - return 0 /* Image */; - case "mesh": - return 2 /* Mesh */; - case "armature": - return 1 /* Armature */; - case "boundingbox": - return 3 /* BoundingBox */; - case "path": - return 4 /* Path */; - default: - return 0 /* Image */; - } - }; - DataParser._getBoundingBoxType = function (value) { - switch (value.toLowerCase()) { - case "rectangle": - return 0 /* Rectangle */; - case "ellipse": - return 1 /* Ellipse */; - case "polygon": - return 2 /* Polygon */; - default: - return 0 /* Rectangle */; - } - }; - DataParser._getActionType = function (value) { - switch (value.toLowerCase()) { - case "play": - return 0 /* Play */; - case "frame": - return 10 /* Frame */; - case "sound": - return 11 /* Sound */; - default: - return 0 /* Play */; - } - }; - DataParser._getBlendMode = function (value) { - switch (value.toLowerCase()) { - case "normal": - return 0 /* Normal */; - case "add": - return 1 /* Add */; - case "alpha": - return 2 /* Alpha */; - case "darken": - return 3 /* Darken */; - case "difference": - return 4 /* Difference */; - case "erase": - return 5 /* Erase */; - case "hardlight": - return 6 /* HardLight */; - case "invert": - return 7 /* Invert */; - case "layer": - return 8 /* Layer */; - case "lighten": - return 9 /* Lighten */; - case "multiply": - return 10 /* Multiply */; - case "overlay": - return 11 /* Overlay */; - case "screen": - return 12 /* Screen */; - case "subtract": - return 13 /* Subtract */; - default: - return 0 /* Normal */; - } - }; - DataParser._getPositionMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "percent": - return 1 /* Percent */; - case "fixed": - return 0 /* Fixed */; - default: - return 1 /* Percent */; - } - }; - DataParser._getSpacingMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "length": - return 0 /* Length */; - case "percent": - return 2 /* Percent */; - case "fixed": - return 1 /* Fixed */; - default: - return 0 /* Length */; - } - }; - DataParser._getRotateMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "tangent": - return 0 /* Tangent */; - case "chain": - return 1 /* Chain */; - case "chainscale": - return 2 /* ChainScale */; - default: - return 0 /* Tangent */; - } - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - DataParser.parseDragonBonesData = function (rawData) { - console.warn("Deprecated."); - if (rawData instanceof ArrayBuffer) { - return dragonBones.BinaryDataParser.getInstance().parseDragonBonesData(rawData); - } - else { - return dragonBones.ObjectDataParser.getInstance().parseDragonBonesData(rawData); - } - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parsetTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parsetTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - DataParser.parseTextureAtlasData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.warn("已废弃"); - var textureAtlasData = {}; - var subTextureList = rawData[DataParser.SUB_TEXTURE]; - for (var i = 0, len = subTextureList.length; i < len; i++) { - var subTextureObject = subTextureList[i]; - var subTextureName = subTextureObject[DataParser.NAME]; - var subTextureRegion = new dragonBones.Rectangle(); - var subTextureFrame = null; - subTextureRegion.x = subTextureObject[DataParser.X] / scale; - subTextureRegion.y = subTextureObject[DataParser.Y] / scale; - subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; - subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; - if (DataParser.FRAME_WIDTH in subTextureObject) { - subTextureFrame = new dragonBones.Rectangle(); - subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; - subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; - subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; - subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; - } - textureAtlasData[subTextureName] = { region: subTextureRegion, frame: subTextureFrame, rotated: false }; - } - return textureAtlasData; - }; - DataParser.DATA_VERSION_2_3 = "2.3"; - DataParser.DATA_VERSION_3_0 = "3.0"; - DataParser.DATA_VERSION_4_0 = "4.0"; - DataParser.DATA_VERSION_4_5 = "4.5"; - DataParser.DATA_VERSION_5_0 = "5.0"; - DataParser.DATA_VERSION_5_5 = "5.5"; - DataParser.DATA_VERSION = DataParser.DATA_VERSION_5_5; - DataParser.DATA_VERSIONS = [ - DataParser.DATA_VERSION_4_0, - DataParser.DATA_VERSION_4_5, - DataParser.DATA_VERSION_5_0, - DataParser.DATA_VERSION_5_5 - ]; - DataParser.TEXTURE_ATLAS = "textureAtlas"; - DataParser.SUB_TEXTURE = "SubTexture"; - DataParser.FORMAT = "format"; - DataParser.IMAGE_PATH = "imagePath"; - DataParser.WIDTH = "width"; - DataParser.HEIGHT = "height"; - DataParser.ROTATED = "rotated"; - DataParser.FRAME_X = "frameX"; - DataParser.FRAME_Y = "frameY"; - DataParser.FRAME_WIDTH = "frameWidth"; - DataParser.FRAME_HEIGHT = "frameHeight"; - DataParser.DRADON_BONES = "dragonBones"; - DataParser.USER_DATA = "userData"; - DataParser.ARMATURE = "armature"; - DataParser.BONE = "bone"; - DataParser.SURFACE = "surface"; - DataParser.SLOT = "slot"; - DataParser.CONSTRAINT = "constraint"; - DataParser.IK = "ik"; - DataParser.PATH_CONSTRAINT = "path"; - DataParser.SKIN = "skin"; - DataParser.DISPLAY = "display"; - DataParser.ANIMATION = "animation"; - DataParser.Z_ORDER = "zOrder"; - DataParser.FFD = "ffd"; - DataParser.FRAME = "frame"; - DataParser.TRANSLATE_FRAME = "translateFrame"; - DataParser.ROTATE_FRAME = "rotateFrame"; - DataParser.SCALE_FRAME = "scaleFrame"; - DataParser.DISPLAY_FRAME = "displayFrame"; - DataParser.COLOR_FRAME = "colorFrame"; - DataParser.DEFAULT_ACTIONS = "defaultActions"; - DataParser.ACTIONS = "actions"; - DataParser.EVENTS = "events"; - DataParser.INTS = "ints"; - DataParser.FLOATS = "floats"; - DataParser.STRINGS = "strings"; - DataParser.CANVAS = "canvas"; - DataParser.TRANSFORM = "transform"; - DataParser.PIVOT = "pivot"; - DataParser.AABB = "aabb"; - DataParser.COLOR = "color"; - DataParser.VERSION = "version"; - DataParser.COMPATIBLE_VERSION = "compatibleVersion"; - DataParser.FRAME_RATE = "frameRate"; - DataParser.TYPE = "type"; - DataParser.SUB_TYPE = "subType"; - DataParser.NAME = "name"; - DataParser.PARENT = "parent"; - DataParser.TARGET = "target"; - DataParser.STAGE = "stage"; - DataParser.SHARE = "share"; - DataParser.PATH = "path"; - DataParser.LENGTH = "length"; - DataParser.DISPLAY_INDEX = "displayIndex"; - DataParser.BLEND_MODE = "blendMode"; - DataParser.INHERIT_TRANSLATION = "inheritTranslation"; - DataParser.INHERIT_ROTATION = "inheritRotation"; - DataParser.INHERIT_SCALE = "inheritScale"; - DataParser.INHERIT_REFLECTION = "inheritReflection"; - DataParser.INHERIT_ANIMATION = "inheritAnimation"; - DataParser.INHERIT_DEFORM = "inheritDeform"; - DataParser.SEGMENT_X = "segmentX"; - DataParser.SEGMENT_Y = "segmentY"; - DataParser.BEND_POSITIVE = "bendPositive"; - DataParser.CHAIN = "chain"; - DataParser.WEIGHT = "weight"; - DataParser.FADE_IN_TIME = "fadeInTime"; - DataParser.PLAY_TIMES = "playTimes"; - DataParser.SCALE = "scale"; - DataParser.OFFSET = "offset"; - DataParser.POSITION = "position"; - DataParser.DURATION = "duration"; - DataParser.TWEEN_EASING = "tweenEasing"; - DataParser.TWEEN_ROTATE = "tweenRotate"; - DataParser.TWEEN_SCALE = "tweenScale"; - DataParser.CLOCK_WISE = "clockwise"; - DataParser.CURVE = "curve"; - DataParser.SOUND = "sound"; - DataParser.EVENT = "event"; - DataParser.ACTION = "action"; - DataParser.X = "x"; - DataParser.Y = "y"; - DataParser.SKEW_X = "skX"; - DataParser.SKEW_Y = "skY"; - DataParser.SCALE_X = "scX"; - DataParser.SCALE_Y = "scY"; - DataParser.VALUE = "value"; - DataParser.ROTATE = "rotate"; - DataParser.SKEW = "skew"; - DataParser.ALPHA_OFFSET = "aO"; - DataParser.RED_OFFSET = "rO"; - DataParser.GREEN_OFFSET = "gO"; - DataParser.BLUE_OFFSET = "bO"; - DataParser.ALPHA_MULTIPLIER = "aM"; - DataParser.RED_MULTIPLIER = "rM"; - DataParser.GREEN_MULTIPLIER = "gM"; - DataParser.BLUE_MULTIPLIER = "bM"; - DataParser.UVS = "uvs"; - DataParser.VERTICES = "vertices"; - DataParser.TRIANGLES = "triangles"; - DataParser.WEIGHTS = "weights"; - DataParser.SLOT_POSE = "slotPose"; - DataParser.BONE_POSE = "bonePose"; - DataParser.GLUE_WEIGHTS = "glueWeights"; - DataParser.GLUE_MESHES = "glueMeshes"; - DataParser.BONES = "bones"; - DataParser.POSITION_MODE = "positionMode"; - DataParser.SPACING_MODE = "spacingMode"; - DataParser.ROTATE_MODE = "rotateMode"; - DataParser.SPACING = "spacing"; - DataParser.ROTATE_OFFSET = "rotateOffset"; - DataParser.ROTATE_MIX = "rotateMix"; - DataParser.TRANSLATE_MIX = "translateMix"; - DataParser.TARGET_DISPLAY = "targetDisplay"; - DataParser.CLOSED = "closed"; - DataParser.CONSTANT_SPEED = "constantSpeed"; - DataParser.VERTEX_COUNT = "vertexCount"; - DataParser.LENGTHS = "lengths"; - DataParser.GOTO_AND_PLAY = "gotoAndPlay"; - DataParser.DEFAULT_NAME = "default"; - return DataParser; - }()); - dragonBones.DataParser = DataParser; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var ObjectDataParser = /** @class */ (function (_super) { - __extends(ObjectDataParser, _super); - function ObjectDataParser() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._rawTextureAtlasIndex = 0; - _this._rawBones = []; - _this._data = null; // - _this._armature = null; // - _this._bone = null; // - _this._surface = null; // - _this._slot = null; // - _this._skin = null; // - _this._mesh = null; // - _this._animation = null; // - _this._timeline = null; // - _this._rawTextureAtlases = null; - _this._defaultColorOffset = -1; - _this._prevClockwise = 0; - _this._prevRotation = 0.0; - _this._helpMatrixA = new dragonBones.Matrix(); - _this._helpMatrixB = new dragonBones.Matrix(); - _this._helpTransform = new dragonBones.Transform(); - _this._helpColorTransform = new dragonBones.ColorTransform(); - _this._helpPoint = new dragonBones.Point(); - _this._helpArray = []; - _this._intArray = []; - _this._floatArray = []; - _this._frameIntArray = []; - _this._frameFloatArray = []; - _this._frameArray = []; - _this._timelineArray = []; - _this._cacheRawMeshes = []; - _this._cacheMeshes = []; - _this._actionFrames = []; - _this._weightSlotPose = {}; - _this._weightBonePoses = {}; - _this._cacheBones = {}; - _this._slotChildActions = {}; - return _this; - } - ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var type = typeof value; - if (type === "boolean") { - return value; - } - else if (type === "string") { - switch (value) { - case "0": - case "NaN": - case "": - case "false": - case "null": - case "undefined": - return false; - default: - return true; - } - } - else { - return !!value; - } - } - return defaultValue; - }; - ObjectDataParser._getNumber = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - if (value === null || value === "NaN") { - return defaultValue; - } - return +value || 0; - } - return defaultValue; - }; - ObjectDataParser._getString = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var type = typeof value; - if (type === "string") { - if (dragonBones.DragonBones.webAssembly) { - for (var i = 0, l = value.length; i < l; ++i) { - if (value.charCodeAt(i) > 255) { - return encodeURI(value); - } - } - } - return value; - } - return String(value); - } - return defaultValue; - }; - ObjectDataParser.prototype._getCurvePoint = function (x1, y1, x2, y2, x3, y3, x4, y4, t, result) { - var l_t = 1.0 - t; - var powA = l_t * l_t; - var powB = t * t; - var kA = l_t * powA; - var kB = 3.0 * t * powA; - var kC = 3.0 * l_t * powB; - var kD = t * powB; - result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; - result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; - }; - ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { - var curveCount = curve.length; - var stepIndex = -2; - for (var i = 0, l = samples.length; i < l; ++i) { - var t = (i + 1) / (l + 1); // float - while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { - stepIndex += 6; - } - var isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; - var x1 = isInCurve ? curve[stepIndex] : 0.0; - var y1 = isInCurve ? curve[stepIndex + 1] : 0.0; - var x2 = curve[stepIndex + 2]; - var y2 = curve[stepIndex + 3]; - var x3 = curve[stepIndex + 4]; - var y3 = curve[stepIndex + 5]; - var x4 = isInCurve ? curve[stepIndex + 6] : 1.0; - var y4 = isInCurve ? curve[stepIndex + 7] : 1.0; - var lower = 0.0; - var higher = 1.0; - while (higher - lower > 0.0001) { - var percentage = (higher + lower) * 0.5; - this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); - if (t - this._helpPoint.x > 0.0) { - lower = percentage; - } - else { - higher = percentage; - } - } - samples[i] = this._helpPoint.y; - } - }; - ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { - if (dragonBones.DataParser.EVENT in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); - } - if (dragonBones.DataParser.SOUND in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); - } - if (dragonBones.DataParser.ACTION in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.ACTION], frameStart, 0 /* Play */, bone, slot); - } - if (dragonBones.DataParser.EVENTS in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); - } - if (dragonBones.DataParser.ACTIONS in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); - } - }; - ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { - var actionOffset = dragonBones.DragonBones.webAssembly ? this._armature.actions.size() : this._armature.actions.length; - var actions = this._parseActionData(rawData, type, bone, slot); - var frameIndex = 0; - var frame = null; - for (var _i = 0, actions_2 = actions; _i < actions_2.length; _i++) { - var action = actions_2[_i]; - this._armature.addAction(action, false); - } - if (this._actionFrames.length === 0) { - frame = new ActionFrame(); - frame.frameStart = 0; - this._actionFrames.push(frame); - frame = null; - } - for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { - var eachFrame = _b[_a]; - if (eachFrame.frameStart === frameStart) { - frame = eachFrame; - break; - } - else if (eachFrame.frameStart > frameStart) { - break; - } - frameIndex++; - } - if (frame === null) { - frame = new ActionFrame(); - frame.frameStart = frameStart; - this._actionFrames.splice(frameIndex + 1, 0, frame); - } - for (var i = 0; i < actions.length; ++i) { - frame.actions.push(actionOffset + i); - } - }; - ObjectDataParser.prototype._parseArmature = function (rawData, scale) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); - armature.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - armature.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, this._data.frameRate); - armature.scale = scale; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - armature.type = dragonBones.DataParser._getArmatureType(rawData[dragonBones.DataParser.TYPE]); - } - else { - armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Armature */); - } - if (armature.frameRate === 0) { - armature.frameRate = 24; - } - this._armature = armature; - if (dragonBones.DataParser.CANVAS in rawData) { - var rawCanvas = rawData[dragonBones.DataParser.CANVAS]; - var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); - if (dragonBones.DataParser.COLOR in rawCanvas) { - canvas.hasBackground = true; - } - else { - canvas.hasBackground = false; - } - canvas.color = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.COLOR, 0); - canvas.x = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * armature.scale; - canvas.y = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * armature.scale; - canvas.width = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.WIDTH, 0) * armature.scale; - canvas.height = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.HEIGHT, 0) * armature.scale; - armature.canvas = canvas; - } - if (dragonBones.DataParser.AABB in rawData) { - var rawAABB = rawData[dragonBones.DataParser.AABB]; - armature.aabb.x = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0.0) * armature.scale; - armature.aabb.y = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0.0) * armature.scale; - armature.aabb.width = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.WIDTH, 0.0) * armature.scale; - armature.aabb.height = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.HEIGHT, 0.0) * armature.scale; - } - if (dragonBones.DataParser.BONE in rawData) { - var rawBones = rawData[dragonBones.DataParser.BONE]; - for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { - var rawBone = rawBones_1[_i]; - var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ""); - var bone = this._parseBone(rawBone); - if (parentName.length > 0) { - var parent_1 = armature.getBone(parentName); - if (parent_1 !== null) { - bone.parent = parent_1; - } - else { - if (!(parentName in this._cacheBones)) { - this._cacheBones[parentName] = []; - } - this._cacheBones[parentName].push(bone); - } - } - if (bone.name in this._cacheBones) { - for (var _a = 0, _b = this._cacheBones[bone.name]; _a < _b.length; _a++) { - var child = _b[_a]; - child.parent = bone; - } - delete this._cacheBones[bone.name]; - } - armature.addBone(bone); - this._rawBones.push(bone); // Cache raw bones sort. - } - } - if (dragonBones.DataParser.IK in rawData) { - var rawIKS = rawData[dragonBones.DataParser.IK]; - for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { - var rawIK = rawIKS_1[_c]; - var constraint = this._parseIKConstraint(rawIK); - if (constraint) { - armature.addConstraint(constraint); - } - } - } - armature.sortBones(); - if (dragonBones.DataParser.SLOT in rawData) { - var zOrder = 0; - var rawSlots = rawData[dragonBones.DataParser.SLOT]; - for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { - var rawSlot = rawSlots_1[_d]; - armature.addSlot(this._parseSlot(rawSlot, zOrder++)); - } - } - if (dragonBones.DataParser.SKIN in rawData) { - var rawSkins = rawData[dragonBones.DataParser.SKIN]; - for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { - var rawSkin = rawSkins_1[_e]; - armature.addSkin(this._parseSkin(rawSkin)); - } - } - if (dragonBones.DataParser.PATH_CONSTRAINT in rawData) { - var rawPaths = rawData[dragonBones.DataParser.PATH_CONSTRAINT]; - for (var _f = 0, rawPaths_1 = rawPaths; _f < rawPaths_1.length; _f++) { - var rawPath = rawPaths_1[_f]; - var constraint = this._parsePathConstraint(rawPath); - if (constraint) { - armature.addConstraint(constraint); - } - } - } - for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { - var rawMeshData = this._cacheRawMeshes[i]; - if (!(dragonBones.DataParser.GLUE_WEIGHTS in rawMeshData) || !(dragonBones.DataParser.GLUE_MESHES in rawMeshData)) { - continue; - } - this._parseMeshGlue(rawMeshData, this._cacheMeshes[i]); - } - for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { - var rawData_1 = this._cacheRawMeshes[i]; - var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ""); - if (shareName.length === 0) { - continue; - } - var skinName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - if (skinName.length === 0) { - skinName = dragonBones.DataParser.DEFAULT_NAME; - } - var shareMesh = armature.getMesh(skinName, "", shareName); // TODO slot; - if (shareMesh === null) { - continue; // Error. - } - var mesh = this._cacheMeshes[i]; - mesh.vertices.shareFrom(shareMesh.vertices); - } - if (dragonBones.DataParser.ANIMATION in rawData) { - var rawAnimations = rawData[dragonBones.DataParser.ANIMATION]; - for (var _g = 0, rawAnimations_1 = rawAnimations; _g < rawAnimations_1.length; _g++) { - var rawAnimation = rawAnimations_1[_g]; - var animation = this._parseAnimation(rawAnimation); - armature.addAnimation(animation); - } - } - if (dragonBones.DataParser.DEFAULT_ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.DEFAULT_ACTIONS], 0 /* Play */, null, null); - for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { - var action = actions_3[_h]; - armature.addAction(action, true); - if (action.type === 0 /* Play */) { - var animation = armature.getAnimation(action.name); - if (animation !== null) { - armature.defaultAnimation = animation; - } - } - } - } - if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - for (var _j = 0, actions_4 = actions; _j < actions_4.length; _j++) { - var action = actions_4[_j]; - armature.addAction(action, false); - } - } - // Clear helper. - this._rawBones.length = 0; - this._cacheRawMeshes.length = 0; - this._cacheMeshes.length = 0; - this._armature = null; - for (var k in this._weightSlotPose) { - delete this._weightSlotPose[k]; - } - for (var k in this._weightBonePoses) { - delete this._weightBonePoses[k]; - } - for (var k in this._cacheBones) { - delete this._cacheBones[k]; - } - for (var k in this._slotChildActions) { - delete this._slotChildActions[k]; - } - return armature; - }; - ObjectDataParser.prototype._parseBone = function (rawData) { - var type = 0 /* Bone */; - var scale = this._armature.scale; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - type = dragonBones.DataParser._getBoneType(rawData[dragonBones.DataParser.TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Bone */); - } - if (type === 0 /* Bone */) { - var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); - bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_TRANSLATION, true); - bone.inheritRotation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_ROTATION, true); - bone.inheritScale = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_SCALE, true); - bone.inheritReflection = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_REFLECTION, true); - bone.length = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.LENGTH, 0) * scale; - bone.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], bone.transform, scale); - } - return bone; - } - var surface = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceData); - surface.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - surface.segmentX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_X, 0); - surface.segmentY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_Y, 0); - surface.vertices.length = (surface.segmentX + 1) * (surface.segmentY + 1) * 2; - if (dragonBones.DataParser.VERTICES in rawData) { - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - for (var i = 0, l = surface.vertices.length; i < l; ++i) { - if (i < rawVertices.length) { - surface.vertices[i] = rawVertices[i] * scale; - } - else { - surface.vertices[i] = 0.0; - } - } - } - return surface; - }; - ObjectDataParser.prototype._parseIKConstraint = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, "")); - if (bone === null) { - return null; - } - var target = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); - if (target === null) { - return null; - } - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); - constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.SCALE, false); - constraint.bendPositive = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true); - constraint.weight = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0); - constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - constraint.type = 0 /* IK */; - constraint.target = target; - var chain = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CHAIN, 0); - if (chain > 0 && bone.parent !== null) { - constraint.root = bone.parent; - constraint.bone = bone; - } - else { - constraint.root = bone; - constraint.bone = null; - } - return constraint; - }; - ObjectDataParser.prototype._parsePathConstraint = function (rawData) { - var target = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); - if (target === null) { - return null; - } - var defaultSkin = this._armature.defaultSkin; - if (defaultSkin === null) { - return null; - } - //TODO - var targetDisplay = defaultSkin.getDisplay(target.name, ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET_DISPLAY, target.name)); - if (targetDisplay === null || !(targetDisplay instanceof dragonBones.PathDisplayData)) { - return null; - } - var bones = rawData[dragonBones.DataParser.BONES]; - if (bones === null || bones.length === 0) { - return null; - } - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraintData); - constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - constraint.type = 1 /* Path */; - constraint.pathSlot = target; - constraint.pathDisplayData = targetDisplay; - constraint.target = target.parent; - constraint.positionMode = dragonBones.DataParser._getPositionMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.POSITION_MODE, "")); - constraint.spacingMode = dragonBones.DataParser._getSpacingMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.SPACING_MODE, "")); - constraint.rotateMode = dragonBones.DataParser._getRotateMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.ROTATE_MODE, "")); - constraint.position = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.POSITION, 0); - constraint.spacing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SPACING, 0); - constraint.rotateOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_OFFSET, 0); - constraint.rotateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_MIX, 1); - constraint.translateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TRANSLATE_MIX, 1); - // - for (var _i = 0, bones_3 = bones; _i < bones_3.length; _i++) { - var boneName = bones_3[_i]; - var bone = this._armature.getBone(boneName); - if (bone !== null) { - constraint.AddBone(bone); - if (constraint.root === null) { - constraint.root = bone; - } - } - } - return constraint; - }; - ObjectDataParser.prototype._parseSlot = function (rawData, zOrder) { - var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); - slot.displayIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); - slot.zOrder = zOrder; - slot.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, "")); // - if (dragonBones.DataParser.BLEND_MODE in rawData && typeof rawData[dragonBones.DataParser.BLEND_MODE] === "string") { - slot.blendMode = dragonBones.DataParser._getBlendMode(rawData[dragonBones.DataParser.BLEND_MODE]); - } - else { - slot.blendMode = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLEND_MODE, 0 /* Normal */); - } - if (dragonBones.DataParser.COLOR in rawData) { - slot.color = dragonBones.SlotData.createColor(); - this._parseColorTransform(rawData[dragonBones.DataParser.COLOR], slot.color); - } - else { - slot.color = dragonBones.SlotData.DEFAULT_COLOR; - } - if (dragonBones.DataParser.ACTIONS in rawData) { - this._slotChildActions[slot.name] = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - } - return slot; - }; - ObjectDataParser.prototype._parseSkin = function (rawData) { - var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); - skin.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (skin.name.length === 0) { - skin.name = dragonBones.DataParser.DEFAULT_NAME; - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawSlots = rawData[dragonBones.DataParser.SLOT]; - this._skin = skin; - for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { - var rawSlot = rawSlots_2[_i]; - var slotName = ObjectDataParser._getString(rawSlot, dragonBones.DataParser.NAME, ""); - var slot = this._armature.getSlot(slotName); - if (slot !== null) { - this._slot = slot; - if (dragonBones.DataParser.DISPLAY in rawSlot) { - var rawDisplays = rawSlot[dragonBones.DataParser.DISPLAY]; - for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { - var rawDisplay = rawDisplays_1[_a]; - if (rawDisplay) { - skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); - } - else { - skin.addDisplay(slotName, null); - } - } - } - this._slot = null; // - } - } - this._skin = null; // - } - return skin; - }; - ObjectDataParser.prototype._parseDisplay = function (rawData) { - var name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - var path = ObjectDataParser._getString(rawData, dragonBones.DataParser.PATH, ""); - var type = 0 /* Image */; - var display = null; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - type = dragonBones.DataParser._getDisplayType(rawData[dragonBones.DataParser.TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, type); - } - switch (type) { - case 0 /* Image */: - var imageDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); - imageDisplay.name = name; - imageDisplay.path = path.length > 0 ? path : name; - this._parsePivot(rawData, imageDisplay); - break; - case 1 /* Armature */: - var armatureDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); - armatureDisplay.name = name; - armatureDisplay.path = path.length > 0 ? path : name; - armatureDisplay.inheritAnimation = true; - if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - for (var _i = 0, actions_5 = actions; _i < actions_5.length; _i++) { - var action = actions_5[_i]; - armatureDisplay.addAction(action); - } - } - else if (this._slot.name in this._slotChildActions) { - var displays = this._skin.getDisplays(this._slot.name); - if (displays === null ? this._slot.displayIndex === 0 : this._slot.displayIndex === displays.length) { - for (var _a = 0, _b = this._slotChildActions[this._slot.name]; _a < _b.length; _a++) { - var action = _b[_a]; - armatureDisplay.addAction(action); - } - delete this._slotChildActions[this._slot.name]; - } - } - break; - case 2 /* Mesh */: - var meshDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); - meshDisplay.vertices.inheritDeform = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_DEFORM, true); - meshDisplay.name = name; - meshDisplay.path = path.length > 0 ? path : name; - meshDisplay.vertices.data = this._data; - if (dragonBones.DataParser.SHARE in rawData) { - this._cacheRawMeshes.push(rawData); - this._cacheMeshes.push(meshDisplay); - } - else { - this._parseMesh(rawData, meshDisplay); - } - if ((dragonBones.DataParser.GLUE_WEIGHTS in rawData) && (dragonBones.DataParser.GLUE_MESHES in rawData)) { - this._cacheRawMeshes.push(rawData); - this._cacheMeshes.push(meshDisplay); - } - break; - case 3 /* BoundingBox */: - var boundingBox = this._parseBoundingBox(rawData); - if (boundingBox !== null) { - var boundingBoxDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); - boundingBoxDisplay.name = name; - boundingBoxDisplay.path = path.length > 0 ? path : name; - boundingBoxDisplay.boundingBox = boundingBox; - } - break; - case 4 /* Path */: - var rawCurveLengths = rawData[dragonBones.DataParser.LENGTHS]; - var pathDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.PathDisplayData); - pathDisplay.closed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CLOSED, false); - pathDisplay.constantSpeed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CONSTANT_SPEED, false); - pathDisplay.name = name; - pathDisplay.path = path.length > 0 ? path : name; - pathDisplay.vertices.data = this._data; - pathDisplay.curveLengths.length = rawCurveLengths.length; - for (var i = 0, l = rawCurveLengths.length; i < l; ++i) { - pathDisplay.curveLengths[i] = rawCurveLengths[i]; - } - this._parsePath(rawData, pathDisplay); - break; - } - if (display !== null && dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], display.transform, this._armature.scale); - } - return display; - }; - ObjectDataParser.prototype._parsePath = function (rawData, display) { - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var vertexCount = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VERTEX_COUNT, 0); // uint - var vertexOffset = this._floatArray.length; - var pathOffset = this._intArray.length; - display.vertices.offset = pathOffset; - this._intArray.length += 1 + 1; - this._intArray[pathOffset + 0 /* PathVertexCount */] = vertexCount; - this._intArray[pathOffset + 2 /* PathFloatOffset */] = vertexOffset; - if (!(dragonBones.DataParser.WEIGHTS in rawData)) { - this._floatArray.length += rawVertices.length; - for (var i = 0, l = rawVertices.length; i < l; ++i) { - this._floatArray[vertexOffset + i] = rawVertices[i]; - } - } - else { - var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; - var rawBones = rawData[dragonBones.DataParser.BONES]; - var weightBoneCount = rawBones.length; - var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; // uint - var weightOffset = this._intArray.length; - var floatOffset = this._floatArray.length; - var sortedBones = this._armature.sortedBones; - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - weight.count = weightCount; - weight.offset = weightOffset; - this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; - // - this._intArray[weightOffset + 0 /* WeigthBoneCount */] = weightBoneCount; - this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; - for (var i = 0; i < weightBoneCount; i++) { - var rawBoneIndex = rawBones[i]; - var bone = this._rawBones[rawBoneIndex]; - weight.addBone(bone); - this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); - } - this._floatArray.length += weightCount * 3; - for (var i = 0, iW = 0, iV = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iF = floatOffset; i < weightCount; i++) { - var boneCount = rawWeights[iW++]; - this._intArray[iB++] = boneCount; - for (var j = 0; j < boneCount; j++) { - var boneIndex = rawWeights[iW++]; - var boneWeight = rawWeights[iW++]; - var x = rawVertices[iV++]; - var y = rawVertices[iV++]; - this._intArray[iB++] = rawBones.indexOf(boneIndex); - this._floatArray[iF++] = boneWeight; - this._floatArray[iF++] = x; - this._floatArray[iF++] = y; - } - } - display.vertices.weight = weight; - } - }; - ObjectDataParser.prototype._parsePivot = function (rawData, display) { - if (dragonBones.DataParser.PIVOT in rawData) { - var rawPivot = rawData[dragonBones.DataParser.PIVOT]; - display.pivot.x = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.X, 0.0); - display.pivot.y = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.Y, 0.0); - } - else { - display.pivot.x = 0.5; - display.pivot.y = 0.5; - } - }; - ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var rawUVs = rawData[dragonBones.DataParser.UVS]; - var rawTriangles = rawData[dragonBones.DataParser.TRIANGLES]; - var vertexCount = Math.floor(rawVertices.length / 2); // uint - var triangleCount = Math.floor(rawTriangles.length / 3); // uint - var vertexOffset = this._floatArray.length; - var uvOffset = vertexOffset + vertexCount * 2; - var meshOffset = this._intArray.length; - var meshName = this._skin.name + "_" + this._slot.name + "_" + mesh.name; // Cache pose data. - mesh.vertices.offset = meshOffset; - this._intArray.length += 1 + 1 + 1 + 1 + triangleCount * 3; - this._intArray[meshOffset + 0 /* MeshVertexCount */] = vertexCount; - this._intArray[meshOffset + 1 /* MeshTriangleCount */] = triangleCount; - this._intArray[meshOffset + 2 /* MeshFloatOffset */] = vertexOffset; - for (var i = 0, l = triangleCount * 3; i < l; ++i) { - this._intArray[meshOffset + 4 /* MeshVertexIndices */ + i] = rawTriangles[i]; - } - this._floatArray.length += vertexCount * 2 + vertexCount * 2; - for (var i = 0, l = vertexCount * 2; i < l; ++i) { - this._floatArray[vertexOffset + i] = rawVertices[i]; - this._floatArray[uvOffset + i] = rawUVs[i]; - } - if (dragonBones.DataParser.WEIGHTS in rawData) { - var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; - var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; - var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; - var sortedBones = this._armature.sortedBones; - var weightBoneIndices = new Array(); - var weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint - var floatOffset = this._floatArray.length; - var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; // uint - var weightOffset = this._intArray.length; - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - weight.count = weightCount; - weight.offset = weightOffset; - weightBoneIndices.length = weightBoneCount; - this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; - this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; - for (var i = 0; i < weightBoneCount; ++i) { - var rawBoneIndex = rawBonePoses[i * 7]; // uint - var bone = this._rawBones[rawBoneIndex]; - weight.addBone(bone); - weightBoneIndices[i] = rawBoneIndex; - this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); - } - this._floatArray.length += weightCount * 3; - this._helpMatrixA.copyFromArray(rawSlotPose, 0); - for (var i = 0, iW = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { - var iD = i * 2; - var vertexBoneCount = this._intArray[iB++] = rawWeights[iW++]; // uint - var x = this._floatArray[vertexOffset + iD]; - var y = this._floatArray[vertexOffset + iD + 1]; - this._helpMatrixA.transformPoint(x, y, this._helpPoint); - x = this._helpPoint.x; - y = this._helpPoint.y; - for (var j = 0; j < vertexBoneCount; ++j) { - var rawBoneIndex = rawWeights[iW++]; // uint - var boneIndex = weightBoneIndices.indexOf(rawBoneIndex); - this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); - this._helpMatrixB.invert(); - this._helpMatrixB.transformPoint(x, y, this._helpPoint); - this._intArray[iB++] = boneIndex; - this._floatArray[iV++] = rawWeights[iW++]; - this._floatArray[iV++] = this._helpPoint.x; - this._floatArray[iV++] = this._helpPoint.y; - } - } - mesh.vertices.weight = weight; - this._weightSlotPose[meshName] = rawSlotPose; - this._weightBonePoses[meshName] = rawBonePoses; - } - }; - ObjectDataParser.prototype._parseMeshGlue = function (rawData, mesh) { - rawData; - mesh; - // const rawWeights = rawData[DataParser.GLUE_WEIGHTS] as Array; - // const rawMeshes = rawData[DataParser.GLUE_MESHES] as Array; - // mesh.glue = BaseObject.borrowObject(GlueData); - // mesh.glue.weights.length = rawWeights.length; - // for (let i = 0, l = rawWeights.length; i < l; ++i) { - // mesh.glue.weights[i] = rawWeights[i]; - // } - // for (let i = 0, l = rawMeshes.length; i < l; i += 3) { - // const glueMesh = this._armature.getMesh(rawMeshes[i], rawMeshes[i + 1], rawMeshes[i + 2]); - // mesh.glue.addMesh(glueMesh); - // } - }; - ObjectDataParser.prototype._parseBoundingBox = function (rawData) { - var boundingBox = null; - var type = 0 /* Rectangle */; - if (dragonBones.DataParser.SUB_TYPE in rawData && typeof rawData[dragonBones.DataParser.SUB_TYPE] === "string") { - type = dragonBones.DataParser._getBoundingBoxType(rawData[dragonBones.DataParser.SUB_TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SUB_TYPE, type); - } - switch (type) { - case 0 /* Rectangle */: - boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); - break; - case 1 /* Ellipse */: - boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); - break; - case 2 /* Polygon */: - boundingBox = this._parsePolygonBoundingBox(rawData); - break; - } - if (boundingBox !== null) { - boundingBox.color = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.COLOR, 0x000000); - if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { - boundingBox.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0.0); - boundingBox.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0.0); - } - } - return boundingBox; - }; - ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { - var polygonBoundingBox = dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); - if (dragonBones.DataParser.VERTICES in rawData) { - var scale = this._armature.scale; - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var vertices = polygonBoundingBox.vertices; - if (dragonBones.DragonBones.webAssembly) { - vertices.resize(rawVertices.length, 0.0); - } - else { - vertices.length = rawVertices.length; - } - for (var i = 0, l = rawVertices.length; i < l; i += 2) { - var x = rawVertices[i] * scale; - var y = rawVertices[i + 1] * scale; - if (dragonBones.DragonBones.webAssembly) { - vertices.set(i, x); - vertices.set(i + 1, y); - } - else { - vertices[i] = x; - vertices[i + 1] = y; - } - // AABB. - if (i === 0) { - polygonBoundingBox.x = x; - polygonBoundingBox.y = y; - polygonBoundingBox.width = x; - polygonBoundingBox.height = y; - } - else { - if (x < polygonBoundingBox.x) { - polygonBoundingBox.x = x; - } - else if (x > polygonBoundingBox.width) { - polygonBoundingBox.width = x; - } - if (y < polygonBoundingBox.y) { - polygonBoundingBox.y = y; - } - else if (y > polygonBoundingBox.height) { - polygonBoundingBox.height = y; - } - } - } - polygonBoundingBox.width -= polygonBoundingBox.x; - polygonBoundingBox.height -= polygonBoundingBox.y; - } - else { - console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug."); - } - return polygonBoundingBox; - }; - ObjectDataParser.prototype._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 1), 1); - animation.playTimes = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); - animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); - animation.scale = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); - animation.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (animation.name.length === 0) { - animation.name = dragonBones.DataParser.DEFAULT_NAME; - } - animation.frameIntOffset = this._frameIntArray.length; - animation.frameFloatOffset = this._frameFloatArray.length; - animation.frameOffset = this._frameArray.length; - this._animation = animation; - if (dragonBones.DataParser.FRAME in rawData) { - var rawFrames = rawData[dragonBones.DataParser.FRAME]; - var keyFrameCount = rawFrames.length; - if (keyFrameCount > 0) { - for (var i = 0, frameStart = 0; i < keyFrameCount; ++i) { - var rawFrame = rawFrames[i]; - this._parseActionDataInFrame(rawFrame, frameStart, null, null); - frameStart += ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); - } - } - } - if (dragonBones.DataParser.Z_ORDER in rawData) { - this._animation.zOrderTimeline = this._parseTimeline(rawData[dragonBones.DataParser.Z_ORDER], null, dragonBones.DataParser.FRAME, 1 /* ZOrder */, false, false, 0, this._parseZOrderFrame); - } - if (dragonBones.DataParser.BONE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.BONE]; - for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { - var rawTimeline = rawTimelines_1[_i]; - this._parseBoneTimeline(rawTimeline); - } - } - if (dragonBones.DataParser.SURFACE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.SURFACE]; - for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { - var rawTimeline = rawTimelines_2[_a]; - var surfaceName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - this._surface = this._armature.getBone(surfaceName); - if (this._surface === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 50 /* Surface */, false, true, 0, this._parseSurfaceFrame); - if (timeline !== null) { - this._animation.addSurfaceTimeline(this._surface, timeline); - } - this._surface = null; // - } - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.SLOT]; - for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { - var rawTimeline = rawTimelines_3[_b]; - this._parseSlotTimeline(rawTimeline); - } - } - if (dragonBones.DataParser.FFD in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.FFD]; - for (var _c = 0, rawTimelines_4 = rawTimelines; _c < rawTimelines_4.length; _c++) { - var rawTimeline = rawTimelines_4[_c]; - var skinName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ""); - var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - if (skinName.length === 0) { - skinName = dragonBones.DataParser.DEFAULT_NAME; - } - this._slot = this._armature.getSlot(slotName); - this._mesh = this._armature.getMesh(skinName, slotName, displayName); - if (this._slot === null || this._mesh === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 22 /* SlotDeform */, false, true, 0, this._parseSlotFFDFrame); - if (timeline !== null) { - this._animation.addSlotTimeline(this._slot, timeline); - } - this._slot = null; // - this._mesh = null; // - } - } - if (dragonBones.DataParser.IK in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.IK]; - for (var _d = 0, rawTimelines_5 = rawTimelines; _d < rawTimelines_5.length; _d++) { - var rawTimeline = rawTimelines_5[_d]; - var constraintName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var constraint = this._armature.getConstraint(constraintName); - if (constraint === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 30 /* IKConstraint */, true, false, 2, this._parseIKConstraintFrame); - if (timeline !== null) { - this._animation.addConstraintTimeline(constraint, timeline); - } - } - } - if (dragonBones.DataParser.ANIMATION in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.ANIMATION]; - for (var _e = 0, rawTimelines_6 = rawTimelines; _e < rawTimelines_6.length; _e++) { - var rawTimeline = rawTimelines_6[_e]; - var animationName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 40 /* AnimationTime */, true, false, 2, this._parseAnimationFrame); - if (timeline !== null) { - this._animation.addAnimationTimeline(animationName, timeline); - } - } - } - if (this._actionFrames.length > 0) { - this._animation.actionTimeline = this._parseTimeline(null, this._actionFrames, "", 0 /* Action */, false, false, 0, this._parseActionFrame); - this._actionFrames.length = 0; - } - this._animation = null; // - return animation; - }; - ObjectDataParser.prototype._parseTimeline = function (rawData, rawFrames, framesKey, type, addIntOffset, addFloatOffset, frameValueCount, frameParser) { - if (rawData !== null && framesKey.length > 0 && framesKey in rawData) { - rawFrames = rawData[framesKey]; - } - if (rawFrames === null) { - return null; - } - var keyFrameCount = rawFrames.length; - if (keyFrameCount === 0) { - return null; - } - var frameIntArrayLength = this._frameIntArray.length; - var frameFloatArrayLength = this._frameFloatArray.length; - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); - var timelineOffset = this._timelineArray.length; - this._timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; - if (rawData !== null) { - this._timelineArray[timelineOffset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0) * 100); - this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0.0) * 100); - } - else { - this._timelineArray[timelineOffset + 0 /* TimelineScale */] = 100; - this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = 0; - } - this._timelineArray[timelineOffset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; - this._timelineArray[timelineOffset + 3 /* TimelineFrameValueCount */] = frameValueCount; - if (addIntOffset) { - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; - } - else if (addFloatOffset) { - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; - } - else { - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = 0; - } - this._timeline = timeline; - timeline.type = type; - timeline.offset = timelineOffset; - if (keyFrameCount === 1) { - timeline.frameIndicesOffset = -1; - this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; - } - else { - var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. - var frameIndices = this._data.frameIndices; - var frameIndicesOffset = 0; - if (dragonBones.DragonBones.webAssembly) { - frameIndicesOffset = frameIndices.size(); - frameIndices.resize(frameIndicesOffset + totalFrameCount, 0); - } - else { - frameIndicesOffset = frameIndices.length; - frameIndices.length += totalFrameCount; - } - timeline.frameIndicesOffset = frameIndicesOffset; - for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { - if (frameStart + frameCount <= i && iK < keyFrameCount) { - var rawFrame = rawFrames[iK]; - frameStart = i; // frame.frameStart; - if (iK === keyFrameCount - 1) { - frameCount = this._animation.frameCount - frameStart; - } - else { - if (rawFrame instanceof ActionFrame) { - frameCount = this._actionFrames[iK + 1].frameStart - frameStart; - } - else { - frameCount = ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); - } - } - this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; - iK++; - } - if (dragonBones.DragonBones.webAssembly) { - frameIndices.set(frameIndicesOffset + i, iK - 1); - } - else { - frameIndices[frameIndicesOffset + i] = iK - 1; - } - } - } - this._timeline = null; // - return timeline; - }; - ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); - if (bone === null) { - return; - } - this._bone = bone; - this._slot = this._armature.getSlot(this._bone.name); - if (dragonBones.DataParser.TRANSLATE_FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.TRANSLATE_FRAME, 11 /* BoneTranslate */, false, true, 2, this._parseBoneTranslateFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone, timeline); - } - } - if (dragonBones.DataParser.ROTATE_FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.ROTATE_FRAME, 12 /* BoneRotate */, false, true, 2, this._parseBoneRotateFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone, timeline); - } - } - if (dragonBones.DataParser.SCALE_FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.SCALE_FRAME, 13 /* BoneScale */, false, true, 2, this._parseBoneScaleFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone, timeline); - } - } - if (dragonBones.DataParser.FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 10 /* BoneAll */, false, true, 6, this._parseBoneAllFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone, timeline); - } - } - this._bone = null; // - this._slot = null; // - }; - ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { - var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); - if (slot === null) { - return; - } - this._slot = slot; - // Display timeline. - var displayTimeline = null; - if (dragonBones.DataParser.DISPLAY_FRAME in rawData) { - displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.DISPLAY_FRAME, 20 /* SlotDisplay */, false, false, 0, this._parseSlotDisplayFrame); - } - else { - displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 20 /* SlotDisplay */, false, false, 0, this._parseSlotDisplayFrame); - } - if (displayTimeline !== null) { - this._animation.addSlotTimeline(slot, displayTimeline); - } - var colorTimeline = null; - if (dragonBones.DataParser.COLOR_FRAME in rawData) { - colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.COLOR_FRAME, 21 /* SlotColor */, true, false, 1, this._parseSlotColorFrame); - } - else { - colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 21 /* SlotColor */, true, false, 1, this._parseSlotColorFrame); - } - if (colorTimeline !== null) { - this._animation.addSlotTimeline(slot, colorTimeline); - } - this._slot = null; // - }; - ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount) { - // tslint:disable-next-line:no-unused-expression - rawData; - // tslint:disable-next-line:no-unused-expression - frameCount; - var frameOffset = this._frameArray.length; - this._frameArray.length += 1; - this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; - return frameOffset; - }; - ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - if (frameCount > 0) { - if (dragonBones.DataParser.CURVE in rawData) { - var sampleCount = frameCount + 1; - this._helpArray.length = sampleCount; - this._samplingEasingCurve(rawData[dragonBones.DataParser.CURVE], this._helpArray); - this._frameArray.length += 1 + 1 + this._helpArray.length; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = sampleCount; - for (var i = 0; i < sampleCount; ++i) { - this._frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); - } - } - else { - var noTween = -2.0; - var tweenEasing = noTween; - if (dragonBones.DataParser.TWEEN_EASING in rawData) { - tweenEasing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_EASING, noTween); - } - if (tweenEasing === noTween) { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; - } - else if (tweenEasing === 0.0) { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; - } - else if (tweenEasing < 0.0) { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); - } - else if (tweenEasing <= 1.0) { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); - } - else { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); - } - } - } - else { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseActionFrame = function (frame, frameStart, frameCount) { - // tslint:disable-next-line:no-unused-expression - frameCount; - var frameOffset = this._frameArray.length; - var actionCount = frame.actions.length; - this._frameArray.length += 1 + 1 + actionCount; - this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; - this._frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. - for (var i = 0; i < actionCount; ++i) { - this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - if (dragonBones.DataParser.Z_ORDER in rawData) { - var rawZOrder = rawData[dragonBones.DataParser.Z_ORDER]; - if (rawZOrder.length > 0) { - var slotCount = this._armature.sortedSlots.length; - var unchanged = new Array(slotCount - rawZOrder.length / 2); - var zOrders = new Array(slotCount); - for (var i_1 = 0; i_1 < unchanged.length; ++i_1) { - unchanged[i_1] = 0; - } - for (var i_2 = 0; i_2 < slotCount; ++i_2) { - zOrders[i_2] = -1; - } - var originalIndex = 0; - var unchangedIndex = 0; - for (var i_3 = 0, l = rawZOrder.length; i_3 < l; i_3 += 2) { - var slotIndex = rawZOrder[i_3]; - var zOrderOffset = rawZOrder[i_3 + 1]; - while (originalIndex !== slotIndex) { - unchanged[unchangedIndex++] = originalIndex++; - } - var index = originalIndex + zOrderOffset; - zOrders[index] = originalIndex++; - } - while (originalIndex < slotCount) { - unchanged[unchangedIndex++] = originalIndex++; - } - this._frameArray.length += 1 + slotCount; - this._frameArray[frameOffset + 1] = slotCount; - var i = slotCount; - while (i--) { - if (zOrders[i] === -1) { - this._frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex] || 0; - } - else { - this._frameArray[frameOffset + 2 + i] = zOrders[i] || 0; - } - } - return frameOffset; - } - } - this._frameArray.length += 1; - this._frameArray[frameOffset + 1] = 0; - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneAllFrame = function (rawData, frameStart, frameCount) { - this._helpTransform.identity(); - if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], this._helpTransform, 1.0); - } - // Modify rotation. - var rotation = this._helpTransform.rotation; - if (frameStart !== 0) { - if (this._prevClockwise === 0) { - rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); - } - else { - if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { - this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; - } - rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; - } - } - this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_ROTATE, 0.0); - this._prevRotation = rotation; - // - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 6; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.x; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.y; - this._frameFloatArray[frameFloatOffset++] = rotation; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; - this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneTranslateFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneRotateFrame = function (rawData, frameStart, frameCount) { - // Modify rotation. - var rotation = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD; - if (frameStart !== 0) { - if (this._prevClockwise === 0) { - rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); - } - else { - if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { - this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; - } - rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; - } - } - this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CLOCK_WISE, 0); - this._prevRotation = rotation; - // - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = rotation; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD; - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneScaleFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 1.0); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 1.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseSurfaceFrame = function (rawData, frameStart, frameCount) { - var frameFloatOffset = this._frameFloatArray.length; - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint - var vertexCount = this._surface.vertices.length / 2; // uint - var x = 0.0; - var y = 0.0; - this._frameFloatArray.length += vertexCount * 2; - for (var i = 0; i < vertexCount * 2; i += 2) { - if (i < offset || i - offset >= rawVertices.length) { - x = 0.0; - } - else { - x = rawVertices[i - offset]; - } - if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { - y = 0.0; - } - else { - y = rawVertices[i + 1 - offset]; - } - this._frameFloatArray[frameFloatOffset + i] = x; - this._frameFloatArray[frameFloatOffset + i + 1] = y; - } - if (frameStart === 0) { - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = 0; // - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; - this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotDisplayFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 1; - if (dragonBones.DataParser.VALUE in rawData) { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); - } - else { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); - } - this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var colorOffset = -1; - if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { - var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : rawData[dragonBones.DataParser.COLOR]; - for (var k in rawColor) { - // tslint:disable-next-line:no-unused-expression - k; - this._parseColorTransform(rawColor, this._helpColorTransform); - colorOffset = this._intArray.length; - this._intArray.length += 8; - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); - this._intArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); - colorOffset -= 8; - break; - } - } - if (colorOffset < 0) { - if (this._defaultColorOffset < 0) { - this._defaultColorOffset = colorOffset = this._intArray.length; - this._intArray.length += 8; - this._intArray[colorOffset++] = 100; - this._intArray[colorOffset++] = 100; - this._intArray[colorOffset++] = 100; - this._intArray[colorOffset++] = 100; - this._intArray[colorOffset++] = 0; - this._intArray[colorOffset++] = 0; - this._intArray[colorOffset++] = 0; - this._intArray[colorOffset++] = 0; - } - colorOffset = this._defaultColorOffset; - } - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1; - this._frameIntArray[frameIntOffset] = colorOffset; - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotFFDFrame = function (rawData, frameStart, frameCount) { - var frameFloatOffset = this._frameFloatArray.length; - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = dragonBones.DataParser.VERTICES in rawData ? rawData[dragonBones.DataParser.VERTICES] : null; - var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint - var vertexCount = this._intArray[this._mesh.vertices.offset + 0 /* MeshVertexCount */]; - var meshName = this._mesh.parent.name + "_" + this._slot.name + "_" + this._mesh.name; - var weight = this._mesh.vertices.weight; - var x = 0.0; - var y = 0.0; - var iB = 0; - var iV = 0; - if (weight !== null) { - var rawSlotPose = this._weightSlotPose[meshName]; - this._helpMatrixA.copyFromArray(rawSlotPose, 0); - this._frameFloatArray.length += weight.count * 2; - iB = weight.offset + 2 /* WeigthBoneIndices */ + weight.bones.length; - } - else { - this._frameFloatArray.length += vertexCount * 2; - } - for (var i = 0; i < vertexCount * 2; i += 2) { - if (rawVertices === null) { - x = 0.0; - y = 0.0; - } - else { - if (i < offset || i - offset >= rawVertices.length) { - x = 0.0; - } - else { - x = rawVertices[i - offset]; - } - if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { - y = 0.0; - } - else { - y = rawVertices[i + 1 - offset]; - } - } - if (weight !== null) { - var rawBonePoses = this._weightBonePoses[meshName]; - var vertexBoneCount = this._intArray[iB++]; - this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); - x = this._helpPoint.x; - y = this._helpPoint.y; - for (var j = 0; j < vertexBoneCount; ++j) { - var boneIndex = this._intArray[iB++]; - this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); - this._helpMatrixB.invert(); - this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); - this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; - this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; - } - } - else { - this._frameFloatArray[frameFloatOffset + i] = x; - this._frameFloatArray[frameFloatOffset + i + 1] = y; - } - } - if (frameStart === 0) { - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._mesh.vertices.offset; - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; - this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseIKConstraintFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 2; - this._frameIntArray[frameIntOffset++] = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true) ? 1 : 0; - this._frameIntArray[frameIntOffset++] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseAnimationFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 2; - this._frameIntArray[frameIntOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); - this._frameIntArray[frameIntOffset++] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseActionData = function (rawData, type, bone, slot) { - var actions = new Array(); - if (typeof rawData === "string") { - var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - action.type = type; - action.name = rawData; - action.bone = bone; - action.slot = slot; - actions.push(action); - } - else if (rawData instanceof Array) { - for (var _i = 0, rawData_2 = rawData; _i < rawData_2.length; _i++) { - var rawAction = rawData_2[_i]; - var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - if (dragonBones.DataParser.GOTO_AND_PLAY in rawAction) { - action.type = 0 /* Play */; - action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.GOTO_AND_PLAY, ""); - } - else { - if (dragonBones.DataParser.TYPE in rawAction && typeof rawAction[dragonBones.DataParser.TYPE] === "string") { - action.type = dragonBones.DataParser._getActionType(rawAction[dragonBones.DataParser.TYPE]); - } - else { - action.type = ObjectDataParser._getNumber(rawAction, dragonBones.DataParser.TYPE, type); - } - action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.NAME, ""); - } - if (dragonBones.DataParser.BONE in rawAction) { - var boneName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.BONE, ""); - action.bone = this._armature.getBone(boneName); - } - else { - action.bone = bone; - } - if (dragonBones.DataParser.SLOT in rawAction) { - var slotName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.SLOT, ""); - action.slot = this._armature.getSlot(slotName); - } - else { - action.slot = slot; - } - var userData = null; - if (dragonBones.DataParser.INTS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawInts = rawAction[dragonBones.DataParser.INTS]; - for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { - var rawValue = rawInts_1[_a]; - userData.addInt(rawValue); - } - } - if (dragonBones.DataParser.FLOATS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawFloats = rawAction[dragonBones.DataParser.FLOATS]; - for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { - var rawValue = rawFloats_1[_b]; - userData.addFloat(rawValue); - } - } - if (dragonBones.DataParser.STRINGS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawStrings = rawAction[dragonBones.DataParser.STRINGS]; - for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { - var rawValue = rawStrings_1[_c]; - userData.addString(rawValue); - } - } - action.data = userData; - actions.push(action); - } - } - return actions; - }; - ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { - transform.x = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0) * scale; - transform.y = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0) * scale; - if (dragonBones.DataParser.ROTATE in rawData || dragonBones.DataParser.SKEW in rawData) { - transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); - transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); - } - else if (dragonBones.DataParser.SKEW_X in rawData || dragonBones.DataParser.SKEW_Y in rawData) { - transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); - transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; - } - transform.scaleX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_X, 1.0); - transform.scaleY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_Y, 1.0); - }; - ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { - color.alphaMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_MULTIPLIER, 100) * 0.01; - color.redMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_MULTIPLIER, 100) * 0.01; - color.greenMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_MULTIPLIER, 100) * 0.01; - color.blueMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_MULTIPLIER, 100) * 0.01; - color.alphaOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_OFFSET, 0); - color.redOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_OFFSET, 0); - color.greenOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_OFFSET, 0); - color.blueOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_OFFSET, 0); - }; - ObjectDataParser.prototype._parseArray = function (rawData) { - // tslint:disable-next-line:no-unused-expression - rawData; - this._intArray.length = 0; - this._floatArray.length = 0; - this._frameIntArray.length = 0; - this._frameFloatArray.length = 0; - this._frameArray.length = 0; - this._timelineArray.length = 0; - }; - ObjectDataParser.prototype._modifyArray = function () { - // Align. - if ((this._intArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._intArray.push(0); - } - if ((this._frameIntArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._frameIntArray.push(0); - } - if ((this._frameArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._frameArray.push(0); - } - if ((this._timelineArray.length % Uint16Array.BYTES_PER_ELEMENT) !== 0) { - this._timelineArray.push(0); - } - var l1 = this._intArray.length * Int16Array.BYTES_PER_ELEMENT; - var l2 = this._floatArray.length * Float32Array.BYTES_PER_ELEMENT; - var l3 = this._frameIntArray.length * Int16Array.BYTES_PER_ELEMENT; - var l4 = this._frameFloatArray.length * Float32Array.BYTES_PER_ELEMENT; - var l5 = this._frameArray.length * Int16Array.BYTES_PER_ELEMENT; - var l6 = this._timelineArray.length * Uint16Array.BYTES_PER_ELEMENT; - var lTotal = l1 + l2 + l3 + l4 + l5 + l6; - if (dragonBones.DragonBones.webAssembly) { - var shareBuffer = dragonBones.webAssemblyModule.HEAP16.buffer; - var bufferPointer = dragonBones.webAssemblyModule._malloc(lTotal); - var intArray = new Int16Array(shareBuffer, bufferPointer, this._intArray.length); - var floatArray = new Float32Array(shareBuffer, bufferPointer + l1, this._floatArray.length); - var frameIntArray = new Int16Array(shareBuffer, bufferPointer + l1 + l2, this._frameIntArray.length); - var frameFloatArray = new Float32Array(shareBuffer, bufferPointer + l1 + l2 + l3, this._frameFloatArray.length); - var frameArray = new Int16Array(shareBuffer, bufferPointer + l1 + l2 + l3 + l4, this._frameArray.length); - var timelineArray = new Uint16Array(shareBuffer, bufferPointer + l1 + l2 + l3 + l4 + l5, this._timelineArray.length); - for (var i = 0, l = this._intArray.length; i < l; ++i) { - intArray[i] = this._intArray[i]; - } - for (var i = 0, l = this._floatArray.length; i < l; ++i) { - floatArray[i] = this._floatArray[i]; - } - for (var i = 0, l = this._frameIntArray.length; i < l; ++i) { - frameIntArray[i] = this._frameIntArray[i]; - } - for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) { - frameFloatArray[i] = this._frameFloatArray[i]; - } - for (var i = 0, l = this._frameArray.length; i < l; ++i) { - frameArray[i] = this._frameArray[i]; - } - for (var i = 0, l = this._timelineArray.length; i < l; ++i) { - timelineArray[i] = this._timelineArray[i]; - } - dragonBones.webAssemblyModule.setDataBinary(this._data, bufferPointer, l1, l2, l3, l4, l5, l6); - } - else { - var binary = new ArrayBuffer(lTotal); - var intArray = new Int16Array(binary, 0, this._intArray.length); - var floatArray = new Float32Array(binary, l1, this._floatArray.length); - var frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length); - var frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length); - var frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length); - var timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length); - for (var i = 0, l = this._intArray.length; i < l; ++i) { - intArray[i] = this._intArray[i]; - } - for (var i = 0, l = this._floatArray.length; i < l; ++i) { - floatArray[i] = this._floatArray[i]; - } - for (var i = 0, l = this._frameIntArray.length; i < l; ++i) { - frameIntArray[i] = this._frameIntArray[i]; - } - for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) { - frameFloatArray[i] = this._frameFloatArray[i]; - } - for (var i = 0, l = this._frameArray.length; i < l; ++i) { - frameArray[i] = this._frameArray[i]; - } - for (var i = 0, l = this._timelineArray.length; i < l; ++i) { - timelineArray[i] = this._timelineArray[i]; - } - this._data.binary = binary; - this._data.intArray = intArray; - this._data.floatArray = floatArray; - this._data.frameIntArray = frameIntArray; - this._data.frameFloatArray = frameFloatArray; - this._data.frameArray = frameArray; - this._data.timelineArray = timelineArray; - } - this._defaultColorOffset = -1; - }; - ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.assert(rawData !== null && rawData !== undefined, "Data error."); - var version = ObjectDataParser._getString(rawData, dragonBones.DataParser.VERSION, ""); - var compatibleVersion = ObjectDataParser._getString(rawData, dragonBones.DataParser.COMPATIBLE_VERSION, ""); - if (dragonBones.DataParser.DATA_VERSIONS.indexOf(version) >= 0 || - dragonBones.DataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { - var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); - data.version = version; - data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); - if (data.frameRate === 0) { - data.frameRate = 24; - } - if (dragonBones.DataParser.ARMATURE in rawData) { - this._data = data; - this._parseArray(rawData); - var rawArmatures = rawData[dragonBones.DataParser.ARMATURE]; - for (var _i = 0, rawArmatures_1 = rawArmatures; _i < rawArmatures_1.length; _i++) { - var rawArmature = rawArmatures_1[_i]; - data.addArmature(this._parseArmature(rawArmature, scale)); - } - if (!this._data.binary) { - this._modifyArray(); - } - if (dragonBones.DataParser.STAGE in rawData) { - data.stage = data.getArmature(ObjectDataParser._getString(rawData, dragonBones.DataParser.STAGE, "")); - } - else if (data.armatureNames.length > 0) { - data.stage = data.getArmature(data.armatureNames[0]); - } - this._data = null; - } - if (dragonBones.DataParser.TEXTURE_ATLAS in rawData) { - this._rawTextureAtlases = rawData[dragonBones.DataParser.TEXTURE_ATLAS]; - } - return data; - } - else { - console.assert(false, "Nonsupport data version: " + version + "\n" + - "Please convert DragonBones data to support version.\n" + - "Read more: https://github.com/DragonBones/Tools/"); - } - return null; - }; - ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { - if (scale === void 0) { scale = 1.0; } - console.assert(rawData !== undefined); - if (rawData === null) { - if (this._rawTextureAtlases === null || this._rawTextureAtlases.length === 0) { - return false; - } - var rawTextureAtlas = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; - this.parseTextureAtlasData(rawTextureAtlas, textureAtlasData, scale); - if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { - this._rawTextureAtlasIndex = 0; - this._rawTextureAtlases = null; - } - return true; - } - // Texture format. - textureAtlasData.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); - textureAtlasData.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); - textureAtlasData.scale = scale === 1.0 ? (1.0 / ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0)) : scale; - textureAtlasData.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - textureAtlasData.imagePath = ObjectDataParser._getString(rawData, dragonBones.DataParser.IMAGE_PATH, ""); - if (dragonBones.DataParser.SUB_TEXTURE in rawData) { - var rawTextures = rawData[dragonBones.DataParser.SUB_TEXTURE]; - for (var i = 0, l = rawTextures.length; i < l; ++i) { - var rawTexture = rawTextures[i]; - var textureData = textureAtlasData.createTexture(); - textureData.rotated = ObjectDataParser._getBoolean(rawTexture, dragonBones.DataParser.ROTATED, false); - textureData.name = ObjectDataParser._getString(rawTexture, dragonBones.DataParser.NAME, ""); - textureData.region.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.X, 0.0); - textureData.region.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.Y, 0.0); - textureData.region.width = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.WIDTH, 0.0); - textureData.region.height = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.HEIGHT, 0.0); - var frameWidth = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_WIDTH, -1.0); - var frameHeight = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_HEIGHT, -1.0); - if (frameWidth > 0.0 && frameHeight > 0.0) { - textureData.frame = dragonBones.TextureData.createRectangle(); - textureData.frame.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_X, 0.0); - textureData.frame.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_Y, 0.0); - textureData.frame.width = frameWidth; - textureData.frame.height = frameHeight; - } - textureAtlasData.addTexture(textureData); - } - } - return true; - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - ObjectDataParser.getInstance = function () { - if (ObjectDataParser._objectDataParserInstance === null) { - ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); - } - return ObjectDataParser._objectDataParserInstance; - }; - ObjectDataParser._objectDataParserInstance = null; - return ObjectDataParser; - }(dragonBones.DataParser)); - dragonBones.ObjectDataParser = ObjectDataParser; - /** - * @internal - */ - var ActionFrame = /** @class */ (function () { - function ActionFrame() { - this.frameStart = 0; - this.actions = []; - } - return ActionFrame; - }()); - dragonBones.ActionFrame = ActionFrame; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - var BinaryDataParser = /** @class */ (function (_super) { - __extends(BinaryDataParser, _super); - function BinaryDataParser() { - return _super !== null && _super.apply(this, arguments) || this; - } - BinaryDataParser.prototype._inRange = function (a, min, max) { - return min <= a && a <= max; - }; - BinaryDataParser.prototype._decodeUTF8 = function (data) { - var EOF_byte = -1; - var EOF_code_point = -1; - var FATAL_POINT = 0xFFFD; - var pos = 0; - var result = ""; - var code_point; - var utf8_code_point = 0; - var utf8_bytes_needed = 0; - var utf8_bytes_seen = 0; - var utf8_lower_boundary = 0; - while (data.length > pos) { - var _byte = data[pos++]; - if (_byte === EOF_byte) { - if (utf8_bytes_needed !== 0) { - code_point = FATAL_POINT; - } - else { - code_point = EOF_code_point; - } - } - else { - if (utf8_bytes_needed === 0) { - if (this._inRange(_byte, 0x00, 0x7F)) { - code_point = _byte; - } - else { - if (this._inRange(_byte, 0xC2, 0xDF)) { - utf8_bytes_needed = 1; - utf8_lower_boundary = 0x80; - utf8_code_point = _byte - 0xC0; - } - else if (this._inRange(_byte, 0xE0, 0xEF)) { - utf8_bytes_needed = 2; - utf8_lower_boundary = 0x800; - utf8_code_point = _byte - 0xE0; - } - else if (this._inRange(_byte, 0xF0, 0xF4)) { - utf8_bytes_needed = 3; - utf8_lower_boundary = 0x10000; - utf8_code_point = _byte - 0xF0; - } - else { - } - utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); - code_point = null; - } - } - else if (!this._inRange(_byte, 0x80, 0xBF)) { - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - pos--; - code_point = _byte; - } - else { - utf8_bytes_seen += 1; - utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); - if (utf8_bytes_seen !== utf8_bytes_needed) { - code_point = null; - } - else { - var cp = utf8_code_point; - var lower_boundary = utf8_lower_boundary; - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - if (this._inRange(cp, lower_boundary, 0x10FFFF) && !this._inRange(cp, 0xD800, 0xDFFF)) { - code_point = cp; - } - else { - code_point = _byte; - } - } - } - } - //Decode string - if (code_point !== null && code_point !== EOF_code_point) { - if (code_point <= 0xFFFF) { - if (code_point > 0) - result += String.fromCharCode(code_point); - } - else { - code_point -= 0x10000; - result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); - result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); - } - } - } - return result; - }; - BinaryDataParser.prototype._getUTF16Key = function (value) { - for (var i = 0, l = value.length; i < l; ++i) { - if (value.charCodeAt(i) > 255) { - return encodeURI(value); - } - } - return value; - }; - BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { - if (timelineData === void 0) { timelineData = null; } - var timeline = timelineData !== null ? timelineData : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); - timeline.type = type; - timeline.offset = offset; - this._timeline = timeline; - var keyFrameCount = this._timelineArrayBuffer[timeline.offset + 2 /* TimelineKeyFrameCount */]; - if (keyFrameCount === 1) { - timeline.frameIndicesOffset = -1; - } - else { - var frameIndicesOffset = 0; - var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. - var frameIndices = this._data.frameIndices; - if (dragonBones.DragonBones.webAssembly) { - frameIndicesOffset = frameIndices.size(); - frameIndices.resize(frameIndicesOffset + totalFrameCount, 0); - } - else { - frameIndicesOffset = frameIndices.length; - frameIndices.length += totalFrameCount; - } - timeline.frameIndicesOffset = frameIndicesOffset; - for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { - if (frameStart + frameCount <= i && iK < keyFrameCount) { - frameStart = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; - if (iK === keyFrameCount - 1) { - frameCount = this._animation.frameCount - frameStart; - } - else { - frameCount = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; - } - iK++; - } - if (dragonBones.DragonBones.webAssembly) { - frameIndices.set(frameIndicesOffset + i, iK - 1); - } - else { - frameIndices[frameIndicesOffset + i] = iK - 1; - } - } - } - this._timeline = null; // - return timeline; - }; - BinaryDataParser.prototype._parseVertices = function (rawData, vertices) { - vertices.offset = rawData[dragonBones.DataParser.OFFSET]; - var weightOffset = this._intArrayBuffer[vertices.offset + 3 /* MeshWeightOffset */]; - if (weightOffset >= 0) { - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - var vertexCount = this._intArrayBuffer[vertices.offset + 0 /* MeshVertexCount */]; - var boneCount = this._intArrayBuffer[weightOffset + 0 /* WeigthBoneCount */]; - weight.offset = weightOffset; - for (var i = 0; i < boneCount; ++i) { - var boneIndex = this._intArrayBuffer[weightOffset + 2 /* WeigthBoneIndices */ + i]; - weight.addBone(this._rawBones[boneIndex]); - } - var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; - var weightCount = 0; - for (var i = 0, l = vertexCount; i < l; ++i) { - var vertexBoneCount = this._intArrayBuffer[boneIndicesOffset++]; - weightCount += vertexBoneCount; - boneIndicesOffset += vertexBoneCount; - } - weight.count = weightCount; - vertices.weight = weight; - } - }; - BinaryDataParser.prototype._parseMesh = function (rawData, mesh) { - this._parseVertices(rawData, mesh.vertices); - }; - BinaryDataParser.prototype._parsePath = function (rawData, path) { - this._parseVertices(rawData, path.vertices); - }; - BinaryDataParser.prototype._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.frameCount = Math.max(dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 1), 1); - animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); - animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); - animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); - animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (animation.name.length === 0) { - animation.name = dragonBones.DataParser.DEFAULT_NAME; - } - // Offsets. - var offsets = rawData[dragonBones.DataParser.OFFSET]; - animation.frameIntOffset = offsets[0]; - animation.frameFloatOffset = offsets[1]; - animation.frameOffset = offsets[2]; - this._animation = animation; - if (dragonBones.DataParser.ACTION in rawData) { - animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.DataParser.ACTION]); - } - if (dragonBones.DataParser.Z_ORDER in rawData) { - animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.DataParser.Z_ORDER]); - } - if (dragonBones.DataParser.BONE in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.BONE]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - if (dragonBones.DragonBones.webAssembly) { - k = this._getUTF16Key(k); - } - var bone = this._armature.getBone(k); - if (bone === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addBoneTimeline(bone, timeline); - } - } - } - if (dragonBones.DataParser.SURFACE in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.SURFACE]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - if (dragonBones.DragonBones.webAssembly) { - k = this._getUTF16Key(k); - } - var surface = this._armature.getBone(k); - if (surface === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addSurfaceTimeline(surface, timeline); - } - } - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.SLOT]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - if (dragonBones.DragonBones.webAssembly) { - k = this._getUTF16Key(k); - } - var slot = this._armature.getSlot(k); - if (slot === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addSlotTimeline(slot, timeline); - } - } - } - if (dragonBones.DataParser.CONSTRAINT in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.CONSTRAINT]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - if (dragonBones.DragonBones.webAssembly) { - k = this._getUTF16Key(k); - } - var constraint = this._armature.getConstraint(k); - if (constraint === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addConstraintTimeline(constraint, timeline); - } - } - } - if (dragonBones.DataParser.ANIMATION in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.ANIMATION]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - if (dragonBones.DragonBones.webAssembly) { - k = this._getUTF16Key(k); - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addAnimationTimeline(k, timeline); - } - } - } - this._animation = null; - return animation; - }; - BinaryDataParser.prototype._parseArray = function (rawData) { - var offsets = rawData[dragonBones.DataParser.OFFSET]; - var l1 = offsets[1]; - var l2 = offsets[3]; - var l3 = offsets[5]; - var l4 = offsets[7]; - var l5 = offsets[9]; - var l6 = offsets[11]; - var intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT); - var floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], l2 / Float32Array.BYTES_PER_ELEMENT); - var frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], l3 / Int16Array.BYTES_PER_ELEMENT); - var frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT); - var frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT); - var timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], l6 / Uint16Array.BYTES_PER_ELEMENT); - if (dragonBones.DragonBones.webAssembly) { - var lTotal = l1 + l2 + l3 + l4 + l5 + l6; - var bufferPointer = dragonBones.webAssemblyModule._malloc(lTotal); - var rawArray = new Uint8Array(this._binary, this._binaryOffset, lTotal / Uint8Array.BYTES_PER_ELEMENT); - var copyArray = new Uint8Array(dragonBones.webAssemblyModule.HEAP16.buffer, bufferPointer, rawArray.length); - for (var i = 0, l = rawArray.length; i < l; ++i) { - copyArray[i] = rawArray[i]; - } - dragonBones.webAssemblyModule.setDataBinary(this._data, bufferPointer, l1, l2, l3, l4, l5, l6); - this._intArrayBuffer = intArray; - this._floatArrayBuffer = floatArray; - this._frameIntArrayBuffer = frameIntArray; - this._frameFloatArrayBuffer = frameFloatArray; - this._frameArrayBuffer = frameArray; - this._timelineArrayBuffer = timelineArray; - } - else { - this._data.binary = this._binary; - this._data.intArray = this._intArrayBuffer = intArray; - this._data.floatArray = this._floatArrayBuffer = floatArray; - this._data.frameIntArray = this._frameIntArrayBuffer = frameIntArray; - this._data.frameFloatArray = this._frameFloatArrayBuffer = frameFloatArray; - this._data.frameArray = this._frameArrayBuffer = frameArray; - this._data.timelineArray = this._timelineArrayBuffer = timelineArray; - } - }; - BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer, "Data error."); - var tag = new Uint8Array(rawData, 0, 8); - if (tag[0] !== "D".charCodeAt(0) || - tag[1] !== "B".charCodeAt(0) || - tag[2] !== "D".charCodeAt(0) || - tag[3] !== "T".charCodeAt(0)) { - console.assert(false, "Nonsupport data."); - return null; - } - var headerLength = new Uint32Array(rawData, 8, 1)[0]; - var headerBytes = new Uint8Array(rawData, 8 + 4, headerLength); - var headerString = this._decodeUTF8(headerBytes); - var header = JSON.parse(headerString); - // - this._binaryOffset = 8 + 4 + headerLength; - this._binary = rawData; - return _super.prototype.parseDragonBonesData.call(this, header, scale); - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - BinaryDataParser.getInstance = function () { - if (BinaryDataParser._binaryDataParserInstance === null) { - BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); - } - return BinaryDataParser._binaryDataParserInstance; - }; - BinaryDataParser._binaryDataParserInstance = null; - return BinaryDataParser; - }(dragonBones.ObjectDataParser)); - dragonBones.BinaryDataParser = BinaryDataParser; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) - * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. - * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) - * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 - * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - var BaseFactory = /** @class */ (function () { - /** - * - Create a factory instance. (typically only one global factory instance is required) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) - * @version DragonBones 3.0 - * @language zh_CN - */ - function BaseFactory(dataParser) { - if (dataParser === void 0) { dataParser = null; } - /** - * @private - */ - this.autoSearch = false; - this._dragonBonesDataMap = {}; - this._textureAtlasDataMap = {}; - this._dragonBones = null; - this._dataParser = null; - if (BaseFactory._objectParser === null) { - BaseFactory._objectParser = new dragonBones.ObjectDataParser(); - } - if (BaseFactory._binaryParser === null) { - BaseFactory._binaryParser = new dragonBones.BinaryDataParser(); - } - this._dataParser = dataParser !== null ? dataParser : BaseFactory._objectParser; - } - BaseFactory.prototype._isSupportMesh = function () { - return true; - }; - BaseFactory.prototype._getTextureData = function (textureAtlasName, textureName) { - if (textureAtlasName in this._textureAtlasDataMap) { - for (var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; _i < _a.length; _i++) { - var textureAtlasData = _a[_i]; - var textureData = textureAtlasData.getTexture(textureName); - if (textureData !== null) { - return textureData; - } - } - } - if (this.autoSearch) { - for (var k in this._textureAtlasDataMap) { - for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { - var textureAtlasData = _c[_b]; - if (textureAtlasData.autoSearch) { - var textureData = textureAtlasData.getTexture(textureName); - if (textureData !== null) { - return textureData; - } - } - } - } - } - return null; - }; - BaseFactory.prototype._fillBuildArmaturePackage = function (dataPackage, dragonBonesName, armatureName, skinName, textureAtlasName) { - var dragonBonesData = null; - var armatureData = null; - if (dragonBonesName.length > 0) { - if (dragonBonesName in this._dragonBonesDataMap) { - dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; - armatureData = dragonBonesData.getArmature(armatureName); - } - } - if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { - for (var k in this._dragonBonesDataMap) { - dragonBonesData = this._dragonBonesDataMap[k]; - if (dragonBonesName.length === 0 || dragonBonesData.autoSearch) { - armatureData = dragonBonesData.getArmature(armatureName); - if (armatureData !== null) { - dragonBonesName = k; - break; - } - } - } - } - if (armatureData !== null) { - dataPackage.dataName = dragonBonesName; - dataPackage.textureAtlasName = textureAtlasName; - dataPackage.data = dragonBonesData; - dataPackage.armature = armatureData; - dataPackage.skin = null; - if (skinName.length > 0) { - dataPackage.skin = armatureData.getSkin(skinName); - if (dataPackage.skin === null && this.autoSearch) { - for (var k in this._dragonBonesDataMap) { - var skinDragonBonesData = this._dragonBonesDataMap[k]; - var skinArmatureData = skinDragonBonesData.getArmature(skinName); - if (skinArmatureData !== null) { - dataPackage.skin = skinArmatureData.defaultSkin; - break; - } - } - } - } - if (dataPackage.skin === null) { - dataPackage.skin = armatureData.defaultSkin; - } - return true; - } - return false; - }; - BaseFactory.prototype._buildBones = function (dataPackage, armature) { - for (var _i = 0, _a = dataPackage.armature.sortedBones; _i < _a.length; _i++) { - var boneData = _a[_i]; - var bone = dragonBones.BaseObject.borrowObject(boneData.type === 0 /* Bone */ ? dragonBones.Bone : dragonBones.Surface); - bone.init(boneData, armature); - } - }; - /** - * @private - */ - BaseFactory.prototype._buildSlots = function (dataPackage, armature) { - var currentSkin = dataPackage.skin; - var defaultSkin = dataPackage.armature.defaultSkin; - if (currentSkin === null || defaultSkin === null) { - return; - } - var skinSlots = {}; - for (var k in defaultSkin.displays) { - var displays = defaultSkin.getDisplays(k); - skinSlots[k] = displays; - } - if (currentSkin !== defaultSkin) { - for (var k in currentSkin.displays) { - var displays = currentSkin.getDisplays(k); - skinSlots[k] = displays; - } - } - for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { - var slotData = _a[_i]; - var displayDatas = slotData.name in skinSlots ? skinSlots[slotData.name] : null; - var slot = this._buildSlot(dataPackage, slotData, armature); - slot.rawDisplayDatas = displayDatas; - if (displayDatas !== null) { - var displayList = new Array(); - // for (const displayData of displays) - for (var i = 0, l = dragonBones.DragonBones.webAssembly ? displayDatas.size() : displayDatas.length; i < l; ++i) { - var displayData = dragonBones.DragonBones.webAssembly ? displayDatas.get(i) : displayDatas[i]; - if (displayData !== null) { - displayList.push(this._getSlotDisplay(dataPackage, displayData, null, slot)); - } - else { - displayList.push(null); - } - } - slot._setDisplayList(displayList); - } - slot._setDisplayIndex(slotData.displayIndex, true); - } - }; - BaseFactory.prototype._buildConstraints = function (dataPackage, armature) { - var constraints = dataPackage.armature.constraints; - for (var k in constraints) { - var constraintData = constraints[k]; - // TODO more constraint type. - switch (constraintData.type) { - case 0 /* IK */: - var ikConstraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); - ikConstraint.init(constraintData, armature); - armature._addConstraint(ikConstraint); - break; - case 1 /* Path */: - var pathConstraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraint); - pathConstraint.init(constraintData, armature); - armature._addConstraint(pathConstraint); - break; - default: - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); - constraint.init(constraintData, armature); - armature._addConstraint(constraint); - break; - } - } - }; - BaseFactory.prototype._buildChildArmature = function (dataPackage, slot, displayData) { - // tslint:disable-next-line:no-unused-expression - slot; - return this.buildArmature(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage !== null ? dataPackage.textureAtlasName : ""); - }; - BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, rawDisplayData, slot) { - var dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.parent.name; - var display = null; - switch (displayData.type) { - case 0 /* Image */: { - var imageDisplayData = displayData; - if (imageDisplayData.texture === null) { - imageDisplayData.texture = this._getTextureData(dataName, displayData.path); - } - else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { - imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); - } - if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */ && this._isSupportMesh()) { - display = slot.meshDisplay; - } - else { - display = slot.rawDisplay; - } - break; - } - case 2 /* Mesh */: { - var meshDisplayData = displayData; - if (meshDisplayData.texture === null) { - meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); - } - else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { - meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); - } - if (this._isSupportMesh()) { - display = slot.meshDisplay; - } - else { - display = slot.rawDisplay; - } - break; - } - case 1 /* Armature */: { - var armatureDisplayData = displayData; - var childArmature = this._buildChildArmature(dataPackage, slot, displayData); - if (childArmature !== null) { - childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; - if (!childArmature.inheritAnimation) { - var actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; - if (actions.length > 0) { - for (var _i = 0, actions_6 = actions; _i < actions_6.length; _i++) { - var action = actions_6[_i]; - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - dragonBones.EventObject.actionDataToInstance(action, eventObject, slot.armature); - eventObject.slot = slot; - slot.armature._bufferAction(eventObject, false); - } - } - else { - childArmature.animation.play(); - } - } - armatureDisplayData.armature = childArmature.armatureData; // - } - display = childArmature; - break; - } - case 3 /* BoundingBox */: - break; - default: - break; - } - return display; - }; - /** - * - Parse the raw data to a DragonBonesData instance and cache it to the factory. - * @param rawData - The raw data. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for all armatures. (Default: 1.0) - * @returns DragonBonesData instance - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 - * @param rawData - 原始数据。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) - * @returns DragonBonesData 实例 - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.parseDragonBonesData = function (rawData, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 1.0; } - var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; - var dragonBonesData = dataParser.parseDragonBonesData(rawData, scale); - while (true) { - var textureAtlasData = this._buildTextureAtlasData(null, null); - if (dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { - this.addTextureAtlasData(textureAtlasData, name); - } - else { - textureAtlasData.returnToPool(); - break; - } - } - if (dragonBonesData !== null) { - this.addDragonBonesData(dragonBonesData, name); - } - return dragonBonesData; - }; - /** - * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. - * @param rawData - The raw texture atlas data. - * @param textureAtlas - The texture atlas object. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for the map set. (Default: 1.0) - * @returns TextureAtlasData instance - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 - * @param rawData - 原始贴图集数据。 - * @param textureAtlas - 贴图集对象。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) - * @returns TextureAtlasData 实例 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 1.0; } - var textureAtlasData = this._buildTextureAtlasData(null, null); - this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); - this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); - this.addTextureAtlasData(textureAtlasData, name); - return textureAtlasData; - }; - /** - * @private - */ - BaseFactory.prototype.updateTextureAtlasData = function (name, textureAtlases) { - var textureAtlasDatas = this.getTextureAtlasData(name); - if (textureAtlasDatas !== null) { - for (var i = 0, l = textureAtlasDatas.length; i < l; ++i) { - if (i < textureAtlases.length) { - this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); - } - } - } - }; - /** - * - Get a specific DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @returns DragonBonesData instance - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 DragonBonesData 实例。 - * @param name - DragonBonesData 实例的缓存名称。 - * @returns DragonBonesData 实例 - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.getDragonBonesData = function (name) { - return (name in this._dragonBonesDataMap) ? this._dragonBonesDataMap[name] : null; - }; - /** - * - Cache a DragonBonesData instance to the factory. - * @param data - The DragonBonesData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 DragonBonesData 实例缓存到工厂中。 - * @param data - DragonBonesData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.addDragonBonesData = function (data, name) { - if (name === void 0) { name = null; } - name = name !== null ? name : data.name; - if (name in this._dragonBonesDataMap) { - if (this._dragonBonesDataMap[name] === data) { - return; - } - console.warn("Can not add same name data: " + name); - return; - } - this._dragonBonesDataMap[name] = data; - }; - /** - * - Remove a DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @param disposeData - Whether to dispose data. (Default: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 DragonBonesData 实例。 - * @param name - DragonBonesData 实例缓存名称。 - * @param disposeData - 是否释放数据。 (默认: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.removeDragonBonesData = function (name, disposeData) { - if (disposeData === void 0) { disposeData = true; } - if (name in this._dragonBonesDataMap) { - if (disposeData) { - this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); - } - delete this._dragonBonesDataMap[name]; - } - }; - /** - * - Get a list of specific TextureAtlasData instances. - * @param name - The TextureAtlasData cahce name. - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 TextureAtlasData 实例列表。 - * @param name - TextureAtlasData 实例缓存名称。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.getTextureAtlasData = function (name) { - return (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : null; - }; - /** - * - Cache a TextureAtlasData instance to the factory. - * @param data - The TextureAtlasData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 TextureAtlasData 实例缓存到工厂中。 - * @param data - TextureAtlasData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.addTextureAtlasData = function (data, name) { - if (name === void 0) { name = null; } - name = name !== null ? name : data.name; - var textureAtlasList = (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : (this._textureAtlasDataMap[name] = []); - if (textureAtlasList.indexOf(data) < 0) { - textureAtlasList.push(data); - } - }; - /** - * - Remove a TextureAtlasData instance. - * @param name - The TextureAtlasData instance cache name. - * @param disposeData - Whether to dispose data. - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 TextureAtlasData 实例。 - * @param name - TextureAtlasData 实例的缓存名称。 - * @param disposeData - 是否释放数据。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.removeTextureAtlasData = function (name, disposeData) { - if (disposeData === void 0) { disposeData = true; } - if (name in this._textureAtlasDataMap) { - var textureAtlasDataList = this._textureAtlasDataMap[name]; - if (disposeData) { - for (var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; _i < textureAtlasDataList_1.length; _i++) { - var textureAtlasData = textureAtlasDataList_1[_i]; - this._dragonBones.bufferObject(textureAtlasData); - } - } - delete this._textureAtlasDataMap[name]; - } - }; - /** - * - Get a specific armature data. - * @param name - The armature data name. - * @param dragonBonesName - The cached name for DragonbonesData instance. - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param name - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language zh_CN - */ - BaseFactory.prototype.getArmatureData = function (name, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - var dataPackage = new BuildArmaturePackage(); - if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) { - return null; - } - return dataPackage.armature; - }; - /** - * - Clear all cached DragonBonesData instances and TextureAtlasData instances. - * @param disposeData - Whether to dispose data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 - * @param disposeData - 是否释放数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.clear = function (disposeData) { - if (disposeData === void 0) { disposeData = true; } - for (var k in this._dragonBonesDataMap) { - if (disposeData) { - this._dragonBones.bufferObject(this._dragonBonesDataMap[k]); - } - delete this._dragonBonesDataMap[k]; - } - for (var k in this._textureAtlasDataMap) { - if (disposeData) { - var textureAtlasDataList = this._textureAtlasDataMap[k]; - for (var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; _i < textureAtlasDataList_2.length; _i++) { - var textureAtlasData = textureAtlasDataList_2[_i]; - this._dragonBones.bufferObject(textureAtlasData); - } - } - delete this._textureAtlasDataMap[k]; - } - }; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. - * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature. - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 - * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架。 - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - if (textureAtlasName === void 0) { textureAtlasName = ""; } - var dataPackage = new BuildArmaturePackage(); - if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, skinName || "", textureAtlasName || "")) { - console.warn("No armature data: " + armatureName + ", " + (dragonBonesName !== null ? dragonBonesName : "")); - return null; - } - var armature = this._buildArmature(dataPackage); - this._buildBones(dataPackage, armature); - this._buildSlots(dataPackage, armature); - this._buildConstraints(dataPackage, armature); - armature.invalidUpdate(null, true); - armature.advanceTime(0.0); // Update armature pose. - return armature; - }; - /** - * @private - */ - BaseFactory.prototype.replaceDisplay = function (slot, displayData, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - if (displayIndex < 0) { - displayIndex = slot.displayIndex; - } - if (displayIndex < 0) { - displayIndex = 0; - } - slot.replaceDisplayData(displayData, displayIndex); - var displayList = slot.displayList; // Copy. - if (displayList.length <= displayIndex) { - displayList.length = displayIndex + 1; - for (var i = 0, l = displayList.length; i < l; ++i) { - if (!displayList[i]) { - displayList[i] = null; - } - } - } - if (displayData !== null) { - var rawDisplayDatas = slot.rawDisplayDatas; - var rawDisplayData = null; - if (rawDisplayDatas) { - if (dragonBones.DragonBones.webAssembly) { - if (displayIndex < rawDisplayDatas.size()) { - rawDisplayData = rawDisplayDatas.get(displayIndex); - } - } - else { - if (displayIndex < rawDisplayDatas.length) { - rawDisplayData = rawDisplayDatas[displayIndex]; - } - } - } - displayList[displayIndex] = this._getSlotDisplay(null, displayData, rawDisplayData, slot); - } - else { - displayList[displayIndex] = null; - } - slot.displayList = displayList; - }; - /** - * - Replaces the current display data for a particular slot with a specific display data. - * Specify display data with "dragonBonesName/armatureName/slotName/displayName". - * @param dragonBonesName - The DragonBonesData instance cache name. - * @param armatureName - The armature data name. - * @param slotName - The slot data name. - * @param displayName - The display data name. - * @param slot - The slot. - * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 - * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @param armatureName - 骨架数据名称。 - * @param slotName - 插槽数据名称。 - * @param displayName - 显示对象数据名称。 - * @param slot - 插槽。 - * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); - if (!armatureData || !armatureData.defaultSkin) { - return false; - } - var displayData = armatureData.defaultSkin.getDisplay(slotName, displayName); - if (!displayData) { - return false; - } - this.replaceDisplay(slot, displayData, displayIndex); - return true; - }; - /** - * @private - */ - BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { - var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); - if (!armatureData || !armatureData.defaultSkin) { - return false; - } - var displays = armatureData.defaultSkin.getDisplays(slotName); - if (!displays) { - return false; - } - var displayIndex = 0; - // for (const displayData of displays) - for (var i = 0, l = dragonBones.DragonBones.webAssembly ? displays.size() : displays.length; i < l; ++i) { - var displayData = dragonBones.DragonBones.webAssembly ? displays.get(i) : displays[i]; - this.replaceDisplay(slot, displayData, displayIndex++); - } - return true; - }; - /** - * - Share specific skin data with specific armature. - * @param armature - The armature. - * @param skin - The skin data. - * @param isOverride - Whether it completely override the original skin. (Default: false) - * @param exclude - A list of slot names that do not need to be replace. - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 将特定的皮肤数据共享给特定的骨架使用。 - * @param armature - 骨架。 - * @param skin - 皮肤数据。 - * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) - * @param exclude - 不需要被替换的插槽名称列表。 - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language zh_CN - */ - BaseFactory.prototype.replaceSkin = function (armature, skin, isOverride, exclude) { - if (isOverride === void 0) { isOverride = false; } - if (exclude === void 0) { exclude = null; } - var success = false; - var defaultSkin = skin.parent.defaultSkin; - for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (exclude !== null && exclude.indexOf(slot.name) >= 0) { - continue; - } - var displays = skin.getDisplays(slot.name); - if (!displays) { - if (defaultSkin !== null && skin !== defaultSkin) { - displays = defaultSkin.getDisplays(slot.name); - } - if (!displays) { - if (isOverride) { - slot.rawDisplayDatas = null; - slot.displayList = []; // - } - continue; - } - } - var displayCount = dragonBones.DragonBones.webAssembly ? displays.size() : displays.length; - var displayList = slot.displayList; // Copy. - displayList.length = displayCount; // Modify displayList length. - for (var i = 0, l = displayCount; i < l; ++i) { - var displayData = dragonBones.DragonBones.webAssembly ? displays.get(i) : displays[i]; - if (displayData !== null) { - displayList[i] = this._getSlotDisplay(null, displayData, null, slot); - } - else { - displayList[i] = null; - } - } - success = true; - slot.rawDisplayDatas = displays; - slot.displayList = displayList; - } - return success; - }; - /** - * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. - * This enables you to make a armature template so that other armature without animations can share it's animations. - * @param armature - The armtaure. - * @param armatureData - The armature data. - * @param isOverride - Whether to completely overwrite the original animation. (Default: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 - * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 - * @param armature - 骨架。 - * @param armatureData - 骨架数据。 - * @param isOverride - 是否完全覆盖原来的动画。(默认: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language zh_CN - */ - BaseFactory.prototype.replaceAnimation = function (armature, armatureData, isOverride) { - if (isOverride === void 0) { isOverride = true; } - var skinData = armatureData.defaultSkin; - if (skinData === null) { - return false; - } - if (isOverride) { - armature.animation.animations = armatureData.animations; - } - else { - var rawAnimations = armature.animation.animations; - var animations = {}; - for (var k in rawAnimations) { - animations[k] = rawAnimations[k]; - } - for (var k in armatureData.animations) { - animations[k] = armatureData.animations[k]; - } - armature.animation.animations = animations; - } - for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - var index = 0; - for (var _b = 0, _c = slot.displayList; _b < _c.length; _b++) { - var display = _c[_b]; - if (display instanceof dragonBones.Armature) { - var displayDatas = skinData.getDisplays(slot.name); - if (displayDatas !== null && index < (dragonBones.DragonBones.webAssembly ? displayDatas.size() : displayDatas.length)) { - var displayData = dragonBones.DragonBones.webAssembly ? displayDatas.get(index) : displayDatas[index]; - if (displayData !== null && displayData.type === 1 /* Armature */) { - var childArmatureData = this.getArmatureData(displayData.path, displayData.parent.parent.parent.name); - if (childArmatureData) { - this.replaceAnimation(display, childArmatureData, isOverride); - } - } - } - } - index++; - } - } - return true; - }; - /** - * @private - */ - BaseFactory.prototype.getAllDragonBonesData = function () { - return this._dragonBonesDataMap; - }; - /** - * @private - */ - BaseFactory.prototype.getAllTextureAtlasData = function () { - return this._textureAtlasDataMap; - }; - Object.defineProperty(BaseFactory.prototype, "clock", { - /** - * - An Worldclock instance updated by engine. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 由引擎驱动的 WorldClock 实例。 - * @version DragonBones 5.7 - * @language zh_CN - */ - get: function () { - return this._dragonBones.clock; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BaseFactory.prototype, "dragonBones", { - /** - * @private - */ - get: function () { - return this._dragonBones; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #replaceSkin}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #replaceSkin}。 - * @deprecated - * @language zh_CN - */ - BaseFactory.prototype.changeSkin = function (armature, skin, exclude) { - if (exclude === void 0) { exclude = null; } - return this.replaceSkin(armature, skin, false, exclude); - }; - /** - * - Deprecated, please refer to {@link #replaceAnimation}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #replaceAnimation}。 - * @deprecated - * @language zh_CN - */ - BaseFactory.prototype.copyAnimationsToArmature = function (toArmature, fromArmatreName, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation) { - if (fromSkinName === void 0) { fromSkinName = ""; } - if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = ""; } - if (replaceOriginalAnimation === void 0) { replaceOriginalAnimation = true; } - // tslint:disable-next-line:no-unused-expression - fromSkinName; - var armatureData = this.getArmatureData(fromArmatreName, fromDragonBonesDataName); - if (!armatureData) { - return false; - } - return this.replaceAnimation(toArmature, armatureData, replaceOriginalAnimation); - }; - BaseFactory._objectParser = null; - BaseFactory._binaryParser = null; - return BaseFactory; - }()); - dragonBones.BaseFactory = BaseFactory; - /** - * @internal - */ - var BuildArmaturePackage = /** @class */ (function () { - function BuildArmaturePackage() { - this.dataName = ""; - this.textureAtlasName = ""; - this.skin = null; - } - return BuildArmaturePackage; - }()); - dragonBones.BuildArmaturePackage = BuildArmaturePackage; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The egret texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var EgretTextureAtlasData = /** @class */ (function (_super) { - __extends(EgretTextureAtlasData, _super); - function EgretTextureAtlasData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._renderTexture = null; // Initial value. - return _this; - } - EgretTextureAtlasData.toString = function () { - return "[class dragonBones.EgretTextureAtlasData]"; - }; - EgretTextureAtlasData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.disposeEnabled && this._renderTexture !== null) { - this._renderTexture.dispose(); - } - this.disposeEnabled = false; - this._renderTexture = null; - }; - /** - * @inheritDoc - */ - EgretTextureAtlasData.prototype.createTexture = function () { - return dragonBones.BaseObject.borrowObject(EgretTextureData); - }; - Object.defineProperty(EgretTextureAtlasData.prototype, "renderTexture", { - /** - * - The Egret texture. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 贴图。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._renderTexture; - }, - set: function (value) { - if (this._renderTexture === value) { - return; - } - this._renderTexture = value; - if (this._renderTexture !== null) { - var bitmapData = this._renderTexture.bitmapData; - var textureAtlasWidth = this.width > 0.0 ? this.width : bitmapData.width; - var textureAtlasHeight = this.height > 0.0 ? this.height : bitmapData.height; - for (var k in this.textures) { - var scale = egret.$TextureScaleFactor; - var textureData = this.textures[k]; - var subTextureWidth = textureData.region.width; - var subTextureHeight = textureData.region.height; - if (textureData.renderTexture === null) { - textureData.renderTexture = new egret.Texture(); - } - textureData.renderTexture.bitmapData = bitmapData; - if (textureData.rotated) { - textureData.renderTexture.$initData(textureData.region.x * scale, textureData.region.y * scale, subTextureHeight * scale, subTextureWidth * scale, 0, 0, subTextureHeight * scale, subTextureWidth * scale, textureAtlasWidth, textureAtlasHeight, textureData.rotated); - } - else { - textureData.renderTexture.$initData(textureData.region.x * scale, textureData.region.y * scale, subTextureWidth * scale, subTextureHeight * scale, 0, 0, subTextureWidth * scale, subTextureHeight * scale, textureAtlasWidth, textureAtlasHeight); - } - } - } - else { - for (var k in this.textures) { - var textureData = this.textures[k]; - textureData.renderTexture = null; - } - } - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#removeTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#removeTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - EgretTextureAtlasData.prototype.dispose = function () { - console.warn("已废弃。"); - this.returnToPool(); - }; - Object.defineProperty(EgretTextureAtlasData.prototype, "texture", { - /** - * - Deprecated, please refer to {@link #renderTexture}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #renderTexture}。 - * @deprecated - * @language zh_CN - */ - get: function () { - console.warn("已废弃。"); - return this.renderTexture; - }, - enumerable: true, - configurable: true - }); - return EgretTextureAtlasData; - }(dragonBones.TextureAtlasData)); - dragonBones.EgretTextureAtlasData = EgretTextureAtlasData; - /** - * @internal - */ - var EgretTextureData = /** @class */ (function (_super) { - __extends(EgretTextureData, _super); - function EgretTextureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.renderTexture = null; // Initial value. - return _this; - } - EgretTextureData.toString = function () { - return "[class dragonBones.EgretTextureData]"; - }; - EgretTextureData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.renderTexture !== null) { - //this.renderTexture.dispose(false); - //this.renderTexture.dispose(); - } - this.renderTexture = null; - }; - return EgretTextureData; - }(dragonBones.TextureData)); - dragonBones.EgretTextureData = EgretTextureData; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The egret event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - Egret 事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - var EgretEvent = /** @class */ (function (_super) { - __extends(EgretEvent, _super); - function EgretEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(EgretEvent.prototype, "eventObject", { - /** - * - The event object. - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象。 - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this.data; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "animationName", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - get: function () { - var animationState = this.eventObject.animationState; - return animationState !== null ? animationState.name : ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "armature", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#armature}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#armature}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.armature; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "bone", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#bone}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#bone}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.bone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "slot", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#slot}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#slot}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.slot; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "animationState", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.animationState; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "frameLabel", { - /** - * Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#name}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#name}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "sound", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#name}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#name}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.eventObject.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretEvent.prototype, "movementID", { - /** - * - Deprecated, please refer to {@link #eventObject} {@link #dragonBones.EventObject#animationState}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #eventObject} {@link #dragonBones.EventObject#animationState}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return this.animationName; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.START}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.START}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.START = dragonBones.EventObject.START; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.LOOP_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.LOOP_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.LOOP_COMPLETE = dragonBones.EventObject.LOOP_COMPLETE; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.COMPLETE}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.COMPLETE = dragonBones.EventObject.COMPLETE; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_IN}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_IN}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.FADE_IN = dragonBones.EventObject.FADE_IN; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_IN_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_IN_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.FADE_IN_COMPLETE = dragonBones.EventObject.FADE_IN_COMPLETE; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_OUT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_OUT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.FADE_OUT = dragonBones.EventObject.FADE_OUT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FADE_OUT_COMPLETE}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FADE_OUT_COMPLETE}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.FADE_OUT_COMPLETE = dragonBones.EventObject.FADE_OUT_COMPLETE; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.SOUND_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.SOUND_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.SOUND_EVENT = dragonBones.EventObject.SOUND_EVENT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.ANIMATION_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.BONE_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.FRAME_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.FRAME_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.MOVEMENT_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; - /** - * - Deprecated, please refer to {@link #dragonBones.EventObject.SOUND_EVENT}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #dragonBones.EventObject.SOUND_EVENT}。 - * @deprecated - * @language zh_CN - */ - EgretEvent.SOUND = dragonBones.EventObject.SOUND_EVENT; - return EgretEvent; - }(egret.Event)); - dragonBones.EgretEvent = EgretEvent; - /** - * @inheritDoc - */ - var EgretArmatureDisplay = /** @class */ (function (_super) { - __extends(EgretArmatureDisplay, _super); - function EgretArmatureDisplay() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.debugDraw = false; - /** - * @internal - */ - _this._batchEnabled = !(global["nativeRender"] || global["bricks"]); // - /** - * @internal - */ - _this._childDirty = true; - _this._debugDraw = false; - _this._armature = null; // - _this._bounds = null; - _this._debugDrawer = null; - return _this; - } - EgretArmatureDisplay._cleanBeforeRender = function () { }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.dbInit = function (armature) { - this._armature = armature; - if (this._batchEnabled) { - this.$renderNode = new egret.sys.GroupNode(); - this.$renderNode.cleanBeforeRender = EgretArmatureDisplay._cleanBeforeRender; - } - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.dbClear = function () { - this._armature = null; - this._bounds = null; - this._debugDrawer = null; - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.dbUpdate = function () { - var drawed = dragonBones.DragonBones.debugDraw || this.debugDraw; - if (drawed || this._debugDraw) { - this._debugDraw = drawed; - if (this._debugDraw) { - if (this._debugDrawer === null) { - this._debugDrawer = new egret.Sprite(); - } - if (this._debugDrawer.parent !== this) { - this.addChild(this._debugDrawer); - } - var boneStep = 2.0; - var graphics = this._debugDrawer.graphics; - graphics.clear(); - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone.boneData.type === 0 /* Bone */) { - var boneLength = Math.max(bone.boneData.length, boneStep); - var startX = bone.globalTransformMatrix.tx; - var startY = bone.globalTransformMatrix.ty; - var aX = startX - bone.globalTransformMatrix.a * boneStep; - var aY = startY - bone.globalTransformMatrix.b * boneStep; - var bX = startX + bone.globalTransformMatrix.a * boneLength; - var bY = startY + bone.globalTransformMatrix.b * boneLength; - var cX = startX + aY - startY; - var cY = startY + aX - startX; - var dX = startX - aY + startY; - var dY = startY - aX + startX; - // - graphics.lineStyle(2.0, 0x00FFFF, 0.7); - graphics.moveTo(aX, aY); - graphics.lineTo(bX, bY); - graphics.moveTo(cX, cY); - graphics.lineTo(dX, dY); - } - else { - var surface = bone; - var surfaceData = surface._boneData; - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var vertices = surface._vertices; - graphics.lineStyle(2.0, 0xFFFF00, 0.7); - for (var iY = 0; iY < segmentY; ++iY) { - for (var iX = 0; iX < segmentX; ++iX) { - var vertexIndex = (iX + iY * (segmentX + 1)) * 2; - var x = vertices[vertexIndex]; - var y = vertices[vertexIndex + 1]; - graphics.moveTo(x, y); - graphics.lineTo(vertices[vertexIndex + 2], vertices[vertexIndex + 3]); - graphics.moveTo(x, y); - graphics.lineTo(vertices[vertexIndex + (segmentX + 1) * 2], vertices[vertexIndex + (segmentX + 1) * 2 + 1]); - if (iX === segmentX - 1) { - graphics.moveTo(vertices[vertexIndex + 2], vertices[vertexIndex + 3]); - graphics.lineTo(vertices[vertexIndex + (segmentX + 2) * 2], vertices[vertexIndex + (segmentX + 2) * 2 + 1]); - } - if (iY === segmentY - 1) { - graphics.moveTo(vertices[vertexIndex + (segmentX + 1) * 2], vertices[vertexIndex + (segmentX + 1) * 2 + 1]); - graphics.lineTo(vertices[vertexIndex + (segmentX + 2) * 2], vertices[vertexIndex + (segmentX + 2) * 2 + 1]); - } - } - } - } - } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - var boundingBoxData = slot.boundingBoxData; - if (boundingBoxData !== null) { - var child = this._debugDrawer.getChildByName(slot.name); - if (child === null) { - child = new egret.Shape(); - child.name = slot.name; - this._debugDrawer.addChild(child); - } - child.graphics.clear(); - child.graphics.lineStyle(2.0, 0xFF00FF, 0.7); - switch (boundingBoxData.type) { - case 0 /* Rectangle */: - child.graphics.drawRect(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height); - break; - case 1 /* Ellipse */: - child.graphics.drawEllipse(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height); - break; - case 2 /* Polygon */: - var vertices = boundingBoxData.vertices; - for (var i = 0; i < vertices.length; i += 2) { - var x = vertices[i]; - var y = vertices[i + 1]; - if (i === 0) { - child.graphics.moveTo(x, y); - } - else { - child.graphics.lineTo(x, y); - } - } - child.graphics.lineTo(vertices[0], vertices[1]); - break; - default: - break; - } - slot.updateTransformAndMatrix(); - slot.updateGlobalTransform(); - child.$setMatrix(slot.globalTransformMatrix, false); - } - else { - var child = this._debugDrawer.getChildByName(slot.name); - if (child !== null) { - this._debugDrawer.removeChild(child); - } - } - } - } - else if (this._debugDrawer !== null && this._debugDrawer.parent === this) { - this.removeChild(this._debugDrawer); - } - } - if (!dragonBones.isV5 && this._batchEnabled && this._childDirty) { - this.$invalidateContentBounds(); - } - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.dispose = function (disposeProxy) { - if (disposeProxy === void 0) { disposeProxy = true; } - // tslint:disable-next-line:no-unused-expression - disposeProxy; - if (this._armature !== null) { - this._armature.dispose(); - this._armature = null; - } - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.dispatchDBEvent = function (type, eventObject) { - var event = egret.Event.create(EgretEvent, type); - event.data = eventObject; - _super.prototype.dispatchEvent.call(this, event); - egret.Event.release(event); - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.hasDBEventListener = function (type) { - return this.hasEventListener(type); - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.addDBEventListener = function (type, listener, target) { - this.addEventListener(type, listener, target); - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.removeDBEventListener = function (type, listener, target) { - this.removeEventListener(type, listener, target); - }; - /** - * - Disable the batch. - * Batch rendering for performance reasons, the boundary properties of the render object are not updated. - * This will not correctly obtain the wide-height properties of the rendered object and the transformation properties of its internal display objects, - * which can turn off batch rendering if you need to use these properties. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 关闭批次渲染。 - * 批次渲染出于性能考虑,不会更新渲染对象的边界属性。 - * 这样将无法正确获得渲染对象的宽高属性以及其内部显示对象的变换属性,如果需要使用这些属性,可以关闭批次渲染。 - * @version DragonBones 5.1 - * @language zh_CN - */ - EgretArmatureDisplay.prototype.disableBatch = function () { - if (!this._batchEnabled || !this._armature) { - return; - } - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - // (slot as EgretSlot).transformUpdateEnabled = true; - var display = ((slot._deformVertices && slot._deformVertices.verticesData) ? slot.meshDisplay : slot.rawDisplay); - if (!slot.display && display === slot.meshDisplay) { - display = slot.rawDisplay; - } - var node = display.$renderNode; - // Transform. - if (node.matrix) { - display.$setMatrix(slot.globalTransformMatrix, false); - } - // ZOrder. - this.addChild(display); - } - this._batchEnabled = false; - this.$renderNode.cleanBeforeRender = null; - this.$renderNode = null; - this.armature.invalidUpdate(null, true); - }; - Object.defineProperty(EgretArmatureDisplay.prototype, "armature", { - /** - * @inheritDoc - */ - get: function () { - return this._armature; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretArmatureDisplay.prototype, "animation", { - /** - * @inheritDoc - */ - get: function () { - return this._armature.animation; - }, - enumerable: true, - configurable: true - }); - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.$measureContentBounds = function (bounds) { - if (this._batchEnabled && this._armature) { - if (this._childDirty) { - this._childDirty = false; - var isFirst = true; - var helpRectangle = new egret.Rectangle(); - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - var display = slot.display; - if (!display || !display.$renderNode || !display.$renderNode.image) { - continue; - } - var matrix = display.$renderNode.matrix; - if (display === slot.meshDisplay) { - var vertices = display.$renderNode.vertices; - if (vertices && vertices.length > 0) { - helpRectangle.setTo(999999.0, 999999.0, -999999.0, -999999.0); - for (var i = 0, l = vertices.length; i < l; i += 2) { - var x = vertices[i]; - var y = vertices[i + 1]; - if (helpRectangle.x > x) - helpRectangle.x = x; - if (helpRectangle.width < x) - helpRectangle.width = x; - if (helpRectangle.y > y) - helpRectangle.y = y; - if (helpRectangle.height < y) - helpRectangle.height = y; - } - helpRectangle.width -= helpRectangle.x; - helpRectangle.height -= helpRectangle.y; - } - else { - continue; - } - } - else { - var displayData = slot.displayData; - if (displayData && displayData instanceof dragonBones.ImageDisplayData && displayData.texture) { - var scale = displayData.texture.parent.scale; - helpRectangle.x = 0; - helpRectangle.y = 0; - helpRectangle.width = displayData.texture.region.width * scale; - helpRectangle.height = displayData.texture.region.height * scale; - } - else { - continue; - } - } - matrix.$transformBounds(helpRectangle); - var left = helpRectangle.x; - var top_1 = helpRectangle.y; - var right = helpRectangle.x + helpRectangle.width; - var bottom = helpRectangle.y + helpRectangle.height; - if (isFirst) { - isFirst = false; - bounds.x = left; - bounds.y = top_1; - bounds.width = right; - bounds.height = bottom; - } - else { - if (left < bounds.x) { - bounds.x = left; - } - if (top_1 < bounds.y) { - bounds.y = top_1; - } - if (right > bounds.width) { - bounds.width = right; - } - if (bottom > bounds.height) { - bounds.height = bottom; - } - } - } - bounds.width -= bounds.x; - bounds.height -= bounds.y; - if (dragonBones.isV5) { - if (this._bounds === null) { - this._bounds = new egret.Rectangle(); - } - this._bounds.copyFrom(bounds); - } - } - else if (dragonBones.isV5) { - if (this._bounds === null) { - this._bounds = new egret.Rectangle(); - } - bounds.copyFrom(this._bounds); - } - return bounds; // V5 - } - return _super.prototype.$measureContentBounds.call(this, bounds); // V5 - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.hasEvent = function (type) { - return this.hasDBEventListener(type); - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.addEvent = function (type, listener, target) { - this.addDBEventListener(type, listener, target); - }; - /** - * @inheritDoc - */ - EgretArmatureDisplay.prototype.removeEvent = function (type, listener, target) { - this.removeDBEventListener(type, listener, target); - }; - /** - * - Deprecated, please refer to {@link dragonBones.Armature#clock} {@link dragonBones.BaseFactory#clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.Armature#clock} {@link dragonBones.BaseFactory#clock}。 - * @deprecated - * @language zh_CN - */ - EgretArmatureDisplay.prototype.advanceTimeBySelf = function (on) { - if (on) { - this._armature.clock = dragonBones.EgretFactory.factory.clock; - } - else { - this._armature.clock = null; - } - }; - return EgretArmatureDisplay; - }(egret.DisplayObjectContainer)); - dragonBones.EgretArmatureDisplay = EgretArmatureDisplay; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - var Event = /** @class */ (function (_super) { - __extends(Event, _super); - function Event() { - return _super !== null && _super.apply(this, arguments) || this; - } - return Event; - }(EgretEvent)); - dragonBones.Event = Event; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - var ArmatureEvent = /** @class */ (function (_super) { - __extends(ArmatureEvent, _super); - function ArmatureEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return ArmatureEvent; - }(EgretEvent)); - dragonBones.ArmatureEvent = ArmatureEvent; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - var AnimationEvent = /** @class */ (function (_super) { - __extends(AnimationEvent, _super); - function AnimationEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return AnimationEvent; - }(EgretEvent)); - dragonBones.AnimationEvent = AnimationEvent; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - var FrameEvent = /** @class */ (function (_super) { - __extends(FrameEvent, _super); - function FrameEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return FrameEvent; - }(EgretEvent)); - dragonBones.FrameEvent = FrameEvent; - /** - * 已废弃,请参考 {@link dragonBones.EgretEvent}。 - * @deprecated - * @language zh_CN - */ - var SoundEvent = /** @class */ (function (_super) { - __extends(SoundEvent, _super); - function SoundEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return SoundEvent; - }(EgretEvent)); - dragonBones.SoundEvent = SoundEvent; - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - var EgretTextureAtlas = /** @class */ (function (_super) { - __extends(EgretTextureAtlas, _super); - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - function EgretTextureAtlas(texture, rawData, scale) { - if (scale === void 0) { scale = 1; } - var _this = _super.call(this) || this; - console.warn("已废弃"); - _this._onClear(); - dragonBones.ObjectDataParser.getInstance().parseTextureAtlasData(rawData, _this, scale); - _this.renderTexture = texture; - return _this; - } - EgretTextureAtlas.toString = function () { - return "[class dragonBones.EgretTextureAtlas]"; - }; - return EgretTextureAtlas; - }(dragonBones.EgretTextureAtlasData)); - dragonBones.EgretTextureAtlas = EgretTextureAtlas; - /** - * 已废弃,请参考 {@link dragonBones.BaseFacory#parseTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - var EgretSheetAtlas = /** @class */ (function (_super) { - __extends(EgretSheetAtlas, _super); - function EgretSheetAtlas() { - return _super !== null && _super.apply(this, arguments) || this; - } - return EgretSheetAtlas; - }(EgretTextureAtlas)); - dragonBones.EgretSheetAtlas = EgretSheetAtlas; - /** - * 已废弃,请参考 {@link dragonBones.EgretFactory#soundEventManager}。 - * @deprecated - * @language zh_CN - */ - var SoundEventManager = /** @class */ (function () { - function SoundEventManager() { - } - /** - * 已废弃,请参考 {@link dragonBones.EgretFactory#soundEventManager}。 - * @deprecated - * @language zh_CN - */ - SoundEventManager.getInstance = function () { - console.warn("已废弃"); - return dragonBones.EgretFactory.factory.soundEventManager; - }; - return SoundEventManager; - }()); - dragonBones.SoundEventManager = SoundEventManager; - /** - * 已废弃,请参考 {@link dragonBones.Armature#cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - var AnimationCacheManager = /** @class */ (function () { - /** - * 已废弃,请参考 {@link dragonBones.Armature#cacheFrameRate}。 - * @deprecated - * @language zh_CN - */ - function AnimationCacheManager() { - console.warn("已废弃"); - } - return AnimationCacheManager; - }()); - dragonBones.AnimationCacheManager = AnimationCacheManager; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * - The egret slot. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 插槽。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var EgretSlot = /** @class */ (function (_super) { - __extends(EgretSlot, _super); - function EgretSlot() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - Whether to update the transform properties of the display object. - * For better performance, the transform properties of display object (x, y, rotation, ScaleX, ScaleX) are not updated and need to be set to true if these properties need to be accessed correctly. - * @default false - * @version DragonBones 3.0 - * @language zh_CN - */ - /** - * - 是否更新显示对象的变换属性。 - * 为了更好的性能, 默认并不会更新显示对象的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 - * @default false - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.transformUpdateEnabled = false; - _this._armatureDisplay = null; - _this._renderDisplay = null; - _this._colorFilter = null; - return _this; - } - EgretSlot.toString = function () { - return "[class dragonBones.EgretSlot]"; - }; - /** - * @inheritDoc - */ - EgretSlot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { - _super.prototype.init.call(this, slotData, armatureValue, rawDisplay, meshDisplay); - if (dragonBones.isV5) { - this._updateTransform = this._updateTransformV5; - } - else { - this._updateTransform = this._updateTransformV4; - } - }; - EgretSlot.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._armatureDisplay = null; // - this._renderDisplay = null; // - this._colorFilter = null; - }; - EgretSlot.prototype._initDisplay = function (value, isRetain) { - // tslint:disable-next-line:no-unused-expression - value; - // tslint:disable-next-line:no-unused-expression - isRetain; - }; - EgretSlot.prototype._disposeDisplay = function (value, isRelease) { - // tslint:disable-next-line:no-unused-expression - value; - // tslint:disable-next-line:no-unused-expression - isRelease; - }; - EgretSlot.prototype._onUpdateDisplay = function () { - this._armatureDisplay = this._armature.display; - this._renderDisplay = (this._display !== null ? this._display : this._rawDisplay); - if (dragonBones.isV5 && this._armatureDisplay._batchEnabled) { - if (this._renderDisplay === this._rawDisplay && !(this._renderDisplay.$renderNode instanceof egret.sys.BitmapNode)) { - this._renderDisplay.$renderNode = new egret.sys.BitmapNode(); // 默认是 sys.NormalBitmapNode 没有矩阵,需要替换成 egret.sys.BitmapNode。 - } - } - if (this._armatureDisplay._batchEnabled) { - if (this._renderDisplay !== this._rawDisplay && this._renderDisplay !== this._meshDisplay) { - this._armatureDisplay.disableBatch(); - } - else { - var node = this._renderDisplay.$renderNode; - if (!node.matrix) { - node.matrix = new egret.Matrix(); - } - } - } - }; - EgretSlot.prototype._addDisplay = function () { - if (this._armatureDisplay._batchEnabled) { - this._armatureDisplay.$renderNode.addNode(this._renderDisplay.$renderNode); - } - else { - this._armatureDisplay.addChild(this._renderDisplay); - } - }; - EgretSlot.prototype._replaceDisplay = function (value) { - var prevDisplay = value; - if (this._armatureDisplay._batchEnabled) { - var nodes = this._armatureDisplay.$renderNode.drawData; - nodes[nodes.indexOf(prevDisplay.$renderNode)] = this._renderDisplay.$renderNode; - } - else { - this._armatureDisplay.addChild(this._renderDisplay); - this._armatureDisplay.swapChildren(this._renderDisplay, prevDisplay); - this._armatureDisplay.removeChild(prevDisplay); - } - }; - EgretSlot.prototype._removeDisplay = function () { - if (this._armatureDisplay._batchEnabled) { - var nodes = this._armatureDisplay.$renderNode.drawData; - nodes.splice(nodes.indexOf(this._renderDisplay.$renderNode), 1); - } - else { - this._renderDisplay.parent.removeChild(this._renderDisplay); - } - }; - EgretSlot.prototype._updateZOrder = function () { - if (this._armatureDisplay._batchEnabled) { - var nodes = this._armatureDisplay.$renderNode.drawData; - nodes[this._zOrder] = this._renderDisplay.$renderNode; - } - else { - var index = this._armatureDisplay.getChildIndex(this._renderDisplay); - if (index === this._zOrder) { - return; - } - this._armatureDisplay.addChildAt(this._renderDisplay, this._zOrder); - } - }; - /** - * @internal - */ - EgretSlot.prototype._updateVisible = function () { - var visible = this._parent.visible && this._visible; - if (this._armatureDisplay._batchEnabled) { - var node = this._renderDisplay.$renderNode; - node.alpha = visible ? 1.0 : 0.0; - } - else { - this._renderDisplay.visible = visible; - } - }; - EgretSlot.prototype._updateBlendMode = function () { - switch (this._blendMode) { - case 0 /* Normal */: - this._renderDisplay.blendMode = egret.BlendMode.NORMAL; - break; - case 1 /* Add */: - this._renderDisplay.blendMode = egret.BlendMode.ADD; - break; - case 5 /* Erase */: - this._renderDisplay.blendMode = egret.BlendMode.ERASE; - break; - default: - break; - } - if (this._armatureDisplay._batchEnabled) { - var node = this._renderDisplay.$renderNode; - node.blendMode = egret.sys.blendModeToNumber(this._renderDisplay.blendMode); - } - }; - EgretSlot.prototype._updateColor = function () { - if (this._colorTransform.redMultiplier !== 1.0 || - this._colorTransform.greenMultiplier !== 1.0 || - this._colorTransform.blueMultiplier !== 1.0 || - this._colorTransform.redOffset !== 0 || - this._colorTransform.greenOffset !== 0 || - this._colorTransform.blueOffset !== 0 || - this._colorTransform.alphaOffset !== 0) { - if (this._colorFilter === null) { - this._colorFilter = new egret.ColorMatrixFilter(); - } - var colorMatrix = this._colorFilter.matrix; - colorMatrix[0] = this._colorTransform.redMultiplier; - colorMatrix[6] = this._colorTransform.greenMultiplier; - colorMatrix[12] = this._colorTransform.blueMultiplier; - colorMatrix[18] = this._colorTransform.alphaMultiplier; - colorMatrix[4] = this._colorTransform.redOffset; - colorMatrix[9] = this._colorTransform.greenOffset; - colorMatrix[14] = this._colorTransform.blueOffset; - colorMatrix[19] = this._colorTransform.alphaOffset; - this._colorFilter.matrix = colorMatrix; - if (this._armatureDisplay._batchEnabled) { - var node = this._renderDisplay.$renderNode; - node.filter = this._colorFilter; - node.alpha = 1.0; - } - var filters = this._renderDisplay.filters; - if (!filters) { - filters = []; - } - if (filters.indexOf(this._colorFilter) < 0) { - filters.push(this._colorFilter); - } - this._renderDisplay.filters = filters; - this._renderDisplay.alpha = 1.0; - } - else { - if (this._armatureDisplay._batchEnabled) { - var node = this._renderDisplay.$renderNode; - node.filter = null; - node.alpha = this._colorTransform.alphaMultiplier; - } - this._renderDisplay.filters = null; - this._renderDisplay.alpha = this._colorTransform.alphaMultiplier; - } - }; - EgretSlot.prototype._updateFrame = function () { - var currentVerticesData = (this._deformVertices !== null && this._display === this._meshDisplay) ? this._deformVertices.verticesData : null; - var currentTextureData = this._textureData; - if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { - if (this._armature.replacedTexture !== null && this._rawDisplayDatas !== null && this._rawDisplayDatas.indexOf(this._displayData) >= 0) { - var currentTextureAtlasData = currentTextureData.parent; - if (this._armature._replaceTextureAtlasData === null) { - currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.EgretTextureAtlasData); - currentTextureAtlasData.copyFrom(currentTextureData.parent); - currentTextureAtlasData.renderTexture = this._armature.replacedTexture; - this._armature._replaceTextureAtlasData = currentTextureAtlasData; - } - else { - currentTextureAtlasData = this._armature._replaceTextureAtlasData; - } - currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); - } - if (currentTextureData.renderTexture !== null) { - if (currentVerticesData !== null) { - var data = currentVerticesData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[currentVerticesData.offset + 0 /* MeshVertexCount */]; - var triangleCount = intArray[currentVerticesData.offset + 1 /* MeshTriangleCount */]; - var vertexOffset = intArray[currentVerticesData.offset + 2 /* MeshFloatOffset */]; - if (vertexOffset < 0) { - vertexOffset += 65536; // Fixed out of bouds bug. - } - var uvOffset = vertexOffset + vertexCount * 2; - var scale = this._armature._armatureData.scale; - var meshDisplay = this._renderDisplay; - var meshNode = meshDisplay.$renderNode; - meshNode.uvs.length = vertexCount * 2; - meshNode.vertices.length = vertexCount * 2; - meshNode.indices.length = triangleCount * 3; - for (var i = 0, l = vertexCount * 2; i < l; ++i) { - meshNode.vertices[i] = floatArray[vertexOffset + i] * scale; - meshNode.uvs[i] = floatArray[uvOffset + i]; - } - for (var i = 0; i < triangleCount * 3; ++i) { - meshNode.indices[i] = intArray[currentVerticesData.offset + 4 /* MeshVertexIndices */ + i]; - } - if (this._armatureDisplay._batchEnabled) { - var texture = currentTextureData.renderTexture; - var node = this._renderDisplay.$renderNode; - egret.sys.RenderNode.prototype.cleanBeforeRender.call(node); - node.image = texture.bitmapData; - if (dragonBones.isV5) { - node.drawMesh(texture.$bitmapX, texture.$bitmapY, texture.$bitmapWidth, texture.$bitmapHeight, texture.$offsetX, texture.$offsetY, texture.textureWidth, texture.textureHeight); - node.imageWidth = texture.$sourceWidth; - node.imageHeight = texture.$sourceHeight; - } - else { - var textureV4 = texture; - node.drawMesh(textureV4._bitmapX, textureV4._bitmapY, textureV4._bitmapWidth, textureV4._bitmapHeight, textureV4._offsetX, textureV4._offsetY, textureV4.textureWidth, textureV4.textureHeight); - node.imageWidth = textureV4._sourceWidth; - node.imageHeight = textureV4._sourceHeight; - } - this._blendModeDirty = true; - this._colorDirty = true; - } - meshDisplay.texture = currentTextureData.renderTexture; - meshDisplay.anchorOffsetX = this._pivotX; - meshDisplay.anchorOffsetY = this._pivotY; - meshDisplay.$updateVertices(); - if (!dragonBones.isV5) { - meshDisplay.$invalidateTransform(); - } - var isSkinned = currentVerticesData.weight !== null; - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - if (isSkinned || isSurface) { - this._identityTransform(); - } - } - else { - var scale = currentTextureData.parent.scale * this._armature._armatureData.scale; - var textureWidth = (currentTextureData.rotated ? currentTextureData.region.height : currentTextureData.region.width) * scale; - var textureHeight = (currentTextureData.rotated ? currentTextureData.region.width : currentTextureData.region.height) * scale; - var normalDisplay_1 = this._renderDisplay; - var texture = currentTextureData.renderTexture; - normalDisplay_1.texture = texture; - if (this._armatureDisplay._batchEnabled) { - var node = this._renderDisplay.$renderNode; - egret.sys.RenderNode.prototype.cleanBeforeRender.call(node); - node.image = texture.bitmapData; - if (dragonBones.isV5) { - node.drawImage(texture.$bitmapX, texture.$bitmapY, texture.$bitmapWidth, texture.$bitmapHeight, texture.$offsetX, texture.$offsetY, textureWidth, textureHeight); - node.imageWidth = texture.$sourceWidth; - node.imageHeight = texture.$sourceHeight; - } - else { - var textureV4 = texture; - node.drawImage(textureV4._bitmapX, textureV4._bitmapY, textureV4._bitmapWidth, textureV4._bitmapHeight, textureV4._offsetX, textureV4._offsetY, textureWidth, textureHeight); - node.imageWidth = textureV4._sourceWidth; - node.imageHeight = textureV4._sourceHeight; - } - this._blendModeDirty = true; - this._colorDirty = true; - } - else { - normalDisplay_1.width = textureWidth; - normalDisplay_1.height = textureHeight; - } - normalDisplay_1.anchorOffsetX = this._pivotX; - normalDisplay_1.anchorOffsetY = this._pivotY; - } - this._visibleDirty = true; - return; - } - } - if (this._armatureDisplay._batchEnabled) { - this._renderDisplay.$renderNode.image = null; - } - var normalDisplay = this._renderDisplay; - normalDisplay.texture = null; - normalDisplay.x = 0.0; - normalDisplay.y = 0.0; - normalDisplay.visible = false; - }; - EgretSlot.prototype._updateMesh = function () { - var scale = this._armature._armatureData.scale; - var deformVertices = this._deformVertices.vertices; - var bones = this._deformVertices.bones; - var verticesData = this._deformVertices.verticesData; - var weightData = verticesData.weight; - var hasDeform = deformVertices.length > 0 && verticesData.inheritDeform; - var meshDisplay = this._renderDisplay; - var meshNode = meshDisplay.$renderNode; - if (weightData !== null) { - var data = verticesData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[verticesData.offset + 0 /* MeshVertexCount */]; - var weightFloatOffset = intArray[weightData.offset + 1 /* WeigthFloatOffset */]; - if (weightFloatOffset < 0) { - weightFloatOffset += 65536; // Fixed out of bouds bug. - } - for (var i = 0, iD = 0, iB = weightData.offset + 2 /* WeigthBoneIndices */ + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) { - var boneCount = intArray[iB++]; - var xG = 0.0, yG = 0.0; - for (var j = 0; j < boneCount; ++j) { - var boneIndex = intArray[iB++]; - var bone = bones[boneIndex]; - if (bone !== null) { - var matrix = bone.globalTransformMatrix; - var weight = floatArray[iV++]; - var xL = floatArray[iV++] * scale; - var yL = floatArray[iV++] * scale; - if (hasDeform) { - xL += deformVertices[iF++]; - yL += deformVertices[iF++]; - } - xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; - yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; - } - } - meshNode.vertices[iD++] = xG; - meshNode.vertices[iD++] = yG; - } - meshDisplay.$updateVertices(); - if (!dragonBones.isV5) { - meshDisplay.$invalidateTransform(); - } - } - else if (hasDeform) { - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - var data = verticesData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[verticesData.offset + 0 /* MeshVertexCount */]; - var vertexOffset = intArray[verticesData.offset + 2 /* MeshFloatOffset */]; - if (vertexOffset < 0) { - vertexOffset += 65536; // Fixed out of bouds bug. - } - for (var i = 0, l = vertexCount * 2; i < l; i += 2) { - var x = floatArray[vertexOffset + i] * scale + deformVertices[i]; - var y = floatArray[vertexOffset + i + 1] * scale + deformVertices[i + 1]; - if (isSurface) { - var matrix = this._parent._getGlobalTransformMatrix(x, y); - meshNode.vertices[i] = matrix.a * x + matrix.c * y + matrix.tx; - meshNode.vertices[i + 1] = matrix.b * x + matrix.d * y + matrix.ty; - } - else { - meshNode.vertices[i] = x; - meshNode.vertices[i + 1] = y; - } - } - meshDisplay.$updateVertices(); - if (!dragonBones.isV5) { - meshDisplay.$invalidateTransform(); - } - } - if (this._armatureDisplay._batchEnabled) { - this._armatureDisplay._childDirty = true; - } - }; - /** - * @internal - */ - EgretSlot.prototype._updateGlueMesh = function () { - }; - EgretSlot.prototype._updateTransform = function () { - throw new Error(); - }; - EgretSlot.prototype._identityTransform = function () { - if (this._armatureDisplay._batchEnabled) { - this._armatureDisplay._childDirty = true; - var displayMatrix = this._renderDisplay.$renderNode.matrix; - displayMatrix.a = 1.0; - displayMatrix.b = 0.0; - displayMatrix.c = 0.0; - displayMatrix.d = 1.0; - displayMatrix.tx = 0.0; - displayMatrix.ty = 0.0; - } - else { - egret.$TempMatrix.identity(); - this._renderDisplay.$setMatrix(egret.$TempMatrix, this.transformUpdateEnabled); - } - }; - EgretSlot.prototype._updateTransformV4 = function () { - var globalTransformMatrix = this.globalTransformMatrix; - if (this._armatureDisplay._batchEnabled) { - this._armatureDisplay._childDirty = true; - var displayMatrix = this._renderDisplay.$renderNode.matrix; - displayMatrix.a = globalTransformMatrix.a; - displayMatrix.b = globalTransformMatrix.b; - displayMatrix.c = globalTransformMatrix.c; - displayMatrix.d = globalTransformMatrix.d; - displayMatrix.tx = this.globalTransformMatrix.tx - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); - displayMatrix.ty = this.globalTransformMatrix.ty - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); - } - else if (this.transformUpdateEnabled) { - this._renderDisplay.$setMatrix(globalTransformMatrix, true); - } - else { - var values = this._renderDisplay.$DisplayObject; - var displayMatrix = values[6]; - displayMatrix.a = this.globalTransformMatrix.a; - displayMatrix.b = this.globalTransformMatrix.b; - displayMatrix.c = this.globalTransformMatrix.c; - displayMatrix.d = this.globalTransformMatrix.d; - displayMatrix.tx = this.globalTransformMatrix.tx; - displayMatrix.ty = this.globalTransformMatrix.ty; - this._renderDisplay.$removeFlags(8); - this._renderDisplay.$invalidatePosition(); - } - }; - EgretSlot.prototype._updateTransformV5 = function () { - var globalTransformMatrix = this.globalTransformMatrix; - if (this._armatureDisplay._batchEnabled) { - this._armatureDisplay._childDirty = true; - var displayMatrix = this._renderDisplay.$renderNode.matrix; - displayMatrix.a = globalTransformMatrix.a; - displayMatrix.b = globalTransformMatrix.b; - displayMatrix.c = globalTransformMatrix.c; - displayMatrix.d = globalTransformMatrix.d; - displayMatrix.tx = this.globalTransformMatrix.tx - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); - displayMatrix.ty = this.globalTransformMatrix.ty - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); - } - else { - this._renderDisplay.$setMatrix(globalTransformMatrix, this.transformUpdateEnabled); - } - }; - return EgretSlot; - }(dragonBones.Slot)); - dragonBones.EgretSlot = EgretSlot; -})(dragonBones || (dragonBones = {})); -/** - * The MIT License (MIT) - * - * Copyright (c) 2012-2018 DragonBones team and other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -var dragonBones; -(function (dragonBones) { - /** - * @internal - */ - dragonBones.isV5 = Number(egret.Capabilities.engineVersion.substr(0, 3)) >= 5.1; - /** - * - The Egret factory. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Egret 工厂。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var EgretFactory = /** @class */ (function (_super) { - __extends(EgretFactory, _super); - /** - * @inheritDoc - */ - function EgretFactory(dataParser) { - if (dataParser === void 0) { dataParser = null; } - var _this = _super.call(this, dataParser) || this; - if (EgretFactory._dragonBonesInstance === null) { - // - var eventManager = new dragonBones.EgretArmatureDisplay(); - EgretFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); - EgretFactory._time = egret.getTimer() * 0.001; - egret.startTick(EgretFactory._clockHandler, EgretFactory); - } - _this._dragonBones = EgretFactory._dragonBonesInstance; - return _this; - } - EgretFactory._clockHandler = function (time) { - time *= 0.001; - var passedTime = time - this._time; - EgretFactory._dragonBonesInstance.advanceTime(passedTime); - this._time = time; - return false; - }; - Object.defineProperty(EgretFactory, "factory", { - /** - * - A global factory instance that can be used directly. - * @version DragonBones 4.7 - * @language en_US - */ - /** - * - 一个可以直接使用的全局工厂实例。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - if (EgretFactory._factory === null) { - EgretFactory._factory = new EgretFactory(); - } - return EgretFactory._factory; - }, - enumerable: true, - configurable: true - }); - EgretFactory.prototype._isSupportMesh = function () { - if (egret.Capabilities.renderMode === "webgl" || egret.Capabilities.runtimeType === egret.RuntimeType.NATIVE) { - return true; - } - console.warn("Canvas can not support mesh, please change renderMode to webgl."); - return false; - }; - EgretFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { - if (textureAtlasData !== null) { - if (textureAtlas instanceof egret.Texture) { - textureAtlasData.renderTexture = textureAtlas; - } - else { - var egretTexture = new egret.Texture(); - egretTexture.bitmapData = new egret.BitmapData(textureAtlas); - textureAtlasData.disposeEnabled = true; - textureAtlasData.renderTexture = egretTexture; - } - } - else { - textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.EgretTextureAtlasData); - } - return textureAtlasData; - }; - EgretFactory.prototype._buildArmature = function (dataPackage) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); - var armatureDisplay = new dragonBones.EgretArmatureDisplay(); - armature.init(dataPackage.armature, armatureDisplay, armatureDisplay, this._dragonBones); - return armature; - }; - EgretFactory.prototype._buildSlot = function (dataPackage, slotData, armature) { - // tslint:disable-next-line:no-unused-expression - dataPackage; - var slot = dragonBones.BaseObject.borrowObject(dragonBones.EgretSlot); - slot.init(slotData, armature, new egret.Bitmap(), new egret.Mesh()); - return slot; - }; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. - * Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. - * The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature display container. - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - *
-         *     let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
-         * 
- * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架,并用 {@link #clock} 更新该骨架。 - * 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 - * 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架的显示容器。 - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - *
-         *     let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
-         * 
- * @language zh_CN - */ - EgretFactory.prototype.buildArmatureDisplay = function (armatureName, dragonBonesName, skinName, textureAtlasName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - if (textureAtlasName === void 0) { textureAtlasName = ""; } - var armature = this.buildArmature(armatureName, dragonBonesName || "", skinName || "", textureAtlasName || ""); - if (armature !== null) { - this._dragonBones.clock.add(armature); - return armature.display; - } - return null; - }; - /** - * - Create the display object with the specified texture. - * @param textureName - The texture data name. - * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建带有指定贴图的显示对象。 - * @param textureName - 贴图数据名称。 - * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) - * @version DragonBones 3.0 - * @language zh_CN - */ - EgretFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) { - if (textureAtlasName === void 0) { textureAtlasName = null; } - var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName); - if (textureData !== null && textureData.renderTexture !== null) { - var texture = textureData.renderTexture; - var bitmap = new egret.Bitmap(texture); - bitmap.width = texture.textureWidth * textureData.parent.scale; - bitmap.height = texture.textureHeight * textureData.parent.scale; - return bitmap; - } - return null; - }; - Object.defineProperty(EgretFactory.prototype, "soundEventManager", { - /** - * - A global sound event manager. - * Sound events can be listened to uniformly from the manager. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 全局声音事件管理器。 - * 声音事件可以从该管理器统一侦听。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._dragonBones.eventManager; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EgretFactory, "clock", { - /** - * - Deprecated, please refer to {@link #clock}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #clock}。 - * @deprecated - * @language zh_CN - */ - get: function () { - return EgretFactory.factory.clock; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #addDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #addDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.addSkeletonData = function (dragonBonesData, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - console.warn("已废弃"); - this.addDragonBonesData(dragonBonesData, dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #getDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #getDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.getSkeletonData = function (dragonBonesName) { - console.warn("已废弃"); - return this.getDragonBonesData(dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #removeDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #removeDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.removeSkeletonData = function (dragonBonesName) { - console.warn("已废弃"); - this.removeDragonBonesData(dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #addTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #addTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.addTextureAtlas = function (textureAtlasData, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - console.warn("已废弃"); - this.addTextureAtlasData(textureAtlasData, dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #getTextureAtlas()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #getTextureAtlas()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.getTextureAtlas = function (dragonBonesName) { - console.warn("已废弃"); - return this.getTextureAtlasData(dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #removeTextureAtlasData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #removeTextureAtlasData()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.removeTextureAtlas = function (dragonBonesName) { - console.warn("已废弃"); - this.removeTextureAtlasData(dragonBonesName); - }; - /** - * - Deprecated, please refer to {@link #buildArmature()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #buildArmature()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.buildFastArmature = function (armatureName, dragonBonesName, skinName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - console.warn("已废弃"); - return this.buildArmature(armatureName, dragonBonesName || "", skinName || ""); - }; - /** - * - Deprecated, please refer to {@link #clear()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #clear()}。 - * @deprecated - * @language zh_CN - */ - EgretFactory.prototype.dispose = function () { - console.warn("已废弃"); - this.clear(); - }; - EgretFactory._time = 0.0; - EgretFactory._dragonBonesInstance = null; - EgretFactory._factory = null; - return EgretFactory; - }(dragonBones.BaseFactory)); - dragonBones.EgretFactory = EgretFactory; -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @private - */ - var _helpRectangle = new egret.Rectangle(); - /** - * @private - */ - var _helpMatrix = new egret.Matrix(); - /** - * @private - */ - var _groupConfigMap = {}; - /** - * @private - */ - function _findObjectInArray(array, name) { - for (var i = 0, l = array.length; i < l; ++i) { - var data = array[i]; - if (data.name === name) { - return data; - } - } - return null; - } - /** - * @private - */ - function _fillCreateMovieHelper(createMovieHelper) { - if (createMovieHelper.groupName) { - var groupConfig = _groupConfigMap[createMovieHelper.groupName]; - if (groupConfig) { - var movieConfig = _findObjectInArray(groupConfig.movie || groupConfig.animation, createMovieHelper.movieName); - if (movieConfig) { - createMovieHelper.groupConfig = groupConfig; - createMovieHelper.movieConfig = movieConfig; - return true; - } - } - } - if (!createMovieHelper.groupName) { - for (var groupName in _groupConfigMap) { - var groupConfig = _groupConfigMap[groupName]; - if (!createMovieHelper.groupName) { - var movieConfig = _findObjectInArray(groupConfig.movie || groupConfig.animation, createMovieHelper.movieName); - if (movieConfig) { - createMovieHelper.groupName = groupName; - createMovieHelper.groupConfig = groupConfig; - createMovieHelper.movieConfig = movieConfig; - return true; - } - } - } - } - return false; - } - /** - * 是否包含指定名称的动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function hasMovieGroup(groupName) { - return groupName in _groupConfigMap; - } - dragonBones.hasMovieGroup = hasMovieGroup; - /** - * 添加动画组。 - * @param groupData 动画二进制数据。 - * @param textureAtlas 贴图集或贴图集列表。 - * @param groupName 为动画组指定一个名称,如果未设置,则使用数据中的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function addMovieGroup(groupData, textureAtlas, groupName) { - if (groupName === void 0) { groupName = null; } - if (groupData) { - var byteArray = new egret.ByteArray(groupData); - byteArray.endian = egret.Endian.LITTLE_ENDIAN; - byteArray.position = 8; // TODO format - var groupConfig = JSON.parse(byteArray.readUTF()); - groupConfig.offset = byteArray.position; - groupConfig.arrayBuffer = groupData; - groupConfig.textures = []; - var p = groupConfig.offset % 4; - if (p) { - groupConfig.offset += 4 - p; - } - for (var i = 0, l = groupConfig.position.length; i < l; i += 3) { - switch (i / 3) { - case 1: - groupConfig.displayFrameArray = new Int16Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); - break; - case 2: - groupConfig.rectangleArray = new Float32Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); - break; - case 3: - groupConfig.transformArray = new Float32Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); - break; - case 4: - groupConfig.colorArray = new Int16Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); - break; - } - } - groupName = groupName || groupConfig.name; - if (_groupConfigMap[groupName]) { - console.warn("Replace group: " + groupName); - } - _groupConfigMap[groupName] = groupConfig; - // - if (textureAtlas instanceof Array) { - for (var i = 0, l = textureAtlas.length; i < l; ++i) { - var texture = textureAtlas[i]; - groupConfig.textures.push(texture); - } - } - else { - groupConfig.textures.push(textureAtlas); - } - } - else { - throw new Error(); - } - } - dragonBones.addMovieGroup = addMovieGroup; - /** - * 移除动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function removeMovieGroup(groupName) { - var groupConfig = _groupConfigMap[groupName]; - if (groupConfig) { - delete _groupConfigMap[groupName]; - } - } - dragonBones.removeMovieGroup = removeMovieGroup; - /** - * 移除所有的动画组。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function removeAllMovieGroup() { - for (var i in _groupConfigMap) { - delete _groupConfigMap[i]; - } - } - dragonBones.removeAllMovieGroup = removeAllMovieGroup; - /** - * 创建一个动画。 - * @param movieName 动画的名称。 - * @param groupName 动画组的名称,如果未设置,将检索所有的动画组,当多个动画组中包含同名的动画时,可能无法创建出准确的动画。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function buildMovie(movieName, groupName) { - if (groupName === void 0) { groupName = null; } - var createMovieHelper = { movieName: movieName, groupName: groupName }; - if (_fillCreateMovieHelper(createMovieHelper)) { - var movie = new Movie(createMovieHelper); - movie.clock = dragonBones.EgretFactory.factory.clock; - return movie; - } - else { - console.warn("No movie named: " + movieName); - } - return null; - } - dragonBones.buildMovie = buildMovie; - /** - * 获取指定动画组内包含的所有动画名称。 - * @param groupName 动画组的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - function getMovieNames(groupName) { - var groupConfig = _groupConfigMap[groupName]; - if (groupConfig) { - var movieNameGroup = []; - var movie = groupConfig.movie || groupConfig.animation; - for (var i = 0, l = movie.length; i < l; ++i) { - movieNameGroup.push(movie[i].name); - } - return movieNameGroup; - } - else { - console.warn("No group named: " + groupName); - } - return null; - } - dragonBones.getMovieNames = getMovieNames; - /** - * 动画事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - var MovieEvent = /** @class */ (function (_super) { - __extends(MovieEvent, _super); - /** - * @private - */ - function MovieEvent(type) { - var _this = _super.call(this, type) || this; - /** - * 事件名称。 (帧标签的名称或声音的名称) - * @version DragonBones 4.7 - * @language zh_CN - */ - _this.name = ""; - /** - * 发出事件的插槽名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - _this.slotName = ""; - /** - * 发出事件的动画剪辑名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - _this.clipName = ""; - return _this; - } - Object.defineProperty(MovieEvent.prototype, "armature", { - //========================================= // 兼容旧数据 - /** - * @private - */ - get: function () { - return this.movie; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieEvent.prototype, "bone", { - /** - * @private - */ - get: function () { - return null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieEvent.prototype, "animationState", { - /** - * @private - */ - get: function () { - return { name: this.clipName }; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieEvent.prototype, "frameLabel", { - /** - * @private - */ - get: function () { - return this.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MovieEvent.prototype, "movementID", { - /** - * @private - */ - get: function () { - return this.clipName; - }, - enumerable: true, - configurable: true - }); - /** - * 动画剪辑开始播放。 - * @version DragonBones 4.7 - * @language zh_CN - */ - MovieEvent.START = "start"; - /** - * 动画剪辑循环播放一次完成。 - * @version DragonBones 4.7 - * @language zh_CN - */ - MovieEvent.LOOP_COMPLETE = "loopComplete"; - /** - * 动画剪辑播放完成。 - * @version DragonBones 4.7 - * @language zh_CN - */ - MovieEvent.COMPLETE = "complete"; - /** - * 动画剪辑帧事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - MovieEvent.FRAME_EVENT = "frameEvent"; - /** - * 动画剪辑声音事件。 - * @version DragonBones 4.7 - * @language zh_CN - */ - MovieEvent.SOUND_EVENT = "soundEvent"; - return MovieEvent; - }(egret.Event)); - dragonBones.MovieEvent = MovieEvent; - /** - * @private - */ - var MovieSlot = /** @class */ (function (_super) { - __extends(MovieSlot, _super); - function MovieSlot(slotConfig) { - var _this = _super.call(this) || this; - _this.displayIndex = -1; - _this.colorIndex = -1; - _this.transformIndex = -1; - _this.rawDisplay = new egret.Bitmap(); - _this.childMovies = {}; - _this.displayConfig = null; - _this.childMovie = null; - _this.colorFilter = null; - _this.display = _this.rawDisplay; - _this.config = slotConfig; - _this.rawDisplay.name = _this.config.name; - if (!_this.config.blendMode) { - _this.config.blendMode = 0 /* Normal */; - } - return _this; - } - MovieSlot.prototype.dispose = function () { - this.rawDisplay = null; - this.childMovies = null; - this.config = null; - this.displayConfig = null; - this.display = null; - this.childMovie = null; - this.colorFilter = null; - }; - return MovieSlot; - }(egret.HashObject)); - /** - * 通过读取缓存的二进制动画数据来更新动画,具有良好的运行性能,同时对内存的占用也非常低。 - * @see dragonBones.buildMovie - * @version DragonBones 4.7 - * @language zh_CN - */ - var Movie = /** @class */ (function (_super) { - __extends(Movie, _super); - function Movie(createMovieHelper) { - var _this = _super.call(this) || this; - /** - * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1 - * @version DragonBones 4.7 - * @language zh_CN - */ - _this.timeScale = 1; - /** - * 动画剪辑的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * (当再次播放其他动画剪辑时,此值将被重置为 1) - * @default 1 - * @version DragonBones 4.7 - * @language zh_CN - */ - _this.clipTimeScale = 1; - _this._batchEnabled = true; - _this._isLockDispose = false; - _this._isDelayDispose = false; - _this._isStarted = false; - _this._isPlaying = false; - _this._isReversing = false; - _this._isCompleted = false; - _this._playTimes = 0; - _this._time = 0; - _this._currentTime = 0; - _this._currentPlayTimes = 0; - _this._cacheFrameIndex = 0; - _this._frameSize = 0; - _this._cacheRectangle = null; - _this._clock = null; - _this._currentFrameConfig = null; - _this._clipNames = []; - _this._slots = []; - _this._childMovies = []; - _this._groupConfig = createMovieHelper.groupConfig; - _this._config = createMovieHelper.movieConfig; - _this._batchEnabled = !(_this._config.isNested || _this._config.hasChildAnimation); - if (_this._batchEnabled) { - _this.$renderNode = new egret.sys.GroupNode(); - _this.$renderNode.cleanBeforeRender = Movie._cleanBeforeRender; - } - _this._clipNames.length = 0; - for (var i = 0, l = _this._config.clip.length; i < l; ++i) { - _this._clipNames.push(_this._config.clip[i].name); - } - for (var i = 0, l = _this._config.slot.length; i < l; ++i) { - var slot = new MovieSlot(_this._config.slot[i]); - _this._updateSlotBlendMode(slot); - _this._slots.push(slot); - if (_this._batchEnabled) { - _this.$renderNode.addNode(slot.rawDisplay.$renderNode); - } - else { - _this.addChild(slot.rawDisplay); - } - } - _this._frameSize = (1 + 1) * _this._slots.length; // displayFrame, transformFrame. - _this.name = _this._config.name; - _this.play(); - _this.advanceTime(0.000001); - _this.stop(); - return _this; - } - Movie._cleanBeforeRender = function () { }; - Movie.prototype._configToEvent = function (config, event) { - event.movie = this; - event.clipName = this._clipConfig.name; - event.name = config.name; - event.slotName = config.slot || ""; - }; - Movie.prototype._onCrossFrame = function (frameConfig) { - for (var i = 0, l = frameConfig.actionAndEvent.length; i < l; ++i) { - var actionAndEvent = frameConfig.actionAndEvent[i]; - if (actionAndEvent) { - switch (actionAndEvent.type) { - case 11 /* Sound */: - if (dragonBones.EgretFactory.factory.soundEventManager.hasEventListener(MovieEvent.SOUND_EVENT)) { - var event_1 = egret.Event.create(MovieEvent, MovieEvent.SOUND_EVENT); - this._configToEvent(actionAndEvent, event_1); - dragonBones.EgretFactory.factory.soundEventManager.dispatchEvent(event_1); - egret.Event.release(event_1); - } - break; - case 10 /* Frame */: - if (this.hasEventListener(MovieEvent.FRAME_EVENT)) { - var event_2 = egret.Event.create(MovieEvent, MovieEvent.FRAME_EVENT); - this._configToEvent(actionAndEvent, event_2); - this.dispatchEvent(event_2); - egret.Event.release(event_2); - } - break; - case 0 /* Play */: - if (actionAndEvent.slot) { - var slot = this._getSlot(actionAndEvent.slot); - if (slot && slot.childMovie) { - slot.childMovie.play(actionAndEvent.name); - } - } - else { - this.play(actionAndEvent.name); - } - break; - } - } - } - }; - Movie.prototype._updateSlotBlendMode = function (slot) { - var blendMode = ""; - switch (slot.config.blendMode) { - case 0 /* Normal */: - blendMode = egret.BlendMode.NORMAL; - break; - case 1 /* Add */: - blendMode = egret.BlendMode.ADD; - break; - case 5 /* Erase */: - blendMode = egret.BlendMode.ERASE; - break; - default: - break; - } - if (blendMode) { - if (this._batchEnabled) { - // RenderNode display. - slot.display.$renderNode.blendMode = egret.sys.blendModeToNumber(blendMode); - } - else { - // Classic display. - slot.display.blendMode = blendMode; - } - } - }; - Movie.prototype._updateSlotColor = function (slot, aM, rM, gM, bM, aO, rO, gO, bO) { - if (rM !== 1 || - gM !== 1 || - bM !== 1 || - rO !== 0 || - gO !== 0 || - bO !== 0 || - aO !== 0) { - if (!slot.colorFilter) { - slot.colorFilter = new egret.ColorMatrixFilter(); - } - var colorMatrix = slot.colorFilter.matrix; - colorMatrix[0] = rM; - colorMatrix[6] = gM; - colorMatrix[12] = bM; - colorMatrix[18] = aM; - colorMatrix[4] = rO; - colorMatrix[9] = gO; - colorMatrix[14] = bO; - colorMatrix[19] = aO; - slot.colorFilter.matrix = colorMatrix; - if (this._batchEnabled) { - // RenderNode display. - slot.display.$renderNode.filter = slot.colorFilter; - slot.display.$renderNode.alpha = 1.0; - } - else { - // Classic display. - var filters = slot.display.filters; - if (!filters) { - filters = []; - } - if (filters.indexOf(slot.colorFilter) < 0) { - filters.push(slot.colorFilter); - } - slot.display.filters = filters; - slot.display.$setAlpha(1.0); - } - } - else { - if (slot.colorFilter) { - slot.colorFilter = null; - } - if (this._batchEnabled) { - // RenderNode display. - slot.display.$renderNode.filter = null; - slot.display.$renderNode.alpha = aM; - } - else { - // Classic display. - slot.display.filters = null; - slot.display.$setAlpha(aM); - } - } - }; - Movie.prototype._updateSlotDisplay = function (slot) { - var prevDisplay = slot.display || slot.rawDisplay; - var prevChildMovie = slot.childMovie; - if (slot.displayIndex >= 0) { - slot.displayConfig = this._groupConfig.display[slot.displayIndex]; - if (slot.displayConfig.type === 1 /* Armature */) { - var childMovie = slot.displayConfig.name in slot.childMovies ? slot.childMovies[slot.displayConfig.name] : null; - if (!childMovie) { - childMovie = buildMovie(slot.displayConfig.name, this._groupConfig.name); - if (childMovie) { - slot.childMovies[slot.displayConfig.name] = childMovie; - } - } - if (childMovie) { - slot.display = childMovie; - slot.childMovie = childMovie; - } - else { - slot.display = slot.rawDisplay; - slot.childMovie = null; - } - } - else { - slot.display = slot.rawDisplay; - slot.childMovie = null; - } - } - else { - slot.displayConfig = null; - slot.display = slot.rawDisplay; - slot.childMovie = null; - } - if (slot.display !== prevDisplay) { - if (prevDisplay) { - this.addChild(slot.display); - this.swapChildren(slot.display, prevDisplay); - this.removeChild(prevDisplay); - } - // Update blendMode. - this._updateSlotBlendMode(slot); - } - // Update frame. - if (slot.display === slot.rawDisplay) { - if (slot.displayConfig && slot.displayConfig.regionIndex !== null && slot.displayConfig.regionIndex !== undefined) { - if (!slot.displayConfig.texture) { - var textureAtlasTexture = this._groupConfig.textures[slot.displayConfig.textureIndex || 0]; - var regionIndex = slot.displayConfig.regionIndex * 4; - var x = this._groupConfig.rectangleArray[regionIndex]; - var y = this._groupConfig.rectangleArray[regionIndex + 1]; - var width = this._groupConfig.rectangleArray[regionIndex + 2]; - var height = this._groupConfig.rectangleArray[regionIndex + 3]; - slot.displayConfig.texture = new egret.Texture(); - slot.displayConfig.texture.bitmapData = textureAtlasTexture.bitmapData; - slot.displayConfig.texture.$initData(x, y, Math.min(width, textureAtlasTexture.textureWidth - x), Math.min(height, textureAtlasTexture.textureHeight - y), 0, 0, Math.min(width, textureAtlasTexture.textureWidth - x), Math.min(height, textureAtlasTexture.textureHeight - y), textureAtlasTexture.textureWidth, textureAtlasTexture.textureHeight); - } - if (this._batchEnabled) { - // RenderNode display. - var texture = slot.displayConfig.texture; - var bitmapNode = slot.rawDisplay.$renderNode; - egret.sys.RenderNode.prototype.cleanBeforeRender.call(slot.rawDisplay.$renderNode); - bitmapNode.image = texture.bitmapData; - if (dragonBones.isV5) { - bitmapNode.drawImage(texture.$bitmapX, texture.$bitmapY, texture.$bitmapWidth, texture.$bitmapHeight, texture.$offsetX, texture.$offsetY, texture.textureWidth, texture.textureHeight); - bitmapNode.imageWidth = texture._sourceWidth; - bitmapNode.imageHeight = texture._sourceHeight; - } - else { - var textureV4 = texture; - bitmapNode.drawImage(textureV4._bitmapX, textureV4._bitmapY, textureV4._bitmapWidth, textureV4._bitmapHeight, textureV4._offsetX, textureV4._offsetY, texture.textureWidth, texture.textureHeight); - bitmapNode.imageWidth = textureV4._sourceWidth; - bitmapNode.imageHeight = textureV4._sourceHeight; - } - } - else { - // Classic display. - slot.rawDisplay.visible = true; - slot.rawDisplay.$setBitmapData(slot.displayConfig.texture); - } - } - else { - if (this._batchEnabled) { - // RenderNode display. - slot.rawDisplay.$renderNode.image = null; - } - else { - // Classic display. - slot.rawDisplay.visible = false; - slot.rawDisplay.$setBitmapData(null); - } - } - } - // Update child movie. - if (slot.childMovie !== prevChildMovie) { - if (prevChildMovie) { - prevChildMovie.stop(); - this._childMovies.slice(this._childMovies.indexOf(prevChildMovie), 1); - } - if (slot.childMovie) { - if (this._childMovies.indexOf(slot.childMovie) < 0) { - this._childMovies.push(slot.childMovie); - } - if (slot.config.action) { - slot.childMovie.play(slot.config.action); - } - else { - slot.childMovie.play(slot.childMovie._config.action); - } - } - } - }; - Movie.prototype._getSlot = function (name) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - var slot = this._slots[i]; - if (slot.config.name === name) { - return slot; - } - } - return null; - }; - /** - * @inheritDoc - */ - Movie.prototype.$render = function () { - if (this._batchEnabled) { - // RenderNode display. - } - else { - // Classic display. - _super.prototype.$render.call(this); - } - }; - /** - * @inheritDoc - */ - Movie.prototype.$updateRenderNode = function () { - if (this._batchEnabled) { - // RenderNode display. - } - else { - // Classic display. - _super.prototype.$updateRenderNode.call(this); - } - }; - /** - * @inheritDoc - */ - Movie.prototype.$measureContentBounds = function (bounds) { - if (this._batchEnabled && this._cacheRectangle) { - // RenderNode display. - bounds.setTo(this._cacheRectangle.x, this._cacheRectangle.y, this._cacheRectangle.width - this._cacheRectangle.x, this._cacheRectangle.height - this._cacheRectangle.y); - } - else { - // Classic display. - _super.prototype.$measureContentBounds.call(this, bounds); - } - }; - /** - * @inheritDoc - */ - Movie.prototype.$doAddChild = function (child, index, notifyListeners) { - if (this._batchEnabled) { - // RenderNode display. - console.warn("Can not add child."); - return null; - } - // Classic display. - return _super.prototype.$doAddChild.call(this, child, index, notifyListeners); - }; - /** - * @inheritDoc - */ - Movie.prototype.$doRemoveChild = function (index, notifyListeners) { - if (this._batchEnabled) { - // RenderNode display. - console.warn("Can not remove child."); - return null; - } - // Classic display. - return _super.prototype.$doRemoveChild.call(this, index, notifyListeners); - }; - /** - * 释放动画。 - * @version DragonBones 3.0 - * @language zh_CN - */ - Movie.prototype.dispose = function () { - if (this._isLockDispose) { - this._isDelayDispose = true; - } - else { - if (this._clock) { - this._clock.remove(this); - } - if (this._slots) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i].dispose(); - } - } - this._isPlaying = false; - this._cacheRectangle = null; - this._clock = null; - this._groupConfig = null; - this._config = null; - this._clipConfig = null; - this._currentFrameConfig = null; - this._clipArray = null; - this._clipNames = null; - this._slots = null; - this._childMovies = null; - } - }; - /** - * @inheritDoc - */ - Movie.prototype.advanceTime = function (passedTime) { - if (this._isPlaying) { - this._isLockDispose = true; - if (passedTime < 0) { - passedTime = -passedTime; - } - passedTime *= this.timeScale; - this._time += passedTime * this.clipTimeScale; - // Modify time. - var duration = this._clipConfig.duration; - var totalTime = duration * this._playTimes; - var currentTime = this._time; - var currentPlayTimes = this._currentPlayTimes; - if (this._playTimes > 0 && (currentTime >= totalTime || currentTime <= -totalTime)) { - this._isCompleted = true; - currentPlayTimes = this._playTimes; - if (currentTime < 0) { - currentTime = 0; - } - else { - currentTime = duration; - } - } - else { - this._isCompleted = false; - if (currentTime < 0) { - currentPlayTimes = Math.floor(-currentTime / duration); - currentTime = duration - (-currentTime % duration); - } - else { - currentPlayTimes = Math.floor(currentTime / duration); - currentTime %= duration; - } - if (this._playTimes > 0 && currentPlayTimes > this._playTimes) { - currentPlayTimes = this._playTimes; - } - } - if (this._currentTime === currentTime) { - return; - } - var cacheFrameIndex = Math.floor(currentTime * this._clipConfig.cacheTimeToFrameScale); - if (this._cacheFrameIndex !== cacheFrameIndex) { - this._cacheFrameIndex = cacheFrameIndex; - var displayFrameArray = this._groupConfig.displayFrameArray; - var transformArray = this._groupConfig.transformArray; - var colorArray = this._groupConfig.colorArray; - // - var isFirst = true; - var hasDisplay = false; - var needCacheRectangle = false; - var prevCacheRectangle = this._cacheRectangle; - this._cacheRectangle = this._clipConfig.cacheRectangles[this._cacheFrameIndex]; - if (this._batchEnabled && !this._cacheRectangle) { - needCacheRectangle = true; - this._cacheRectangle = new egret.Rectangle(); - this._clipConfig.cacheRectangles[this._cacheFrameIndex] = this._cacheRectangle; - } - // Update slots. - for (var i = 0, l = this._slots.length; i < l; ++i) { - var slot = this._slots[i]; - var clipFrameIndex = this._frameSize * this._cacheFrameIndex + i * 2; - if (clipFrameIndex >= this._clipArray.length) { - clipFrameIndex = this._frameSize * (this._cacheFrameIndex - 1) + i * 2; - } - var displayFrameIndex = this._clipArray[clipFrameIndex] * 2; - if (displayFrameIndex >= 0) { - var displayIndex = displayFrameArray[displayFrameIndex]; - var colorIndex = displayFrameArray[displayFrameIndex + 1] * 8; - var transformIndex = this._clipArray[clipFrameIndex + 1] * 6; - var colorChange = false; - if (slot.displayIndex !== displayIndex) { - slot.displayIndex = displayIndex; - colorChange = true; - this._updateSlotDisplay(slot); - } - if (slot.colorIndex !== colorIndex || colorChange) { - slot.colorIndex = colorIndex; - if (slot.colorIndex >= 0) { - this._updateSlotColor(slot, colorArray[colorIndex] * 0.01, colorArray[colorIndex + 1] * 0.01, colorArray[colorIndex + 2] * 0.01, colorArray[colorIndex + 3] * 0.01, colorArray[colorIndex + 4], colorArray[colorIndex + 5], colorArray[colorIndex + 6], colorArray[colorIndex + 7]); - } - else { - this._updateSlotColor(slot, 1, 1, 1, 1, 0, 0, 0, 0); - } - } - hasDisplay = true; - if (slot.transformIndex !== transformIndex) { - slot.transformIndex = transformIndex; - if (this._batchEnabled) { - // RenderNode display. - var matrix = slot.display.$renderNode.matrix; - if (!matrix) { - matrix = slot.display.$renderNode.matrix = new egret.Matrix(); - } - matrix.a = transformArray[transformIndex]; - matrix.b = transformArray[transformIndex + 1]; - matrix.c = transformArray[transformIndex + 2]; - matrix.d = transformArray[transformIndex + 3]; - matrix.tx = transformArray[transformIndex + 4]; - matrix.ty = transformArray[transformIndex + 5]; - } - else { - // Classic display. - _helpMatrix.a = transformArray[transformIndex]; - _helpMatrix.b = transformArray[transformIndex + 1]; - _helpMatrix.c = transformArray[transformIndex + 2]; - _helpMatrix.d = transformArray[transformIndex + 3]; - _helpMatrix.tx = transformArray[transformIndex + 4]; - _helpMatrix.ty = transformArray[transformIndex + 5]; - slot.display.$setMatrix(_helpMatrix); - } - } - // - if (this._batchEnabled && needCacheRectangle && slot.displayConfig) { - // RenderNode display. - var matrix = slot.display.$renderNode.matrix; - _helpRectangle.x = 0; - _helpRectangle.y = 0; - _helpRectangle.width = slot.displayConfig.texture.textureWidth; - _helpRectangle.height = slot.displayConfig.texture.textureHeight; - matrix.$transformBounds(_helpRectangle); - if (isFirst) { - isFirst = false; - this._cacheRectangle.x = _helpRectangle.x; - this._cacheRectangle.width = _helpRectangle.x + _helpRectangle.width; - this._cacheRectangle.y = _helpRectangle.y; - this._cacheRectangle.height = _helpRectangle.y + _helpRectangle.height; - } - else { - this._cacheRectangle.x = Math.min(this._cacheRectangle.x, _helpRectangle.x); - this._cacheRectangle.width = Math.max(this._cacheRectangle.width, _helpRectangle.x + _helpRectangle.width); - this._cacheRectangle.y = Math.min(this._cacheRectangle.y, _helpRectangle.y); - this._cacheRectangle.height = Math.max(this._cacheRectangle.height, _helpRectangle.y + _helpRectangle.height); - } - } - } - else if (slot.displayIndex !== -1) { - slot.displayIndex = -1; - this._updateSlotDisplay(slot); - } - } - // - if (this._cacheRectangle) { - if (hasDisplay && needCacheRectangle && isFirst && prevCacheRectangle) { - this._cacheRectangle.x = prevCacheRectangle.x; - this._cacheRectangle.y = prevCacheRectangle.y; - this._cacheRectangle.width = prevCacheRectangle.width; - this._cacheRectangle.height = prevCacheRectangle.height; - } - if (!dragonBones.isV5) { - this.$invalidateContentBounds(); - } - } - } - if (this._isCompleted) { - this._isPlaying = false; - } - if (!this._isStarted) { - this._isStarted = true; - if (this.hasEventListener(MovieEvent.START)) { - var event_3 = egret.Event.create(MovieEvent, MovieEvent.START); - event_3.movie = this; - event_3.clipName = this._clipConfig.name; - event_3.name = ""; - event_3.slotName = ""; - this.dispatchEvent(event_3); - } - } - this._isReversing = this._currentTime > currentTime && this._currentPlayTimes === currentPlayTimes; - this._currentTime = currentTime; - // Action and event. - var frameCount = this._clipConfig.frame ? this._clipConfig.frame.length : 0; - if (frameCount > 0) { - var currentFrameIndex = Math.floor(this._currentTime * this._config.frameRate); - var currentFrameConfig = this._groupConfig.frame[this._clipConfig.frame[currentFrameIndex]]; - if (this._currentFrameConfig !== currentFrameConfig) { - if (frameCount > 1) { - var crossedFrameConfig = this._currentFrameConfig; - this._currentFrameConfig = currentFrameConfig; - if (!crossedFrameConfig) { - var prevFrameIndex = Math.floor(this._currentTime * this._config.frameRate); - crossedFrameConfig = this._groupConfig.frame[this._clipConfig.frame[prevFrameIndex]]; - if (this._isReversing) { - } - else { - if (this._currentTime <= crossedFrameConfig.position || - this._currentPlayTimes !== currentPlayTimes) { - crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.prev]; - } - } - } - if (this._isReversing) { - while (crossedFrameConfig !== currentFrameConfig) { - this._onCrossFrame(crossedFrameConfig); - crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.prev]; - } - } - else { - while (crossedFrameConfig !== currentFrameConfig) { - crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.next]; - this._onCrossFrame(crossedFrameConfig); - } - } - } - else { - this._currentFrameConfig = currentFrameConfig; - if (this._currentFrameConfig) { - this._onCrossFrame(this._currentFrameConfig); - } - } - } - } - if (this._currentPlayTimes !== currentPlayTimes) { - this._currentPlayTimes = currentPlayTimes; - if (this.hasEventListener(MovieEvent.LOOP_COMPLETE)) { - var event_4 = egret.Event.create(MovieEvent, MovieEvent.LOOP_COMPLETE); - event_4.movie = this; - event_4.clipName = this._clipConfig.name; - event_4.name = ""; - event_4.slotName = ""; - this.dispatchEvent(event_4); - egret.Event.release(event_4); - } - if (this._isCompleted && this.hasEventListener(MovieEvent.COMPLETE)) { - var event_5 = egret.Event.create(MovieEvent, MovieEvent.COMPLETE); - event_5.movie = this; - event_5.clipName = this._clipConfig.name; - event_5.name = ""; - event_5.slotName = ""; - this.dispatchEvent(event_5); - egret.Event.release(event_5); - } - } - } - this._isLockDispose = false; - if (this._isDelayDispose) { - this.dispose(); - } - }; - /** - * 播放动画剪辑。 - * @param clipName 动画剪辑的名称,如果未设置,则播放默认动画剪辑,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画剪辑。 - * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 4.7 - * @language zh_CN - */ - Movie.prototype.play = function (clipName, playTimes) { - if (clipName === void 0) { clipName = null; } - if (playTimes === void 0) { playTimes = -1; } - if (clipName) { - var clipConfig = null; - for (var i = 0, l = this._config.clip.length; i < l; ++i) { - var data = this._config.clip[i]; - if (data.name === clipName) { - clipConfig = data; - } - } - if (clipConfig) { - this._clipConfig = clipConfig; - this._clipArray = new Int16Array(this._groupConfig.arrayBuffer, this._groupConfig.offset + this._groupConfig.position[0] + this._clipConfig.p, this._clipConfig.s / this._groupConfig.position[2]); - if (!this._clipConfig.cacheRectangles) { - this._clipConfig.cacheRectangles = []; - } - this._isPlaying = true; - this._isStarted = false; - this._isCompleted = false; - if (playTimes < 0 || playTimes !== playTimes) { - this._playTimes = this._clipConfig.playTimes; - } - else { - this._playTimes = playTimes; - } - this._time = 0; - this._currentTime = 0; - this._currentPlayTimes = 0; - this._cacheFrameIndex = -1; - this._currentFrameConfig = null; - this._cacheRectangle = null; - this.clipTimeScale = 1 / this._clipConfig.scale; - } - else { - console.warn("No clip in movie.", this._config.name, clipName); - } - } - else if (this._clipConfig) { - if (this._isPlaying || this._isCompleted) { - this.play(this._clipConfig.name, this._playTimes); - } - else { - this._isPlaying = true; - } - // playTimes - } - else if (this._config.action) { - this.play(this._config.action, playTimes); - } - }; - /** - * 暂停播放动画。 - * @version DragonBones 4.7 - * @language zh_CN - */ - Movie.prototype.stop = function () { - this._isPlaying = false; - }; - /** - * 从指定时间播放动画。 - * @param clipName 动画剪辑的名称。 - * @param time 指定时间。(以秒为单位) - * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 5.0 - * @language zh_CN - */ - Movie.prototype.gotoAndPlay = function (clipName, time, playTimes) { - if (clipName === void 0) { clipName = null; } - if (playTimes === void 0) { playTimes = -1; } - time %= this._clipConfig.duration; - if (time < 0) { - time += this._clipConfig.duration; - } - this.play(clipName, playTimes); - this._time = time; - this._currentTime = time; - }; - /** - * 将动画停止到指定时间。 - * @param clipName 动画剪辑的名称。 - * @param time 指定时间。(以秒为单位) - * @version DragonBones 5.0 - * @language zh_CN - */ - Movie.prototype.gotoAndStop = function (clipName, time) { - if (clipName === void 0) { clipName = null; } - time %= this._clipConfig.duration; - if (time < 0) { - time += this._clipConfig.duration; - } - this.play(clipName, 1); - this._time = time; - this._currentTime = time; - this.advanceTime(0.001); - this.stop(); - }; - /** - * 是否包含指定动画剪辑。 - * @param clipName 动画剪辑的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - Movie.prototype.hasClip = function (clipName) { - for (var i = 0, l = this._config.clip.length; i < l; ++i) { - var clip = this._config.clip[i]; - if (clip.name === clipName) { - return true; - } - } - return false; - }; - Object.defineProperty(Movie.prototype, "isPlaying", { - /** - * 动画剪辑是否处正在播放。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._isPlaying && !this._isCompleted; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "isComplete", { - /** - * 动画剪辑是否均播放完毕。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._isCompleted; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "currentTime", { - /** - * 当前动画剪辑的播放时间。 (以秒为单位) - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._currentTime; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "totalTime", { - /** - * 当前动画剪辑的总时间。 (以秒为单位) - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._clipConfig ? this._clipConfig.duration : 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "currentPlayTimes", { - /** - * 当前动画剪辑的播放次数。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._currentPlayTimes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "playTimes", { - /** - * 当前动画剪辑需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._playTimes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "groupName", { - get: function () { - return this._groupConfig.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "clipName", { - /** - * 正在播放的动画剪辑名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._clipConfig ? this._clipConfig.name : ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "clipNames", { - /** - * 所有动画剪辑的名称。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - return this._clipNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - var prevClock = this._clock; - if (prevClock) { - prevClock.remove(this); - } - this._clock = value; - if (this._clock) { - this._clock.add(this); - } - }, - enumerable: true, - configurable: true - }); - /** - * 已废弃,请参考 {@link dragonBones.Movie#clock} {@link dragonBones.Movie#clock} {@link dragonBones.EgretFactory#clock}。 - * @deprecated - * @language zh_CN - */ - Movie.prototype.advanceTimeBySelf = function (on) { - if (on) { - this.clock = dragonBones.EgretFactory.clock; - } - else { - this.clock = null; - } - }; - Object.defineProperty(Movie.prototype, "display", { - //========================================= // 兼容旧数据 - /** - * @private - */ - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "animation", { - /** - * @private - */ - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "armature", { - /** - * @private - */ - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - /** - * @private - */ - Movie.prototype.getAnimation = function () { - return this; - }; - /** - * @private - */ - Movie.prototype.getArmature = function () { - return this; - }; - /** - * @private - */ - Movie.prototype.getDisplay = function () { - return this; - }; - /** - * @private - */ - Movie.prototype.hasAnimation = function (name) { - return this.hasClip(name); - }; - /** - * @private - */ - Movie.prototype.invalidUpdate = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - // tslint:disable-next-line:no-unused-expression - args; - }; - Object.defineProperty(Movie.prototype, "lastAnimationName", { - /** - * @private - */ - get: function () { - return this.clipName; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "animationNames", { - /** - * @private - */ - get: function () { - return this.clipNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Movie.prototype, "animationList", { - /** - * @private - */ - get: function () { - return this.clipNames; - }, - enumerable: true, - configurable: true - }); - return Movie; - }(egret.DisplayObjectContainer)); - dragonBones.Movie = Movie; -})(dragonBones || (dragonBones = {})); diff --git a/demo/libs/modules/dragonBones/dragonBones.min.js b/demo/libs/modules/dragonBones/dragonBones.min.js deleted file mode 100644 index bfd59c17..00000000 --- a/demo/libs/modules/dragonBones/dragonBones.min.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)if(e.hasOwnProperty(a))t[a]=e[a]};return function(e,a){t(e,a);function r(){this.constructor=e}e.prototype=a===null?Object.create(a):(r.prototype=a.prototype,new r)}}();var dragonBones;(function(t){})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function e(a){this._clock=new t.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=a;console.info("DragonBones: "+e.VERSION+"\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/")}e.prototype.advanceTime=function(e){if(this._objects.length>0){for(var a=0,r=this._objects;a0){for(var n=0;na){i.length=a}t._maxCountMap[r]=a}else{t._defaultMaxCount=a;for(var r in t._poolsMap){var i=t._poolsMap[r];if(i.length>a){i.length=a}if(r in t._maxCountMap){t._maxCountMap[r]=a}}}};t.clearPool=function(e){if(e===void 0){e=null}if(e!==null){var a=String(e);var r=a in t._poolsMap?t._poolsMap[a]:null;if(r!==null&&r.length>0){r.length=0}}else{for(var i in t._poolsMap){var r=t._poolsMap[i];r.length=0}}};t.borrowObject=function(e){var a=String(e);var r=a in t._poolsMap?t._poolsMap[a]:null;if(r!==null&&r.length>0){var i=r.pop();i._isInPool=false;return i}var n=new e;n._onClear();return n};t.prototype.returnToPool=function(){this._onClear();t._returnObject(this)};t._hashCode=0;t._defaultMaxCount=3e3;t._maxCountMap={};t._poolsMap={};return t}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n){if(t===void 0){t=1}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=a;this.d=r;this.tx=i;this.ty=n}t.prototype.toString=function(){return"[object dragonBones.Matrix] a:"+this.a+" b:"+this.b+" c:"+this.c+" d:"+this.d+" tx:"+this.tx+" ty:"+this.ty};t.prototype.copyFrom=function(t){this.a=t.a;this.b=t.b;this.c=t.c;this.d=t.d;this.tx=t.tx;this.ty=t.ty;return this};t.prototype.copyFromArray=function(t,e){if(e===void 0){e=0}this.a=t[e];this.b=t[e+1];this.c=t[e+2];this.d=t[e+3];this.tx=t[e+4];this.ty=t[e+5];return this};t.prototype.identity=function(){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this};t.prototype.concat=function(t){var e=this.a*t.a;var a=0;var r=0;var i=this.d*t.d;var n=this.tx*t.a+t.tx;var s=this.ty*t.d+t.ty;if(this.b!==0||this.c!==0){e+=this.b*t.c;a+=this.b*t.d;r+=this.c*t.a;i+=this.c*t.b}if(t.b!==0||t.c!==0){a+=this.a*t.b;r+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=a;this.c=r;this.d=i;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var a=this.c;var r=this.d;var i=this.tx;var n=this.ty;if(e===0&&a===0){this.b=this.c=0;if(t===0||r===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;r=this.d=1/r;this.tx=-t*i;this.ty=-r*n}return this}var s=t*r-e*a;if(s===0){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this}s=1/s;var o=this.a=r*s;e=this.b=-e*s;a=this.c=-a*s;r=this.d=t*s;this.tx=-(o*i+a*n);this.ty=-(e*i+r*n);return this};t.prototype.transformPoint=function(t,e,a,r){if(r===void 0){r=false}a.x=this.a*t+this.c*e;a.y=this.b*t+this.d*e;if(!r){a.x+=this.tx;a.y+=this.ty}};t.prototype.transformRectangle=function(t,e){if(e===void 0){e=false}var a=this.a;var r=this.b;var i=this.c;var n=this.d;var s=e?0:this.tx;var o=e?0:this.ty;var l=t.x;var h=t.y;var f=l+t.width;var u=h+t.height;var _=a*l+i*h+s;var c=r*l+n*h+o;var p=a*f+i*h+s;var m=r*f+n*h+o;var d=a*f+i*u+s;var v=r*f+n*u+o;var y=a*l+i*u+s;var g=r*l+n*u+o;var b=0;if(_>p){b=_;_=p;p=b}if(d>y){b=d;d=y;y=b}t.x=Math.floor(_y?p:y)-t.x);if(c>m){b=c;c=m;m=b}if(v>g){b=v;v=g;g=b}t.y=Math.floor(cg?m:g)-t.y)};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}if(i===void 0){i=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=a;this.rotation=r;this.scaleX=i;this.scaleY=n}t.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};t.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+this.skew*180/Math.PI+" skewY:"+this.rotation*180/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY};t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.skew=t.skew;this.rotation=t.rotation;this.scaleX=t.scaleX;this.scaleY=t.scaleY;return this};t.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};t.prototype.add=function(t){this.x+=t.x;this.y+=t.y;this.skew+=t.skew;this.rotation+=t.rotation;this.scaleX*=t.scaleX;this.scaleY*=t.scaleY;return this};t.prototype.minus=function(t){this.x-=t.x;this.y-=t.y;this.skew-=t.skew;this.rotation-=t.rotation;this.scaleX/=t.scaleX;this.scaleY/=t.scaleY;return this};t.prototype.fromMatrix=function(e){var a=this.scaleX,r=this.scaleY;var i=t.PI_Q;this.x=e.tx;this.y=e.ty;this.rotation=Math.atan(e.b/e.a);var n=Math.atan(-e.c/e.d);this.scaleX=this.rotation>-i&&this.rotation-i&&n=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(r>=0&&this.scaleY<0){this.scaleY=-this.scaleY;n=n-Math.PI}this.skew=n-this.rotation;return this};t.prototype.toMatrix=function(t){if(this.rotation===0){t.a=1;t.b=0}else{t.a=Math.cos(this.rotation);t.b=Math.sin(this.rotation)}if(this.skew===0){t.c=-t.b;t.d=t.a}else{t.c=-Math.sin(this.skew+this.rotation);t.d=Math.cos(this.skew+this.rotation)}if(this.scaleX!==1){t.a*=this.scaleX;t.b*=this.scaleX}if(this.scaleY!==1){t.c*=this.scaleY;t.d*=this.scaleY}t.tx=this.x;t.ty=this.y;return this};t.PI=Math.PI;t.PI_D=Math.PI*2;t.PI_H=Math.PI/2;t.PI_Q=Math.PI/4;t.RAD_DEG=180/Math.PI;t.DEG_RAD=Math.PI/180;return t}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(a===void 0){a=1}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}if(s===void 0){s=0}if(o===void 0){o=0}this.alphaMultiplier=t;this.redMultiplier=e;this.greenMultiplier=a;this.blueMultiplier=r;this.alphaOffset=i;this.redOffset=n;this.greenOffset=s;this.blueOffset=o}t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier;this.redMultiplier=t.redMultiplier;this.greenMultiplier=t.greenMultiplier;this.blueMultiplier=t.blueMultiplier;this.alphaOffset=t.alphaOffset;this.redOffset=t.redOffset;this.greenOffset=t.greenOffset;this.blueOffset=t.blueOffset};t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1;this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0};return t}();t.ColorTransform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e){if(t===void 0){t=0}if(e===void 0){e=0}this.x=t;this.y=e}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y};t.prototype.clear=function(){this.x=this.y=0};return t}();t.Point=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}this.x=t;this.y=e;this.width=a;this.height=r}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.width=t.width;this.height=t.height};t.prototype.clear=function(){this.x=this.y=0;this.width=this.height=0};return t}();t.Rectangle=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.ints=[];e.floats=[];e.strings=[];return e}e.toString=function(){return"[class dragonBones.UserData]"};e.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};e.prototype.addInt=function(t){this.ints.push(t)};e.prototype.addFloat=function(t){this.floats.push(t)};e.prototype.addString=function(t){this.strings.push(t)};e.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){a=0}if(this.sortedBones.indexOf(i)>=0){continue}var n=false;for(var s in this.constraints){var o=this.constraints[s];if(o.root===i&&this.sortedBones.indexOf(o.target)<0){n=true;break}}if(n){continue}if(i.parent!==null&&this.sortedBones.indexOf(i.parent)<0){continue}this.sortedBones.push(i);r++}};a.prototype.cacheFrames=function(t){if(this.cacheFrameRate>0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};a.prototype.setCacheFrame=function(t,e){var a=this.parent.cachedFrames;var r=a.length;a.length+=10;a[r]=t.a;a[r+1]=t.b;a[r+2]=t.c;a[r+3]=t.d;a[r+4]=t.tx;a[r+5]=t.ty;a[r+6]=e.rotation;a[r+7]=e.skew;a[r+8]=e.scaleX;a[r+9]=e.scaleY;return r};a.prototype.getCacheFrame=function(t,e,a){var r=this.parent.cachedFrames;t.a=r[a];t.b=r[a+1];t.c=r[a+2];t.d=r[a+3];t.tx=r[a+4];t.ty=r[a+5];e.rotation=r[a+6];e.skew=r[a+7];e.scaleX=r[a+8];e.scaleY=r[a+9];e.x=t.tx;e.y=t.ty};a.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Same bone: "+t.name);return}this.bones[t.name]=t;this.sortedBones.push(t)};a.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Same slot: "+t.name);return}this.slots[t.name]=t;this.sortedSlots.push(t)};a.prototype.addConstraint=function(t){if(t.name in this.constraints){console.warn("Same constraint: "+t.name);return}this.constraints[t.name]=t};a.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Same skin: "+t.name);return}t.parent=this;this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}if(t.name==="default"){this.defaultSkin=t}};a.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Same animation: "+t.name);return}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};a.prototype.addAction=function(t,e){if(e){this.defaultActions.push(t)}else{this.actions.push(t)}};a.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};a.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};a.prototype.getConstraint=function(t){return t in this.constraints?this.constraints[t]:null};a.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};a.prototype.getMesh=function(t,e,a){var r=this.getSkin(t);if(r===null){return null}return r.getDisplay(e,a)};a.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return a}(t.BaseObject);t.ArmatureData=e;var a=function(e){__extends(a,e);function a(){var a=e!==null&&e.apply(this,arguments)||this;a.transform=new t.Transform;a.userData=null;return a}a.toString=function(){return"[class dragonBones.BoneData]"};a.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.inheritTranslation=false;this.inheritRotation=false;this.inheritScale=false;this.inheritReflection=false;this.type=0;this.length=0;this.name="";this.transform.identity();this.userData=null;this.parent=null};return a}(t.BaseObject);t.BoneData=a;var r=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.vertices=[];return e}e.toString=function(){return"[class dragonBones.SurfaceData]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1;this.segmentX=0;this.segmentY=0;this.vertices.length=0};return e}(a);t.SurfaceData=r;var i=function(e){__extends(a,e);function a(){var t=e!==null&&e.apply(this,arguments)||this;t.color=null;t.userData=null;return t}a.createColor=function(){return new t.ColorTransform};a.toString=function(){return"[class dragonBones.SlotData]"};a.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.blendMode=0;this.displayIndex=0;this.zOrder=0;this.name="";this.color=null;this.userData=null;this.parent=null};a.DEFAULT_COLOR=new t.ColorTransform;return a}(t.BaseObject);t.SlotData=i})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.CanvasData]"};e.prototype._onClear=function(){this.hasBackground=false;this.color=0;this.x=0;this.y=0;this.width=0;this.height=0};return e}(t.BaseObject);t.CanvasData=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.displays={};return e}e.toString=function(){return"[class dragonBones.SkinData]"};e.prototype._onClear=function(){for(var t in this.displays){var e=this.displays[t];for(var a=0,r=e;ai){s|=2}if(en){s|=8}return s};e.rectangleIntersectsSegment=function(t,a,r,i,n,s,o,l,h,f,u){if(h===void 0){h=null}if(f===void 0){f=null}if(u===void 0){u=null}var _=t>n&&ts&&an&&rs&&i=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){return true}}return false};e.prototype.intersectsSegment=function(t,a,r,i,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=this.width*.5;var h=this.height*.5;var f=e.rectangleIntersectsSegment(t,a,r,i,-l,-h,l,h,n,s,o);return f};return e}(e);t.RectangleBoundingBoxData=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.EllipseData]"};e.ellipseIntersectsSegment=function(t,e,a,r,i,n,s,o,l,h,f){if(l===void 0){l=null}if(h===void 0){h=null}if(f===void 0){f=null}var u=s/o;var _=u*u;e*=u;r*=u;var c=a-t;var p=r-e;var m=Math.sqrt(c*c+p*p);var d=c/m;var v=p/m;var y=(i-t)*d+(n-e)*v;var g=y*y;var b=t*t+e*e;var D=s*s;var T=D-b+g;var A=0;if(T>=0){var x=Math.sqrt(T);var P=y-x;var O=y+x;var S=P<0?-1:P<=m?0:1;var E=O<0?-1:O<=m?0:1;var M=S*E;if(M<0){return-1}else if(M===0){if(S===-1){A=2;a=t+O*d;r=(e+O*v)/u;if(l!==null){l.x=a;l.y=r}if(h!==null){h.x=a;h.y=r}if(f!==null){f.x=Math.atan2(r/D*_,a/D);f.y=f.x+Math.PI}}else if(E===1){A=1;t=t+P*d;e=(e+P*v)/u;if(l!==null){l.x=t;l.y=e}if(h!==null){h.x=t;h.y=e}if(f!==null){f.x=Math.atan2(e/D*_,t/D);f.y=f.x+Math.PI}}else{A=3;if(l!==null){l.x=t+P*d;l.y=(e+P*v)/u;if(f!==null){f.x=Math.atan2(l.y/D*_,l.x/D)}}if(h!==null){h.x=t+O*d;h.y=(e+O*v)/u;if(f!==null){f.y=Math.atan2(h.y/D*_,h.x/D)}}}}}return A};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};e.prototype.containsPoint=function(t,e){var a=this.width*.5;if(t>=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){e*=a/r;return Math.sqrt(t*t+e*e)<=a}}return false};e.prototype.intersectsSegment=function(t,a,r,i,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=e.ellipseIntersectsSegment(t,a,r,i,0,0,this.width*.5,this.height*.5,n,s,o);return l};return e}(e);t.EllipseBoundingBoxData=r;var i=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.vertices=[];return e}e.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};e.polygonIntersectsSegment=function(t,e,a,r,i,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(t===a){t=a+1e-6}if(e===r){e=r+1e-6}var l=i.length;var h=t-a;var f=e-r;var u=t*r-e*a;var _=0;var c=i[l-2];var p=i[l-1];var m=0;var d=0;var v=0;var y=0;var g=0;var b=0;for(var D=0;D=c&&E<=T||E>=T&&E<=c)&&(h===0||E>=t&&E<=a||E>=a&&E<=t)){var M=(u*P-f*O)/S;if((M>=p&&M<=A||M>=A&&M<=p)&&(f===0||M>=e&&M<=r||M>=r&&M<=e)){if(s!==null){var B=E-t;if(B<0){B=-B}if(_===0){m=B;d=B;v=E;y=M;g=E;b=M;if(o!==null){o.x=Math.atan2(A-p,T-c)-Math.PI*.5;o.y=o.x}}else{if(Bd){d=B;g=E;b=M;if(o!==null){o.y=Math.atan2(A-p,T-c)-Math.PI*.5}}}_++}else{v=E;y=M;g=E;b=M;_++;if(o!==null){o.x=Math.atan2(A-p,T-c)-Math.PI*.5;o.y=o.x}break}}}c=T;p=A}if(_===1){if(n!==null){n.x=v;n.y=y}if(s!==null){s.x=v;s.y=y}if(o!==null){o.y=o.x+Math.PI}}else if(_>1){_++;if(n!==null){n.x=v;n.y=y}if(s!==null){s.x=g;s.y=b}}return _};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=2;this.x=0;this.y=0;this.vertices.length=0};e.prototype.containsPoint=function(t,e){var a=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var r=0,i=this.vertices.length,n=i-2;r=e||s=e){var l=this.vertices[n];var h=this.vertices[r];if((e-o)*(l-h)/(s-o)+h0){return}this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);var e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=e;for(var a=0,r=this.cacheFrames.length;a=0};e.prototype.addBoneMask=function(t,e,a){if(a===void 0){a=true}var r=t.getBone(e);if(r===null){return}if(this.boneMask.indexOf(e)<0){this.boneMask.push(e)}if(a){for(var i=0,n=t.getBones();i=0){this.boneMask.splice(r,1)}if(a){var i=t.getBone(e);if(i!==null){if(this.boneMask.length>0){for(var n=0,s=t.getBones();n=0&&i.contains(o)){this.boneMask.splice(l,1)}}}else{for(var h=0,f=t.getBones();he._zOrder?1:-1};a.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=n){continue}var o=a[s];var l=this.getSlot(o.name);if(l!==null){l._setZorder(i)}}this._slotsDirty=true;this._zOrderDirty=!r}};a.prototype._addBone=function(t){if(this._bones.indexOf(t)<0){this._bones.push(t)}};a.prototype._addSlot=function(t){if(this._slots.indexOf(t)<0){this._slots.push(t)}};a.prototype._addConstraint=function(t){if(this._constraints.indexOf(t)<0){this._constraints.push(t)}};a.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};a.prototype.dispose=function(){if(this._armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};a.prototype.init=function(e,a,r,i){if(this._armatureData!==null){return}this._armatureData=e;this._animation=t.BaseObject.borrowObject(t.Animation);this._proxy=a;this._display=r;this._dragonBones=i;this._proxy.dbInit(this);this._animation.init(this);this._animation.animations=this._armatureData.animations};a.prototype.advanceTime=function(t){if(this._lockUpdate){return}if(this._armatureData===null){console.warn("The armature has been disposed.");return}else if(this._armatureData.parent===null){console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear().");return}var e=this._cacheFrameIndex;this._animation.advanceTime(t);if(this._slotsDirty){this._slotsDirty=false;this._slots.sort(a._onSortSlots)}if(this._cacheFrameIndex<0||this._cacheFrameIndex!==e){var r=0,i=0;for(r=0,i=this._bones.length;r0){this._lockUpdate=true;for(var n=0,s=this._actions;n0){var a=this.getBone(t);if(a!==null){a.invalidUpdate();if(e){for(var r=0,i=this._slots;r0){if(i!==null||n!==null){if(i!==null){var T=o?i.y-e:i.x-t;if(T<0){T=-T}if(d===null||Th){h=T;_=n.x;c=n.y;v=b;if(s!==null){m=s.y}}}}else{d=b;break}}}if(d!==null&&i!==null){i.x=f;i.y=u;if(s!==null){s.x=p}}if(v!==null&&n!==null){n.x=_;n.y=c;if(s!==null){s.y=m}}return d};a.prototype.getBone=function(t){for(var e=0,a=this._bones;e=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else{if(this._hasConstraint){for(var a=0,r=this._armature._constraints;a=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var n=0,s=this._armature._constraints;n=0;if(this._localDirty){this._updateGlobalTransformMatrix(o)}if(o&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};a.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};a.prototype.invalidUpdate=function(){this._transformDirty=true};a.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};Object.defineProperty(a.prototype,"boneData",{get:function(){return this._boneData},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;for(var e=0,a=this._armature.getSlots();e=n){return this.globalTransformMatrix}i=a>this._kX*(t+n)+d;p=((o*(l+1)+o*2+l+c)*2+(i?1:0))*7;if(this._matrixCahce[p]>0){y.copyFromArray(v,p+1)}else{var g=c*(h+2);var b=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[2]-(l-c)*b;var A=this._hullCache[3]-(l-c)*D;var x=this._vertices;if(i){this._getAffineTransform(-n,d+u,r-n,u,x[g+h+2],x[g+h+3],T+b,A+D,x[g],x[g+1],e._helpTransform,y,true)}else{this._getAffineTransform(-r,d,r-n,u,T,A,x[g],x[g+1],T+b,A+D,e._helpTransform,y,false)}v[p]=1;v[p+1]=y.a;v[p+2]=y.b;v[p+3]=y.c;v[p+4]=y.d;v[p+5]=y.tx;v[p+6]=y.ty}}else if(t>=n){if(a<-n||a>=n){return this.globalTransformMatrix}i=a>this._kX*(t-r)+d;p=((o*(l+1)+o+c)*2+(i?1:0))*7;if(this._matrixCahce[p]>0){y.copyFromArray(v,p+1)}else{var g=(c+1)*(h+2)-2;var b=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[0]+c*b;var A=this._hullCache[1]+c*D;var x=this._vertices;if(i){this._getAffineTransform(r,d+u,r-n,u,T+b,A+D,x[g+h+2],x[g+h+3],T,A,e._helpTransform,y,true)}else{this._getAffineTransform(n,d,r-n,u,x[g],x[g+1],T,A,x[g+h+2],x[g+h+3],e._helpTransform,y,false)}v[p]=1;v[p+1]=y.a;v[p+2]=y.b;v[p+3]=y.c;v[p+4]=y.d;v[p+5]=y.tx;v[p+6]=y.ty}}else if(a<-n){if(t<-n||t>=n){return this.globalTransformMatrix}i=a>this._kY*(t-m-f)-r;p=(o*(l+1)+_*2+(i?1:0))*7;if(this._matrixCahce[p]>0){y.copyFromArray(v,p+1)}else{var g=_*2;var b=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[8]+_*b;var A=this._hullCache[9]+_*D;var x=this._vertices;if(i){this._getAffineTransform(m+f,-n,f,r-n,x[g+2],x[g+3],x[g],x[g+1],T+b,A+D,e._helpTransform,y,true)}else{this._getAffineTransform(m,-r,f,r-n,T,A,T+b,A+D,x[g],x[g+1],e._helpTransform,y,false)}v[p]=1;v[p+1]=y.a;v[p+2]=y.b;v[p+3]=y.c;v[p+4]=y.d;v[p+5]=y.tx;v[p+6]=y.ty}}else if(a>=n){if(t<-n||t>=n){return this.globalTransformMatrix}i=a>this._kY*(t-m-f)+n;p=((o*(l+1)+o+l+c)*2+(i?1:0))*7;if(this._matrixCahce[p]>0){y.copyFromArray(v,p+1)}else{var g=l*(h+2)+_*2;var b=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[6]-(o-_)*b;var A=this._hullCache[7]-(o-_)*D;var x=this._vertices;if(i){this._getAffineTransform(m+f,r,f,r-n,T+b,A+D,T,A,x[g+2],x[g+3],e._helpTransform,y,true)}else{this._getAffineTransform(m,n,f,r-n,x[g],x[g+1],x[g+2],x[g+3],T,A,e._helpTransform,y,false)}v[p]=1;v[p+1]=y.a;v[p+2]=y.b;v[p+3]=y.c;v[p+4]=y.d;v[p+5]=y.tx;v[p+6]=y.ty}}else{i=a>this._k*(t-m-f)+d;p=((o*c+_)*2+(i?1:0))*7;if(this._matrixCahce[p]>0){y.copyFromArray(v,p+1)}else{var g=_*2+c*(h+2);var x=this._vertices;if(i){this._getAffineTransform(m+f,d+u,f,u,x[g+h+4],x[g+h+5],x[g+h+2],x[g+h+3],x[g+2],x[g+3],e._helpTransform,y,true)}else{this._getAffineTransform(m,d,f,u,x[g],x[g+1],x[g+2],x[g+3],x[g+h+2],x[g+h+3],e._helpTransform,y,false)}v[p]=1;v[p+1]=y.a;v[p+2]=y.b;v[p+3]=y.c;v[p+4]=y.d;v[p+5]=y.tx;v[p+6]=y.ty}}return y};e.prototype.init=function(e,a){if(this._boneData!==null){return}t.prototype.init.call(this,e,a);var r=e.segmentX;var i=e.segmentY;var n=e.vertices.length;var s=1e3;var o=200;this._dX=o*2/r;this._dY=o*2/i;this._k=-this._dY/this._dX;this._kX=-this._dY/(s-o);this._kY=-(s-o)/this._dX;this._vertices.length=n;this._deformVertices.length=n;this._matrixCahce.length=(r*i+r*2+i*2)*2*7;this._hullCache.length=10;for(var l=0;l=0&&this._cachedFrameIndices!==null){var a=this._cachedFrameIndices[t];if(a>=0&&this._cachedFrameIndex===a){this._transformDirty=false}else if(a>=0){this._transformDirty=true;this._cachedFrameIndex=a}else{if(this._hasConstraint){for(var r=0,i=this._armature._constraints;r=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var s=0,o=this._armature._constraints;s=0;if(this._localDirty){this._updateGlobalTransformMatrix(f)}if(f&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}var u=1e3;var _=200;var c=2*this.global.x;var p=2*this.global.y;var m=e._helpPoint;this.globalTransformMatrix.transformPoint(u,-_,m);this._hullCache[0]=m.x;this._hullCache[1]=m.y;this._hullCache[2]=c-m.x;this._hullCache[3]=p-m.y;this.globalTransformMatrix.transformPoint(0,this._dY,m,true);this._hullCache[4]=m.x;this._hullCache[5]=m.y;this.globalTransformMatrix.transformPoint(_,u,m);this._hullCache[6]=m.x;this._hullCache[7]=m.y;this._hullCache[8]=c-m.x;this._hullCache[9]=p-m.y;this.globalTransformMatrix.transformPoint(this._dX,0,m,true);this._hullCache[10]=m.x;this._hullCache[11]=m.y}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};return e}(t.Bone);t.Surface=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(a,e);function a(){var a=e!==null&&e.apply(this,arguments)||this;a._localMatrix=new t.Matrix;a._colorTransform=new t.ColorTransform;a._displayDatas=[];a._displayList=[];a._deformVertices=null;a._rawDisplay=null;a._meshDisplay=null;return a}a.prototype._onClear=function(){e.prototype._onClear.call(this);var a=[];for(var r=0,i=this._displayList;r=0){if(this._rawDisplayDatas!==null){n=this._displayIndex=0&&this._displayIndex=0&&this._rawDisplayDatas!==null){var s=this._displayIndex0){for(var o=0,l=n;o0){if(this._displayList.length!==e.length){this._displayList.length=e.length}for(var a=0,r=e.length;a0){this._displayList.length=0}if(this._displayIndex>=0&&this._displayIndex=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else if(this._transformDirty||this._parent._childrenTransformDirty){this._transformDirty=true;this._cachedFrameIndex=-1}else if(this._cachedFrameIndex>=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}else if(this._transformDirty||this._parent._childrenTransformDirty){t=-1;this._transformDirty=true;this._cachedFrameIndex=-1}if(this._display===null){return}if(this._visibleDirty){this._visibleDirty=false;this._updateVisible()}if(this._blendModeDirty){this._blendModeDirty=false;this._updateBlendMode()}if(this._colorDirty){this._colorDirty=false;this._updateColor()}if(this._deformVertices!==null&&this._deformVertices.verticesData!==null&&this._display===this._meshDisplay){var a=this._deformVertices.verticesData.weight!==null;var r=this._parent._boneData.type!==0;if(this._deformVertices.verticesDirty||a&&this._deformVertices.isBonesUpdate()||r&&this._parent._childrenTransformDirty){this._deformVertices.verticesDirty=false;this._updateMesh()}if(a||r){return}}if(this._transformDirty){this._transformDirty=false;if(this._cachedFrameIndex<0){var i=t>=0;this._updateGlobalTransformMatrix(i);if(i&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}this._updateTransform()}};a.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._transformDirty=false;this._updateGlobalTransformMatrix(false)}};a.prototype.replaceDisplayData=function(t,e){if(e===void 0){e=-1}if(e<0){if(this._displayIndex<0){e=0}else{e=this._displayIndex}}if(this._displayDatas.length<=e){this._displayDatas.length=e+1;for(var a=0,r=this._displayDatas.length;a0){if(l===1||l===2){if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n);if(s!==null){s.x=n.x;s.y=n.y}}else if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}else{if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}if(o!==null){this.globalTransformMatrix.transformPoint(Math.cos(o.x),Math.sin(o.x),a._helpPoint,true);o.x=Math.atan2(a._helpPoint.y,a._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(o.y),Math.sin(o.y),a._helpPoint,true);o.y=Math.atan2(a._helpPoint.y,a._helpPoint.x)}}return l};a.prototype.invalidUpdate=function(){this._displayDirty=true;this._transformDirty=true};Object.defineProperty(a.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;this._updateVisible()},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){if(this._setDisplayIndex(t)){this.update(-1)}},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"name",{get:function(){return this._slotData.name},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var a=this._displayList.concat();var r=new Array;if(this._setDisplayList(e)){this.update(-1)}for(var i=0,n=a;id){continue}var T=0;for(;;b++){var A=v[b];if(m>A){continue}if(b===0){T=m/A}else{var x=v[b-1];T=(m-x)/(A-x)}break}if(b!==p){p=b;if(f&&b===c){this._computeVertices(_-4,4,0,u);this._computeVertices(0,4,4,u)}else{this._computeVertices(b*6+2,8,0,u)}}this.addCurvePosition(T,u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],l,g,a)}return}if(f){_+=2;u.length=o;this._computeVertices(2,_-4,0,u);this._computeVertices(0,2,_-4,u);u[_-2]=u[0];u[_-1]=u[1]}else{c--;_-=4;u.length=_;this._computeVertices(2,_,0,u)}var P=new Array(c);d=0;var O=u[0],S=u[1],E=0,M=0,B=0,C=0,w=0,I=0;var F,N,R,k,j,L,V,U;for(var y=0,Y=2;yd){continue}for(;;b++){var W=P[b];if(G>W)continue;if(b===0)G/=W;else{var z=P[b-1];G=(G-z)/(W-z)}break}if(b!==p){p=b;var K=b*6;O=u[K];S=u[K+1];E=u[K+2];M=u[K+3];B=u[K+4];C=u[K+5];w=u[K+6];I=u[K+7];F=(O-E*2+B)*.03;N=(S-M*2+C)*.03;R=((E-B)*3-O+w)*.006;k=((M-C)*3-S+I)*.006;j=F*2+R;L=N*2+k;V=(E-O)*.3+F+R*.16666667;U=(M-S)*.3+N+k*.16666667;H=Math.sqrt(V*V+U*U);X[0]=H;for(K=1;K<8;K++){V+=j;U+=L;j+=R;L+=k;H+=Math.sqrt(V*V+U*U);X[K]=H}V+=j;U+=L;H+=Math.sqrt(V*V+U*U);X[8]=H;V+=j+R;U+=L+k;H+=Math.sqrt(V*V+U*U);X[9]=H;$=0}G*=H;for(;;$++){var Z=X[$];if(G>Z)continue;if($===0)G/=Z;else{var z=X[$-1];G=$+(G-z)/(Z-z)}break}this.addCurvePosition(G*.1,O,S,E,M,B,C,w,I,l,g,a)}};a.prototype.addCurvePosition=function(t,e,a,r,i,n,s,o,l,h,f,u){if(t===0){h[f]=e;h[f+1]=a;h[f+2]=0;return}if(t===1){h[f]=o;h[f+1]=l;h[f+2]=0;return}var _=1-t;var c=_*_;var p=t*t;var m=c*_;var d=c*t*3;var v=_*p*3;var y=t*p;var g=m*e+d*r+v*n+y*o;var b=m*a+d*i+v*s+y*l;h[f]=g;h[f+1]=b;if(u){h[f+2]=Math.atan2(b-(m*a+d*i+v*s),g-(m*e+d*r+v*n))}else{h[f+2]=0}};a.prototype.init=function(t,e){this._constraintData=t;this._armature=e;var a=t;this.pathOffset=a.pathDisplayData.vertices.offset;this.position=a.position;this.spacing=a.spacing;this.rotateOffset=a.rotateOffset;this.rotateMix=a.rotateMix;this.translateMix=a.translateMix;this._root=this._armature.getBone(a.root.name);this._target=this._armature.getBone(a.target.name);this._pathSlot=this._armature.getSlot(a.pathSlot.name);for(var r=0,i=a.bones.length;r0?t.Transform.DEG_RAD:-t.Transform.DEG_RAD}}var B=this.rotateMix;var C=this.translateMix;for(var v=0,w=3;v0){var k=D.a,j=D.b,L=D.c,V=D.d,U=void 0,Y=void 0,X=void 0;if(_){U=P[w-1]}else{U=Math.atan2(F,I)}U-=Math.atan2(j,k);if(M){Y=Math.cos(U);X=Math.sin(U);var H=g._boneData.length;S+=(H*(Y*k-X*j)-I)*B;E+=(H*(X*k+Y*j)-F)*B}else{U+=O}if(U>t.Transform.PI){U-=t.Transform.PI_D}else if(U<-t.Transform.PI){U+=t.Transform.PI_D}U*=B;Y=Math.cos(U);X=Math.sin(U);D.a=Y*k-X*j;D.b=X*k+Y*j;D.c=Y*L-X*V;D.d=X*L+Y*V}g.global.fromMatrix(D)}this.dirty=false};a.prototype.invalidUpdate=function(){};return a}(e);t.PathConstraint=r})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t){if(t===void 0){t=0}this.time=0;this.timeScale=1;this._systemTime=0;this._animatebles=[];this._clock=null;this.time=t;this._systemTime=(new Date).getTime()*.001}t.prototype.advanceTime=function(t){if(t!==t){t=0}var e=Date.now()*.001;if(t<0){t=e-this._systemTime}this._systemTime=e;if(this.timeScale!==1){t*=this.timeScale}if(t===0){return}if(t<0){this.time-=t}else{this.time+=t}var a=0,r=0,i=this._animatebles.length;for(;a0){this._animatebles[a-r]=n;this._animatebles[a]=null}n.advanceTime(t)}else{r++}}if(r>0){i=this._animatebles.length;for(;a=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&a._subFadeState>0){this._armature._dragonBones.bufferObject(a);this._animationStates.length=0;this._lastAnimationState=null}else{var r=a._animationData;var i=r.cacheFrameRate;if(this._animationDirty&&i>0){this._animationDirty=false;for(var n=0,s=this._armature.getBones();n0){var _=u[0];if(_!==null){if(_.parent===this._armature.armatureData.defaultSkin){f._cachedFrameIndices=r.getSlotCachedFrameIndices(f.name);continue}}}f._cachedFrameIndices=null}}a.advanceTime(t,i)}}else if(e>1){for(var c=0,p=0;c0&&a._subFadeState>0){p++;this._armature._dragonBones.bufferObject(a);this._animationDirty=true;if(this._lastAnimationState===a){this._lastAnimationState=null}}else{if(p>0){this._animationStates[c-p]=a}a.advanceTime(t,0)}if(c===e-1&&p>0){this._animationStates.length-=p;if(this._lastAnimationState===null&&this._animationStates.length>0){this._lastAnimationState=this._animationStates[this._animationStates.length-1]}}}this._armature._cacheFrameIndex=-1}else{this._armature._cacheFrameIndex=-1}};a.prototype.reset=function(){for(var t=0,e=this._animationStates;t1){if(e.position<0){e.position%=r.duration;e.position=r.duration-e.position}else if(e.position===r.duration){e.position-=1e-6}else if(e.position>r.duration){e.position%=r.duration}if(e.duration>0&&e.position+e.duration>r.duration){e.duration=r.duration-e.position}if(e.playTimes<0){e.playTimes=r.playTimes}}else{e.playTimes=1;e.position=0;if(e.duration>0){e.duration=0}}if(e.duration===0){e.duration=-1}this._fadeOut(e);var o=t.BaseObject.borrowObject(t.AnimationState);o.init(this._armature,r,e);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var l=false;for(var h=0,f=this._animationStates.length;hthis._animationStates[h].layer){l=true;this._animationStates.splice(h,0,o);break}else if(h!==f-1&&o.layer>this._animationStates[h+1].layer){l=true;this._animationStates.splice(h+1,0,o);break}}if(!l){this._animationStates.push(o)}}else{this._animationStates.push(o)}for(var u=0,_=this._armature.getSlots();u<_.length;u++){var c=_[u];var p=c.childArmature;if(p!==null&&p.inheritAnimation&&p.animation.hasAnimation(a)&&p.animation.getState(a)===null){p.animation.fadeIn(a)}}var m=false;for(var d in r.animationTimelines){if(!this._lockUpdate){m=true;this._lockUpdate=true}var v=this.fadeIn(d,e.fadeInTime,1,o.layer,null,0);if(v!==null){v.resetToPose=false;v._parent=o;v.stop()}}if(m){this._lockUpdate=false}if(!this._lockUpdate){if(e.fadeInTime<=0){this._armature.advanceTime(0)}this._lastAnimationState=o}return o};a.prototype.play=function(t,e){if(t===void 0){t=null}if(e===void 0){e=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t!==null?t:"";if(t!==null&&t.length>0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var a=this._armature.armatureData.defaultAnimation;if(a!==null){this._animationConfig.animation=a.name;this.playConfig(this._animationConfig)}}else if(!this._lastAnimationState.isPlaying&&!this._lastAnimationState.isCompleted){this._lastAnimationState.play()}else{this._animationConfig.animation=this._lastAnimationState.name;this.playConfig(this._animationConfig)}return this._lastAnimationState};a.prototype.fadeIn=function(t,e,a,r,i,n){if(e===void 0){e=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(i===void 0){i=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=i!==null?i:"";return this.playConfig(this._animationConfig)};a.prototype.gotoAndPlayByTime=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};a.prototype.gotoAndPlayByFrame=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.duration*e/r.frameCount}return this.playConfig(this._animationConfig)};a.prototype.gotoAndPlayByProgress=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};a.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByTime(t,e,1);if(a!==null){a.stop()}return a};a.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByFrame(t,e,1);if(a!==null){a.stop()}return a};a.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByProgress(t,e,1);if(a!==null){a.stop()}return a};a.prototype.getState=function(t){var e=this._animationStates.length;while(e--){var a=this._animationStates[e];if(a.name===t){return a}}return null};a.prototype.hasAnimation=function(t){return t in this._animations};a.prototype.getStates=function(){return this._animationStates};Object.defineProperty(a.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animations",{get:function(){return this._animations},set:function(t){if(this._animations===t){return}this._animationNames.length=0;for(var e in this._animations){delete this._animations[e]}for(var e in t){this._animationNames.push(e);this._animations[e]=t[e]}},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});a.prototype.gotoAndPlay=function(t,e,a,r,i,n,s,o,l){if(e===void 0){e=-1}if(a===void 0){a=-1}if(r===void 0){r=-1}if(i===void 0){i=0}if(n===void 0){n=null}if(s===void 0){s=3}if(o===void 0){o=true}if(l===void 0){l=true}console.warn("Deprecated.");o;l;this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.fadeOutMode=s;this._animationConfig.playTimes=r;this._animationConfig.layer=i;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=n!==null?n:"";var h=this._animations[t];if(h&&a>0){this._animationConfig.timeScale=h.duration/a}return this.playConfig(this._animationConfig)};a.prototype.gotoAndStop=function(t,e){if(e===void 0){e=0}console.warn("Deprecated.");return this.gotoAndStopByTime(t,e)};Object.defineProperty(a.prototype,"animationList",{get:function(){console.warn("Deprecated.");return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animationDataList",{get:function(){console.warn("Deprecated.");var t=[];for(var e=0,a=this._animationNames.length;e0;if(this._subFadeState<0){this._subFadeState=0;var r=a?t.EventObject.FADE_OUT:t.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=t.BaseObject.borrowObject(t.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}if(e<0){e=-e}this._fadeTime+=e;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=a?0:1}else if(this._fadeTime>0){this._fadeProgress=a?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=a?1:0}if(this._subFadeState>0){if(!a){this._playheadState|=1;this._fadeState=0}var r=a?t.EventObject.FADE_OUT_COMPLETE:t.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=t.BaseObject.borrowObject(t.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}};i.prototype.init=function(e,a,r){if(this._armature!==null){return}this._armature=e;this._animationData=a;this.resetToPose=r.resetToPose;this.additiveBlending=r.additiveBlending;this.displayControl=r.displayControl;this.actionEnabled=r.actionEnabled;this.layer=r.layer;this.playTimes=r.playTimes;this.timeScale=r.timeScale;this.fadeTotalTime=r.fadeInTime;this.autoFadeOutTime=r.autoFadeOutTime;this.weight=r.weight;this.name=r.name.length>0?r.name:r.animation;this.group=r.group;if(r.pauseFadeIn){this._playheadState=2}else{this._playheadState=3}if(r.duration<0){this._position=0;this._duration=this._animationData.duration;if(r.position!==0){if(this.timeScale>=0){this._time=r.position}else{this._time=r.position-this._duration}}else{this._time=0}}else{this._position=r.position;this._duration=r.duration;this._time=0}if(this.timeScale<0&&this._time===0){this._time=-1e-6}if(this.fadeTotalTime<=0){this._fadeProgress=.999999}if(r.boneMask.length>0){this._boneMask.length=r.boneMask.length;for(var i=0,n=this._boneMask.length;i0;var i=true;var n=true;var s=this._time;this._weightResult=this.weight*this._fadeProgress;if(this._parent!==null){this._weightResult*=this._parent._weightResult/this._parent._fadeProgress}if(this._actionTimeline.playState<=0){this._actionTimeline.update(s)}if(r){var o=a*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*o)/o}if(this._zOrderTimeline!==null&&this._zOrderTimeline.playState<=0){this._zOrderTimeline.update(s)}if(r){var l=Math.floor(this._actionTimeline.currentTime*a);if(this._armature._cacheFrameIndex===l){i=false;n=false}else{this._armature._cacheFrameIndex=l;if(this._animationData.cachedFrames[l]){n=false}else{this._animationData.cachedFrames[l]=true}}}if(i){if(n){for(var h=0,f=this._boneTimelines.length;h0){this._subFadeState=0;if(this._poseTimelines.length>0){for(var p=0,m=this._poseTimelines;p0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};i.prototype.play=function(){this._playheadState=3};i.prototype.stop=function(){this._playheadState&=1};i.prototype.fadeOut=function(t,e){if(e===void 0){e=true}if(t<0){t=0}if(e){this._playheadState&=2}if(this._fadeState>0){if(t>this.fadeTotalTime-this._fadeTime){return}}else{this._fadeState=1;this._subFadeState=-1;if(t<=0||this._fadeProgress<=0){this._fadeProgress=1e-6}for(var a=0,r=this._boneTimelines;a1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};i.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};i.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var a=this._armature.getBone(t);if(a===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var r=0,i=this._armature.getBones();r=0){this._boneMask.splice(a,1)}if(e){var r=this._armature.getBone(t);if(r!==null){var i=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=i;n=0&&r.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,f=i;h0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"currentTime",{get:function(){return this._actionTimeline.currentTime},set:function(t){var e=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if(t<0||this._duration0&&e===this.playTimes-1&&t===this._duration){t=this._duration-1e-6}if(this._time===t){return}this._time=t;this._actionTimeline.setCurrentTime(this._time);if(this._zOrderTimeline!==null){this._zOrderTimeline.playState=-1}for(var a=0,r=this._boneTimelines;a0){if(this.layer!==e){if(this.layerWeight>=this.leftWeight){this.leftWeight=0;return 0}else{this.layer=e;this.leftWeight-=this.layerWeight;this.layerWeight=0}}}else{return 0}t*=this.leftWeight;this.layerWeight+=t;this.blendWeight=t;return 2}this.dirty=true;this.layer=e;this.layerWeight=t;this.leftWeight=1;this.blendWeight=t;return 1};t.prototype.clear=function(){this.dirty=false;this.layer=0;this.leftWeight=0;this.layerWeight=0;this.blendWeight=0};return t}();t.BlendState=r})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){this.playState=-1;this.currentPlayTimes=-1;this.currentTime=-1;this._tweenState=0;this._frameRate=0;this._frameValueOffset=0;this._frameCount=0;this._frameOffset=0;this._frameIndex=-1;this._frameRateR=0;this._position=0;this._duration=0;this._timeScale=1;this._timeOffset=0;this._dragonBonesData=null;this._animationData=null;this._timelineData=null;this._armature=null;this._animationState=null;this._actionTimeline=null;this._frameArray=null;this._frameIntArray=null;this._frameFloatArray=null;this._timelineArray=null;this._frameIndices=null};e.prototype._setCurrentTime=function(t){var e=this.playState;var a=this.currentPlayTimes;var r=this.currentTime;if(this._actionTimeline!==null&&this._frameCount<=1){this.playState=this._actionTimeline.playState>=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var i=this._animationState.playTimes;var n=i*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(i>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=i;if(t<0){this.currentTime=0}else{this.currentTime=this._duration+1e-6}}else{if(this.playState!==0&&this._animationState._playheadState===3){this.playState=0}if(t<0){t=-t;this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=this._duration-t%this._duration}else{this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=t%this._duration}}this.currentTime+=this._position}else{this.playState=this._actionTimeline.playState;this.currentPlayTimes=this._actionTimeline.currentPlayTimes;this.currentTime=this._actionTimeline.currentTime}if(this.currentPlayTimes===a&&this.currentTime===r){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==a){this._frameIndex=-1}return true};e.prototype.init=function(t,e,a){this._armature=t;this._animationState=e;this._timelineData=a;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._animationData=this._animationState._animationData;this._frameRate=this._animationData.parent.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;this._dragonBonesData=this._animationData.parent.parent;if(this._timelineData!==null){this._frameIntArray=this._dragonBonesData.frameIntArray;this._frameFloatArray=this._dragonBonesData.frameFloatArray;this._frameArray=this._dragonBonesData.frameArray;this._timelineArray=this._dragonBonesData.timelineArray;this._frameIndices=this._dragonBonesData.frameIndices;this._frameCount=this._timelineArray[this._timelineData.offset+2];this._frameValueOffset=this._timelineArray[this._timelineData.offset+4];this._timeScale=100/this._timelineArray[this._timelineData.offset+0];this._timeOffset=this._timelineArray[this._timelineData.offset+1]*.01}};e.prototype.fadeOut=function(){};e.prototype.update=function(t){if(this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var a=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==a){this._frameIndex=a;this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+this._frameIndex];this._onArriveAtFrame()}}else if(this._frameIndex<0){this._frameIndex=0;if(this._timelineData!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5]}this._onArriveAtFrame()}if(this._tweenState!==0){this._onUpdateFrame()}}};return e}(t.BaseObject);t.TimelineState=e;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,a){var r=e;switch(t){case 3:r=Math.pow(e,2);break;case 4:r=1-Math.pow(1-e,2);break;case 5:r=.5*(1-Math.cos(e*Math.PI));break}return(r-e)*a+e};e._getEasingCurveValue=function(t,e,a,r){if(t<=0){return 0}else if(t>=1){return 1}var i=a+1;var n=Math.floor(t*i);var s=n===0?0:e[r+n-1];var o=n===i-1?1e4:e[r+n];return(s+(o-s)*(t*i-n))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenProgress=0;this._tweenEasing=0};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){this._frameDurationR=1/e}else{this._frameDurationR=0}}}else{this._tweenState=1}};e.prototype._onUpdateFrame=function(){if(this._tweenState===2){this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR;if(this._tweenType===2){this._tweenProgress=e._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+3)}else if(this._tweenType!==1){this._tweenProgress=e._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing)}}else{this._tweenProgress=0}};return e}(e);t.TweenTimelineState=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){t.prototype._onClear.call(this);this.bone=null;this.bonePose=null};e.prototype.blend=function(t){var e=this.bone._blendState.blendWeight;var a=this.bone.animationPose;var r=this.bonePose.result;if(t===2){a.x+=r.x*e;a.y+=r.y*e;a.rotation+=r.rotation*e;a.skew+=r.skew*e;a.scaleX+=(r.scaleX-1)*e;a.scaleY+=(r.scaleY-1)*e}else if(e!==1){a.x=r.x*e;a.y=r.y*e;a.rotation=r.rotation*e;a.skew=r.skew*e;a.scaleX=(r.scaleX-1)*e+1;a.scaleY=(r.scaleY-1)*e+1}else{a.x=r.x;a.y=r.y;a.rotation=r.rotation;a.skew=r.skew;a.scaleX=r.scaleX;a.scaleY=r.scaleY}if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){this.bone._transformDirty=true}};return e}(a);t.BoneTimelineState=r;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){t.prototype._onClear.call(this);this.slot=null};return e}(a);t.SlotTimelineState=i;var n=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){t.prototype._onClear.call(this);this.constraint=null};return e}(a);t.ConstraintTimelineState=n})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(a,e);function a(){return e!==null&&e.apply(this,arguments)||this}a.toString=function(){return"[class dragonBones.ActionTimelineState]"};a.prototype._onCrossFrame=function(e){var a=this._armature.eventDispatcher;if(this._animationState.actionEnabled){var r=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+e];var i=this._frameArray[r+1];var n=this._animationData.parent.actions;for(var s=0;s0){if(n.hasDBEventListener(t.EventObject.COMPLETE)){h=t.BaseObject.borrowObject(t.EventObject);h.type=t.EventObject.COMPLETE;h.armature=this._armature;h.animationState=this._animationState}}}if(this._frameCount>1){var f=this._timelineData;var u=Math.floor(this.currentTime*this._frameRate);var _=this._frameIndices[f.frameIndicesOffset+u];if(this._frameIndex!==_){var c=this._frameIndex;this._frameIndex=_;if(this._timelineArray!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[f.offset+5+this._frameIndex];if(o){if(c<0){var p=Math.floor(i*this._frameRate);c=this._frameIndices[f.frameIndicesOffset+p];if(this.currentPlayTimes===r){if(c===_){c=-1}}}while(c>=0){var m=this._animationData.frameOffset+this._timelineArray[f.offset+5+c];var d=this._frameArray[m]/this._frameRate;if(this._position<=d&&d<=this._position+this._duration){this._onCrossFrame(c)}if(l!==null&&c===0){this._armature._dragonBones.bufferEvent(l);l=null}if(c>0){c--}else{c=this._frameCount-1}if(c===_){break}}}else{if(c<0){var p=Math.floor(i*this._frameRate);c=this._frameIndices[f.frameIndicesOffset+p];var m=this._animationData.frameOffset+this._timelineArray[f.offset+5+c];var d=this._frameArray[m]/this._frameRate;if(this.currentPlayTimes===r){if(i<=d){if(c>0){c--}else{c=this._frameCount-1}}else if(c===_){c=-1}}}while(c>=0){if(c=0){var t=this._frameArray[this._frameOffset+1];if(t>0){this._armature._sortZOrder(this._frameArray,this._frameOffset+2)}else{this._armature._sortZOrder(null,0)}}};e.prototype._onUpdateFrame=function(){};return e}(t.TimelineState);t.ZOrderTimelineState=a;var r=function(e){__extends(a,e);function a(){return e!==null&&e.apply(this,arguments)||this}a.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};a.prototype._onArriveAtFrame=function(){e.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*6;var a=this._armature._armatureData.scale;var r=this._frameFloatArray;var i=this.bonePose.current;var n=this.bonePose.delta;i.x=r[t++]*a;i.y=r[t++]*a;i.rotation=r[t++];i.skew=r[t++];i.scaleX=r[t++];i.scaleY=r[t++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){t=this._animationData.frameFloatOffset+this._frameValueOffset}n.x=r[t++]*a-i.x;n.y=r[t++]*a-i.y;n.rotation=r[t++]-i.rotation;n.skew=r[t++]-i.skew;n.scaleX=r[t++]-i.scaleX;n.scaleY=r[t++]-i.scaleY}else{n.x=0;n.y=0;n.rotation=0;n.skew=0;n.scaleX=0;n.scaleY=0}}else{var i=this.bonePose.current;var n=this.bonePose.delta;i.x=0;i.y=0;i.rotation=0;i.skew=0;i.scaleX=1;i.scaleY=1;n.x=0;n.y=0;n.rotation=0;n.skew=0;n.scaleX=0;n.scaleY=0}};a.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current;var a=this.bonePose.delta;var r=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}r.x=t.x+a.x*this._tweenProgress;r.y=t.y+a.y*this._tweenProgress;r.rotation=t.rotation+a.rotation*this._tweenProgress;r.skew=t.skew+a.skew*this._tweenProgress;r.scaleX=t.scaleX+a.scaleX*this._tweenProgress;r.scaleY=t.scaleY+a.scaleY*this._tweenProgress};a.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation);e.skew=t.Transform.normalizeRadian(e.skew)};return a}(t.BoneTimelineState);t.BoneAllTimelineState=r;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.BoneTranslateTimelineState]"};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*2;var a=this._armature._armatureData.scale;var r=this._frameFloatArray;var i=this.bonePose.current;var n=this.bonePose.delta;i.x=r[e++]*a;i.y=r[e++]*a;if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){e=this._animationData.frameFloatOffset+this._frameValueOffset}n.x=r[e++]*a-i.x;n.y=r[e++]*a-i.y}else{n.x=0;n.y=0}}else{var i=this.bonePose.current;var n=this.bonePose.delta;i.x=0;i.y=0;n.x=0;n.y=0}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);var e=this.bonePose.current;var a=this.bonePose.delta;var r=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}r.x=e.x+a.x*this._tweenProgress;r.y=e.y+a.y*this._tweenProgress};return e}(t.BoneTimelineState);t.BoneTranslateTimelineState=i;var n=function(e){__extends(a,e);function a(){return e!==null&&e.apply(this,arguments)||this}a.toString=function(){return"[class dragonBones.BoneRotateTimelineState]"};a.prototype._onArriveAtFrame=function(){e.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var a=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*2;var r=this._frameFloatArray;var i=this.bonePose.current;var n=this.bonePose.delta;i.rotation=r[a++];i.skew=r[a++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){a=this._animationData.frameFloatOffset+this._frameValueOffset;n.rotation=t.Transform.normalizeRadian(r[a++]-i.rotation)}else{n.rotation=r[a++]-i.rotation}n.skew=r[a++]-i.skew}else{n.rotation=0;n.skew=0}}else{var i=this.bonePose.current;var n=this.bonePose.delta;i.rotation=0;i.skew=0;n.rotation=0;n.skew=0}};a.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current;var a=this.bonePose.delta;var r=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}r.rotation=t.rotation+a.rotation*this._tweenProgress;r.skew=t.skew+a.skew*this._tweenProgress};a.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation);e.skew=t.Transform.normalizeRadian(e.skew)};return a}(t.BoneTimelineState);t.BoneRotateTimelineState=n;var s=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.BoneScaleTimelineState]"};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*2;var a=this._frameFloatArray;var r=this.bonePose.current;var i=this.bonePose.delta;r.scaleX=a[e++];r.scaleY=a[e++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){e=this._animationData.frameFloatOffset+this._frameValueOffset}i.scaleX=a[e++]-r.scaleX;i.scaleY=a[e++]-r.scaleY}else{i.scaleX=0;i.scaleY=0}}else{var r=this.bonePose.current;var i=this.bonePose.delta;r.scaleX=1;r.scaleY=1;i.scaleX=0;i.scaleY=0}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);var e=this.bonePose.current;var a=this.bonePose.delta;var r=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}r.scaleX=e.scaleX+a.scaleX*this._tweenProgress;r.scaleY=e.scaleY+a.scaleY*this._tweenProgress};return e}(t.BoneTimelineState);t.BoneScaleTimelineState=s;var o=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[];e._delta=[];e._result=[];return e}e.toString=function(){return"[class dragonBones.SurfaceTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.surface=null;this._frameFloatOffset=0;this._valueCount=0;this._deformCount=0;this._valueOffset=0;this._current.length=0;this._delta.length=0;this._result.length=0};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount;var a=this._armature._armatureData.scale;var r=this._frameFloatArray;if(this._tweenState===2){var i=e+this._valueCount;if(this._frameIndex===this._frameCount-1){i=this._animationData.frameFloatOffset+this._frameValueOffset}for(var n=0;n=0){var t=this._timelineData!==null?this._frameArray[this._frameOffset+1]:this.slot._slotData.displayIndex;if(this.slot.displayIndex!==t){this.slot._setDisplayIndex(t,true)}}};return e}(t.SlotTimelineState);t.SlotDislayTimelineState=l;var h=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[0,0,0,0,0,0,0,0];e._delta=[0,0,0,0,0,0,0,0];e._result=[0,0,0,0,0,0,0,0];return e}e.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._dirty=false};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._dragonBonesData.intArray;var a=this._frameIntArray;var r=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex*1;var i=a[r];if(i<0){i+=65536}this._current[0]=e[i++];this._current[1]=e[i++];this._current[2]=e[i++];this._current[3]=e[i++];this._current[4]=e[i++];this._current[5]=e[i++];this._current[6]=e[i++];this._current[7]=e[i++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){i=a[this._animationData.frameIntOffset+this._frameValueOffset]}else{i=a[r+1*1]}if(i<0){i+=65536}this._delta[0]=e[i++]-this._current[0];this._delta[1]=e[i++]-this._current[1];this._delta[2]=e[i++]-this._current[2];this._delta[3]=e[i++]-this._current[3];this._delta[4]=e[i++]-this._current[4];this._delta[5]=e[i++]-this._current[5];this._delta[6]=e[i++]-this._current[6];this._delta[7]=e[i++]-this._current[7]}}else{var n=this.slot._slotData.color;this._current[0]=n.alphaMultiplier*100;this._current[1]=n.redMultiplier*100;this._current[2]=n.greenMultiplier*100;this._current[3]=n.blueMultiplier*100;this._current[4]=n.alphaOffset;this._current[5]=n.redOffset;this._current[6]=n.greenOffset;this._current[7]=n.blueOffset}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);this._dirty=true;if(this._tweenState!==2){this._tweenState=0}this._result[0]=(this._current[0]+this._delta[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._delta[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._delta[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._delta[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._delta[4]*this._tweenProgress;this._result[5]=this._current[5]+this._delta[5]*this._tweenProgress;this._result[6]=this._current[6]+this._delta[6]*this._tweenProgress;this._result[7]=this._current[7]+this._delta[7]*this._tweenProgress};e.prototype.fadeOut=function(){this._tweenState=0;this._dirty=false};e.prototype.update=function(e){t.prototype.update.call(this,e);if(this._tweenState!==0||this._dirty){var a=this.slot._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){var r=Math.pow(this._animationState._fadeProgress,4);a.alphaMultiplier+=(this._result[0]-a.alphaMultiplier)*r;a.redMultiplier+=(this._result[1]-a.redMultiplier)*r;a.greenMultiplier+=(this._result[2]-a.greenMultiplier)*r;a.blueMultiplier+=(this._result[3]-a.blueMultiplier)*r;a.alphaOffset+=(this._result[4]-a.alphaOffset)*r;a.redOffset+=(this._result[5]-a.redOffset)*r;a.greenOffset+=(this._result[6]-a.greenOffset)*r;a.blueOffset+=(this._result[7]-a.blueOffset)*r;this.slot._colorDirty=true}}else if(this._dirty){this._dirty=false;if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){a.alphaMultiplier=this._result[0];a.redMultiplier=this._result[1];a.greenMultiplier=this._result[2];a.blueMultiplier=this._result[3];a.alphaOffset=this._result[4];a.redOffset=this._result[5];a.greenOffset=this._result[6];a.blueOffset=this._result[7];this.slot._colorDirty=true}}}};return e}(t.SlotTimelineState);t.SlotColorTimelineState=h;var f=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[];e._delta=[];e._result=[];return e}e.toString=function(){return"[class dragonBones.DeformTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.vertexOffset=0;this._dirty=false;this._frameFloatOffset=0;this._valueCount=0;this._deformCount=0;this._valueOffset=0;this._current.length=0;this._delta.length=0;this._result.length=0};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount;var a=this._armature._armatureData.scale;var r=this._frameFloatArray;if(this._tweenState===2){var i=e+this._valueCount;if(this._frameIndex===this._frameCount-1){i=this._animationData.frameFloatOffset+this._frameValueOffset}for(var n=0;n=0){this._floats[2]=this._floats[0]+this._floats[1]*this._tweenProgress}this._floats[5]=this._floats[3]+this._floats[4]*this._tweenProgress};e.prototype.blend=function(t){var e=this.animationState;var a=e._blendState.blendWeight;if(t===2){e.weight+=this._floats[5]*a;e.currentTime+=this._floats[2]*a}else{e.weight=this._floats[5]*a;e.currentTime=this._floats[2]*a}};return e}(t.TweenTimelineState);t.AnimationTimelineState=_})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.actionDataToInstance=function(t,a,r){if(t.type===0){a.type=e.FRAME_EVENT}else{a.type=t.type===10?e.FRAME_EVENT:e.SOUND_EVENT}a.name=t.name;a.armature=r;a.actionData=t;a.data=t.data;if(t.bone!==null){a.bone=r.getBone(t.bone.name)}if(t.slot!==null){a.slot=r.getSlot(t.slot.name)}};e.toString=function(){return"[class dragonBones.EventObject]"};e.prototype._onClear=function(){this.time=0;this.type="";this.name="";this.armature=null;this.bone=null;this.slot=null;this.animationState=null;this.actionData=null;this.data=null};e.START="start";e.LOOP_COMPLETE="loopComplete";e.COMPLETE="complete";e.FADE_IN="fadeIn";e.FADE_IN_COMPLETE="fadeInComplete";e.FADE_OUT="fadeOut";e.FADE_OUT_COMPLETE="fadeOutComplete";e.FRAME_EVENT="frameEvent";e.SOUND_EVENT="soundEvent";return e}(t.BaseObject);t.EventObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function e(){}e._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":return 0;case"movieclip":return 1;default:return 0}};e._getBoneType=function(t){switch(t.toLowerCase()){case"bone":return 0;case"surface":return 1;default:return 0}};e._getDisplayType=function(t){switch(t.toLowerCase()){case"image":return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;case"path":return 4;default:return 0}};e._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":return 0;case"ellipse":return 1;case"polygon":return 2;default:return 0}};e._getActionType=function(t){switch(t.toLowerCase()){case"play":return 0;case"frame":return 10;case"sound":return 11;default:return 0}};e._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13;default:return 0}};e._getPositionMode=function(t){switch(t.toLocaleLowerCase()){case"percent":return 1;case"fixed":return 0;default:return 1}};e._getSpacingMode=function(t){switch(t.toLocaleLowerCase()){case"length":return 0;case"percent":return 2;case"fixed":return 1;default:return 0}};e._getRotateMode=function(t){switch(t.toLocaleLowerCase()){case"tangent":return 0;case"chain":return 1;case"chainscale":return 2;default:return 0}};e.parseDragonBonesData=function(e){console.warn("Deprecated.");if(e instanceof ArrayBuffer){return t.BinaryDataParser.getInstance().parseDragonBonesData(e)}else{return t.ObjectDataParser.getInstance().parseDragonBonesData(e)}};e.parseTextureAtlasData=function(a,r){if(r===void 0){r=1}console.warn("已废弃");var i={};var n=a[e.SUB_TEXTURE];for(var s=0,o=n.length;s255){return encodeURI(i)}}}return i}return String(i)}return r};r.prototype._getCurvePoint=function(t,e,a,r,i,n,s,o,l,h){var f=1-l;var u=f*f;var _=l*l;var c=f*u;var p=3*l*u;var m=3*f*_;var d=l*_;h.x=c*t+p*a+m*i+d*s;h.y=c*e+p*r+m*n+d*o};r.prototype._samplingEasingCurve=function(t,e){var a=t.length;var r=-2;for(var i=0,n=e.length;i=0&&r+61e-4){var y=(v+d)*.5;this._getCurvePoint(l,h,f,u,_,c,p,m,y,this._helpPoint);if(s-this._helpPoint.x>0){d=y}else{v=y}}e[i]=this._helpPoint.y}};r.prototype._parseActionDataInFrame=function(e,a,r,i){if(t.DataParser.EVENT in e){this._mergeActionFrame(e[t.DataParser.EVENT],a,10,r,i)}if(t.DataParser.SOUND in e){this._mergeActionFrame(e[t.DataParser.SOUND],a,11,r,i)}if(t.DataParser.ACTION in e){this._mergeActionFrame(e[t.DataParser.ACTION],a,0,r,i)}if(t.DataParser.EVENTS in e){this._mergeActionFrame(e[t.DataParser.EVENTS],a,10,r,i)}if(t.DataParser.ACTIONS in e){this._mergeActionFrame(e[t.DataParser.ACTIONS],a,0,r,i)}};r.prototype._mergeActionFrame=function(e,r,i,n,s){var o=t.DragonBones.webAssembly?this._armature.actions.size():this._armature.actions.length;var l=this._parseActionData(e,i,n,s);var h=0;var f=null;for(var u=0,_=l;u<_.length;u++){var c=_[u];this._armature.addAction(c,false)}if(this._actionFrames.length===0){f=new a;f.frameStart=0;this._actionFrames.push(f);f=null}for(var p=0,m=this._actionFrames;pr){break}h++}if(f===null){f=new a;f.frameStart=r;this._actionFrames.splice(h+1,0,f)}for(var v=0;v0){var p=i.getBone(_);if(p!==null){c.parent=p}else{if(!(_ in this._cacheBones)){this._cacheBones[_]=[]}this._cacheBones[_].push(c)}}if(c.name in this._cacheBones){for(var m=0,d=this._cacheBones[c.name];m0&&a.parent!==null){n.root=a.parent;n.bone=a}else{n.root=a;n.bone=null}return n};r.prototype._parsePathConstraint=function(e){var a=this._armature.getSlot(r._getString(e,t.DataParser.TARGET,""));if(a===null){return null}var i=this._armature.defaultSkin;if(i===null){return null}var n=i.getDisplay(a.name,r._getString(e,t.DataParser.TARGET_DISPLAY,a.name));if(n===null||!(n instanceof t.PathDisplayData)){return null}var s=e[t.DataParser.BONES];if(s===null||s.length===0){return null}var o=t.BaseObject.borrowObject(t.PathConstraintData);o.name=r._getString(e,t.DataParser.NAME,"");o.type=1;o.pathSlot=a;o.pathDisplayData=n;o.target=a.parent;o.positionMode=t.DataParser._getPositionMode(r._getString(e,t.DataParser.POSITION_MODE,""));o.spacingMode=t.DataParser._getSpacingMode(r._getString(e,t.DataParser.SPACING_MODE,""));o.rotateMode=t.DataParser._getRotateMode(r._getString(e,t.DataParser.ROTATE_MODE,""));o.position=r._getNumber(e,t.DataParser.POSITION,0);o.spacing=r._getNumber(e,t.DataParser.SPACING,0);o.rotateOffset=r._getNumber(e,t.DataParser.ROTATE_OFFSET,0);o.rotateMix=r._getNumber(e,t.DataParser.ROTATE_MIX,1);o.translateMix=r._getNumber(e,t.DataParser.TRANSLATE_MIX,1);for(var l=0,h=s;l0?i:a;this._parsePivot(e,o);break;case 1:var l=s=t.BaseObject.borrowObject(t.ArmatureDisplayData);l.name=a;l.path=i.length>0?i:a;l.inheritAnimation=true;if(t.DataParser.ACTIONS in e){var h=this._parseActionData(e[t.DataParser.ACTIONS],0,null,null);for(var f=0,u=h;f0?i:a;d.vertices.data=this._data;if(t.DataParser.SHARE in e){this._cacheRawMeshes.push(e);this._cacheMeshes.push(d)}else{this._parseMesh(e,d)}if(t.DataParser.GLUE_WEIGHTS in e&&t.DataParser.GLUE_MESHES in e){this._cacheRawMeshes.push(e);this._cacheMeshes.push(d)}break;case 3:var v=this._parseBoundingBox(e);if(v!==null){var y=s=t.BaseObject.borrowObject(t.BoundingBoxDisplayData);y.name=a;y.path=i.length>0?i:a;y.boundingBox=v}break;case 4:var g=e[t.DataParser.LENGTHS];var b=s=t.BaseObject.borrowObject(t.PathDisplayData);b.closed=r._getBoolean(e,t.DataParser.CLOSED,false);b.constantSpeed=r._getBoolean(e,t.DataParser.CONSTANT_SPEED,false);b.name=a;b.path=i.length>0?i:a;b.vertices.data=this._data;b.curveLengths.length=g.length;for(var D=0,T=g.length;Da.width){a.width=l}if(ha.height){a.height=h}}}a.width-=a.x;a.height-=a.y}else{console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug.")}return a};r.prototype._parseAnimation=function(e){var a=t.BaseObject.borrowObject(t.AnimationData);a.frameCount=Math.max(r._getNumber(e,t.DataParser.DURATION,1),1);a.playTimes=r._getNumber(e,t.DataParser.PLAY_TIMES,1);a.duration=a.frameCount/this._armature.frameRate;a.fadeInTime=r._getNumber(e,t.DataParser.FADE_IN_TIME,0);a.scale=r._getNumber(e,t.DataParser.SCALE,1);a.name=r._getString(e,t.DataParser.NAME,t.DataParser.DEFAULT_NAME);if(a.name.length===0){a.name=t.DataParser.DEFAULT_NAME}a.frameIntOffset=this._frameIntArray.length;a.frameFloatOffset=this._frameFloatArray.length;a.frameOffset=this._frameArray.length;this._animation=a;if(t.DataParser.FRAME in e){var i=e[t.DataParser.FRAME];var n=i.length;if(n>0){for(var s=0,o=0;s0){this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",0,false,false,0,this._parseActionFrame);this._actionFrames.length=0}this._animation=null;return a};r.prototype._parseTimeline=function(e,i,n,s,o,l,h,f){if(e!==null&&n.length>0&&n in e){i=e[n]}if(i===null){return null}var u=i.length;if(u===0){return null}var _=this._frameIntArray.length;var c=this._frameFloatArray.length;var p=t.BaseObject.borrowObject(t.TimelineData);var m=this._timelineArray.length;this._timelineArray.length+=1+1+1+1+1+u;if(e!==null){this._timelineArray[m+0]=Math.round(r._getNumber(e,t.DataParser.SCALE,1)*100);this._timelineArray[m+1]=Math.round(r._getNumber(e,t.DataParser.OFFSET,0)*100)}else{this._timelineArray[m+0]=100;this._timelineArray[m+1]=0}this._timelineArray[m+2]=u;this._timelineArray[m+3]=h;if(o){this._timelineArray[m+4]=_-this._animation.frameIntOffset}else if(l){this._timelineArray[m+4]=c-this._animation.frameFloatOffset}else{this._timelineArray[m+4]=0}this._timeline=p;p.type=s;p.offset=m;if(u===1){p.frameIndicesOffset=-1;this._timelineArray[m+5+0]=f.call(this,i[0],0,0)-this._animation.frameOffset}else{var d=this._animation.frameCount+1;var v=this._data.frameIndices;var y=0;if(t.DragonBones.webAssembly){y=v.size();v.resize(y+d,0)}else{y=v.length;v.length+=d}p.frameIndicesOffset=y;for(var g=0,b=0,D=0,T=0;g0){if(t.DataParser.CURVE in e){var s=i+1;this._helpArray.length=s;this._samplingEasingCurve(e[t.DataParser.CURVE],this._helpArray);this._frameArray.length+=1+1+this._helpArray.length;this._frameArray[n+1]=2;this._frameArray[n+2]=s;for(var o=0;o0){var s=this._armature.sortedSlots.length;var o=new Array(s-n.length/2);var l=new Array(s);for(var h=0;h0?n>=this._prevRotation:n<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}n=this._prevRotation+n-this._prevRotation+t.Transform.PI_D*this._prevClockwise}}this._prevClockwise=r._getNumber(e,t.DataParser.TWEEN_ROTATE,0);this._prevRotation=n;var s=this._parseTweenFrame(e,a,i);var o=this._frameFloatArray.length;this._frameFloatArray.length+=6;this._frameFloatArray[o++]=this._helpTransform.x;this._frameFloatArray[o++]=this._helpTransform.y;this._frameFloatArray[o++]=n;this._frameFloatArray[o++]=this._helpTransform.skew;this._frameFloatArray[o++]=this._helpTransform.scaleX;this._frameFloatArray[o++]=this._helpTransform.scaleY;this._parseActionDataInFrame(e,a,this._bone,this._slot);return s};r.prototype._parseBoneTranslateFrame=function(e,a,i){var n=this._parseTweenFrame(e,a,i);var s=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[s++]=r._getNumber(e,t.DataParser.X,0);this._frameFloatArray[s++]=r._getNumber(e,t.DataParser.Y,0);return n};r.prototype._parseBoneRotateFrame=function(e,a,i){var n=r._getNumber(e,t.DataParser.ROTATE,0)*t.Transform.DEG_RAD;if(a!==0){if(this._prevClockwise===0){n=this._prevRotation+t.Transform.normalizeRadian(n-this._prevRotation)}else{if(this._prevClockwise>0?n>=this._prevRotation:n<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}n=this._prevRotation+n-this._prevRotation+t.Transform.PI_D*this._prevClockwise}}this._prevClockwise=r._getNumber(e,t.DataParser.CLOCK_WISE,0);this._prevRotation=n;var s=this._parseTweenFrame(e,a,i);var o=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[o++]=n;this._frameFloatArray[o++]=r._getNumber(e,t.DataParser.SKEW,0)*t.Transform.DEG_RAD;return s};r.prototype._parseBoneScaleFrame=function(e,a,i){var n=this._parseTweenFrame(e,a,i);var s=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[s++]=r._getNumber(e,t.DataParser.X,1);this._frameFloatArray[s++]=r._getNumber(e,t.DataParser.Y,1);return n};r.prototype._parseSurfaceFrame=function(e,a,i){var n=this._frameFloatArray.length;var s=this._parseTweenFrame(e,a,i);var o=e[t.DataParser.VERTICES];var l=r._getNumber(e,t.DataParser.OFFSET,0);var h=this._surface.vertices.length/2;var f=0;var u=0;this._frameFloatArray.length+=h*2;for(var _=0;_=o.length){f=0}else{f=o[_-l]}if(_+1=o.length){u=0}else{u=o[_+1-l]}this._frameFloatArray[n+_]=f;this._frameFloatArray[n+_+1]=u}if(a===0){var c=this._frameIntArray.length;this._frameIntArray.length+=1+1+1+1+1;this._frameIntArray[c+0]=0;this._frameIntArray[c+1]=this._frameFloatArray.length-n;this._frameIntArray[c+2]=this._frameFloatArray.length-n;this._frameIntArray[c+3]=0;this._frameIntArray[c+4]=n-this._animation.frameFloatOffset;this._timelineArray[this._timeline.offset+3]=c-this._animation.frameIntOffset}return s};r.prototype._parseSlotDisplayFrame=function(e,a,i){var n=this._parseFrame(e,a,i);this._frameArray.length+=1;if(t.DataParser.VALUE in e){this._frameArray[n+1]=r._getNumber(e,t.DataParser.VALUE,0)}else{this._frameArray[n+1]=r._getNumber(e,t.DataParser.DISPLAY_INDEX,0)}this._parseActionDataInFrame(e,a,this._slot.parent,this._slot);return n};r.prototype._parseSlotColorFrame=function(e,a,r){var i=this._parseTweenFrame(e,a,r);var n=-1;if(t.DataParser.VALUE in e||t.DataParser.COLOR in e){var s=t.DataParser.VALUE in e?e[t.DataParser.VALUE]:e[t.DataParser.COLOR];for(var o in s){o;this._parseColorTransform(s,this._helpColorTransform);n=this._intArray.length;this._intArray.length+=8;this._intArray[n++]=Math.round(this._helpColorTransform.alphaMultiplier*100);this._intArray[n++]=Math.round(this._helpColorTransform.redMultiplier*100);this._intArray[n++]=Math.round(this._helpColorTransform.greenMultiplier*100);this._intArray[n++]=Math.round(this._helpColorTransform.blueMultiplier*100);this._intArray[n++]=Math.round(this._helpColorTransform.alphaOffset);this._intArray[n++]=Math.round(this._helpColorTransform.redOffset);this._intArray[n++]=Math.round(this._helpColorTransform.greenOffset);this._intArray[n++]=Math.round(this._helpColorTransform.blueOffset);n-=8;break}}if(n<0){if(this._defaultColorOffset<0){this._defaultColorOffset=n=this._intArray.length;this._intArray.length+=8;this._intArray[n++]=100;this._intArray[n++]=100;this._intArray[n++]=100;this._intArray[n++]=100;this._intArray[n++]=0;this._intArray[n++]=0;this._intArray[n++]=0;this._intArray[n++]=0}n=this._defaultColorOffset}var l=this._frameIntArray.length;this._frameIntArray.length+=1;this._frameIntArray[l]=n;return i};r.prototype._parseSlotFFDFrame=function(e,a,i){var n=this._frameFloatArray.length;var s=this._parseTweenFrame(e,a,i);var o=t.DataParser.VERTICES in e?e[t.DataParser.VERTICES]:null;var l=r._getNumber(e,t.DataParser.OFFSET,0);var h=this._intArray[this._mesh.vertices.offset+0];var f=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name;var u=this._mesh.vertices.weight;var _=0;var c=0;var p=0;var m=0;if(u!==null){var d=this._weightSlotPose[f];this._helpMatrixA.copyFromArray(d,0);this._frameFloatArray.length+=u.count*2;p=u.offset+2+u.bones.length}else{this._frameFloatArray.length+=h*2}for(var v=0;v=o.length){_=0}else{_=o[v-l]}if(v+1=o.length){c=0}else{c=o[v+1-l]}}if(u!==null){var y=this._weightBonePoses[f];var g=this._intArray[p++];this._helpMatrixA.transformPoint(_,c,this._helpPoint,true);_=this._helpPoint.x;c=this._helpPoint.y;for(var b=0;b=0||t.DataParser.DATA_VERSIONS.indexOf(n)>=0){var s=t.BaseObject.borrowObject(t.DragonBonesData);s.version=i;s.name=r._getString(e,t.DataParser.NAME,"");s.frameRate=r._getNumber(e,t.DataParser.FRAME_RATE,24);if(s.frameRate===0){s.frameRate=24}if(t.DataParser.ARMATURE in e){this._data=s;this._parseArray(e);var o=e[t.DataParser.ARMATURE];for(var l=0,h=o;l0){s.stage=s.getArmature(s.armatureNames[0])}this._data=null}if(t.DataParser.TEXTURE_ATLAS in e){this._rawTextureAtlases=e[t.DataParser.TEXTURE_ATLAS]}return s}else{console.assert(false,"Nonsupport data version: "+i+"\n"+"Please convert DragonBones data to support version.\n"+"Read more: https://github.com/DragonBones/Tools/")}return null};r.prototype.parseTextureAtlasData=function(e,a,i){if(i===void 0){i=1}console.assert(e!==undefined);if(e===null){if(this._rawTextureAtlases===null||this._rawTextureAtlases.length===0){return false}var n=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(n,a,i);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}a.width=r._getNumber(e,t.DataParser.WIDTH,0);a.height=r._getNumber(e,t.DataParser.HEIGHT,0);a.scale=i===1?1/r._getNumber(e,t.DataParser.SCALE,1):i;a.name=r._getString(e,t.DataParser.NAME,"");a.imagePath=r._getString(e,t.DataParser.IMAGE_PATH,"");if(t.DataParser.SUB_TEXTURE in e){var s=e[t.DataParser.SUB_TEXTURE];for(var o=0,l=s.length;o0&&_>0){f.frame=t.TextureData.createRectangle();f.frame.x=r._getNumber(h,t.DataParser.FRAME_X,0);f.frame.y=r._getNumber(h,t.DataParser.FRAME_Y,0);f.frame.width=u;f.frame.height=_}a.addTexture(f)}}return true};r.getInstance=function(){if(r._objectDataParserInstance===null){r._objectDataParserInstance=new r}return r._objectDataParserInstance};r._objectDataParserInstance=null;return r}(t.DataParser);t.ObjectDataParser=e;var a=function(){function t(){this.frameStart=0;this.actions=[]}return t}();t.ActionFrame=a})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(a,e);function a(){return e!==null&&e.apply(this,arguments)||this}a.prototype._inRange=function(t,e,a){return e<=t&&t<=a};a.prototype._decodeUTF8=function(t){var e=-1;var a=-1;var r=65533;var i=0;var n="";var s;var o=0;var l=0;var h=0;var f=0;while(t.length>i){var u=t[i++];if(u===e){if(l!==0){s=r}else{s=a}}else{if(l===0){if(this._inRange(u,0,127)){s=u}else{if(this._inRange(u,194,223)){l=1;f=128;o=u-192}else if(this._inRange(u,224,239)){l=2;f=2048;o=u-224}else if(this._inRange(u,240,244)){l=3;f=65536;o=u-240}else{}o=o*Math.pow(64,l);s=null}}else if(!this._inRange(u,128,191)){o=0;l=0;h=0;f=0;i--;s=u}else{h+=1;o=o+(u-128)*Math.pow(64,l-h);if(h!==l){s=null}else{var _=o;var c=f;o=0;l=0;h=0;f=0;if(this._inRange(_,c,1114111)&&!this._inRange(_,55296,57343)){s=_}else{s=u}}}}if(s!==null&&s!==a){if(s<=65535){if(s>0)n+=String.fromCharCode(s)}else{s-=65536;n+=String.fromCharCode(55296+(s>>10&1023));n+=String.fromCharCode(56320+(s&1023))}}}return n};a.prototype._getUTF16Key=function(t){for(var e=0,a=t.length;e255){return encodeURI(t)}}return t};a.prototype._parseBinaryTimeline=function(e,a,r){if(r===void 0){r=null}var i=r!==null?r:t.BaseObject.borrowObject(t.TimelineData);i.type=e;i.offset=a;this._timeline=i;var n=this._timelineArrayBuffer[i.offset+2];if(n===1){i.frameIndicesOffset=-1}else{var s=0;var o=this._animation.frameCount+1;var l=this._data.frameIndices;if(t.DragonBones.webAssembly){s=l.size();l.resize(s+o,0)}else{s=l.length;l.length+=o}i.frameIndicesOffset=s;for(var h=0,f=0,u=0,_=0;h=0){var i=t.BaseObject.borrowObject(t.WeightData);var n=this._intArrayBuffer[a.offset+0];var s=this._intArrayBuffer[r+0];i.offset=r;for(var o=0;o0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(a)}}if(s===null&&(e.length===0||this.autoSearch)){for(var o in this._dragonBonesDataMap){n=this._dragonBonesDataMap[o];if(e.length===0||n.autoSearch){s=n.getArmature(a);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=i;t.data=n;t.armature=s;t.skin=null;if(r.length>0){t.skin=s.getSkin(r);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(r);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};e.prototype._buildBones=function(e,a){for(var r=0,i=e.armature.sortedBones;r0){o.texture=this._getTextureData(e.textureAtlasName,a.path)}if(r!==null&&r.type===2&&this._isSupportMesh()){s=i.meshDisplay}else{s=i.rawDisplay}break}case 2:{var l=a;if(l.texture===null){l.texture=this._getTextureData(n,l.path)}else if(e!==null&&e.textureAtlasName.length>0){l.texture=this._getTextureData(e.textureAtlasName,l.path)}if(this._isSupportMesh()){s=i.meshDisplay}else{s=i.rawDisplay}break}case 1:{var h=a;var f=this._buildChildArmature(e,i,a);if(f!==null){f.inheritAnimation=h.inheritAnimation;if(!f.inheritAnimation){var u=h.actions.length>0?h.actions:f.armatureData.defaultActions;if(u.length>0){for(var _=0,c=u;_=0){continue}var f=a.getDisplays(h.name);if(!f){if(s!==null&&a!==s){f=s.getDisplays(h.name)}if(!f){if(r){h.rawDisplayDatas=null;h.displayList=[]}continue}}var u=t.DragonBones.webAssembly?f.size():f.length;var _=h.displayList;_.length=u;for(var c=0,p=u;c0?this.width:e.width;var r=this.height>0?this.height:e.height;for(var i in this.textures){var n=egret.$TextureScaleFactor;var s=this.textures[i];var o=s.region.width;var l=s.region.height;if(s.renderTexture===null){s.renderTexture=new egret.Texture}s.renderTexture.bitmapData=e;if(s.rotated){s.renderTexture.$initData(s.region.x*n,s.region.y*n,l*n,o*n,0,0,l*n,o*n,a,r,s.rotated)}else{s.renderTexture.$initData(s.region.x*n,s.region.y*n,o*n,l*n,0,0,o*n,l*n,a,r)}}}else{for(var i in this.textures){var s=this.textures[i];s.renderTexture=null}}},enumerable:true,configurable:true});r.prototype.dispose=function(){console.warn("已废弃。");this.returnToPool()};Object.defineProperty(r.prototype,"texture",{get:function(){console.warn("已废弃。");return this.renderTexture},enumerable:true,configurable:true});return r}(t.TextureAtlasData);t.EgretTextureAtlasData=e;var a=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.renderTexture=null;return e}e.toString=function(){return"[class dragonBones.EgretTextureData]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);if(this.renderTexture!==null){}this.renderTexture=null};return e}(t.TextureData);t.EgretTextureData=a})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(a,e);function a(){return e!==null&&e.apply(this,arguments)||this}Object.defineProperty(a.prototype,"eventObject",{get:function(){return this.data},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animationName",{get:function(){var t=this.eventObject.animationState;return t!==null?t.name:""},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"armature",{get:function(){return this.eventObject.armature},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"bone",{get:function(){return this.eventObject.bone},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"slot",{get:function(){return this.eventObject.slot},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"animationState",{get:function(){return this.eventObject.animationState},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"frameLabel",{get:function(){return this.eventObject.name},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"sound",{get:function(){return this.eventObject.name},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"movementID",{get:function(){return this.animationName},enumerable:true,configurable:true});a.START=t.EventObject.START;a.LOOP_COMPLETE=t.EventObject.LOOP_COMPLETE;a.COMPLETE=t.EventObject.COMPLETE;a.FADE_IN=t.EventObject.FADE_IN;a.FADE_IN_COMPLETE=t.EventObject.FADE_IN_COMPLETE;a.FADE_OUT=t.EventObject.FADE_OUT;a.FADE_OUT_COMPLETE=t.EventObject.FADE_OUT_COMPLETE;a.FRAME_EVENT=t.EventObject.FRAME_EVENT;a.SOUND_EVENT=t.EventObject.SOUND_EVENT;a.ANIMATION_FRAME_EVENT=t.EventObject.FRAME_EVENT;a.BONE_FRAME_EVENT=t.EventObject.FRAME_EVENT;a.MOVEMENT_FRAME_EVENT=t.EventObject.FRAME_EVENT;a.SOUND=t.EventObject.SOUND_EVENT;return a}(egret.Event);t.EgretEvent=e;var a=function(a){__extends(r,a);function r(){var t=a!==null&&a.apply(this,arguments)||this;t.debugDraw=false;t._batchEnabled=!(global["nativeRender"]||global["bricks"]);t._childDirty=true;t._debugDraw=false;t._armature=null;t._bounds=null;t._debugDrawer=null;return t}r._cleanBeforeRender=function(){};r.prototype.dbInit=function(t){this._armature=t;if(this._batchEnabled){this.$renderNode=new egret.sys.GroupNode;this.$renderNode.cleanBeforeRender=r._cleanBeforeRender}};r.prototype.dbClear=function(){this._armature=null;this._bounds=null;this._debugDrawer=null};r.prototype.dbUpdate=function(){var e=t.DragonBones.debugDraw||this.debugDraw;if(e||this._debugDraw){this._debugDraw=e;if(this._debugDraw){if(this._debugDrawer===null){this._debugDrawer=new egret.Sprite}if(this._debugDrawer.parent!==this){this.addChild(this._debugDrawer)}var a=2;var r=this._debugDrawer.graphics;r.clear();for(var i=0,n=this._armature.getBones();i0){i.setTo(999999,999999,-999999,-999999);for(var u=0,_=f.length;u<_;u+=2){var c=f[u];var p=f[u+1];if(i.x>c)i.x=c;if(i.widthp)i.y=p;if(i.heighte.width){e.width=g}if(b>e.height){e.height=b}}}e.width-=e.x;e.height-=e.y;if(t.isV5){if(this._bounds===null){this._bounds=new egret.Rectangle}this._bounds.copyFrom(e)}}else if(t.isV5){if(this._bounds===null){this._bounds=new egret.Rectangle}e.copyFrom(this._bounds)}return e}return a.prototype.$measureContentBounds.call(this,e)};r.prototype.hasEvent=function(t){return this.hasDBEventListener(t)};r.prototype.addEvent=function(t,e,a){this.addDBEventListener(t,e,a)};r.prototype.removeEvent=function(t,e,a){this.removeDBEventListener(t,e,a)};r.prototype.advanceTimeBySelf=function(e){if(e){this._armature.clock=t.EgretFactory.factory.clock}else{this._armature.clock=null}};return r}(egret.DisplayObjectContainer);t.EgretArmatureDisplay=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(e);t.Event=r;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(e);t.ArmatureEvent=i;var n=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(e);t.AnimationEvent=n;var s=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(e);t.FrameEvent=s;var o=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(e);t.SoundEvent=o;var l=function(e){__extends(a,e);function a(a,r,i){if(i===void 0){i=1}var n=e.call(this)||this;console.warn("已废弃");n._onClear();t.ObjectDataParser.getInstance().parseTextureAtlasData(r,n,i);n.renderTexture=a;return n}a.toString=function(){return"[class dragonBones.EgretTextureAtlas]"};return a}(t.EgretTextureAtlasData);t.EgretTextureAtlas=l;var h=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(l);t.EgretSheetAtlas=h;var f=function(){function e(){}e.getInstance=function(){console.warn("已废弃");return t.EgretFactory.factory.soundEventManager};return e}();t.SoundEventManager=f;var u=function(){function t(){console.warn("已废弃")}return t}();t.AnimationCacheManager=u})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(a,e);function a(){var t=e!==null&&e.apply(this,arguments)||this;t.transformUpdateEnabled=false;t._armatureDisplay=null;t._renderDisplay=null;t._colorFilter=null;return t}a.toString=function(){return"[class dragonBones.EgretSlot]"};a.prototype.init=function(a,r,i,n){e.prototype.init.call(this,a,r,i,n);if(t.isV5){this._updateTransform=this._updateTransformV5}else{this._updateTransform=this._updateTransformV4}};a.prototype._onClear=function(){e.prototype._onClear.call(this);this._armatureDisplay=null;this._renderDisplay=null;this._colorFilter=null};a.prototype._initDisplay=function(t,e){t;e};a.prototype._disposeDisplay=function(t,e){t;e};a.prototype._onUpdateDisplay=function(){this._armatureDisplay=this._armature.display;this._renderDisplay=this._display!==null?this._display:this._rawDisplay;if(t.isV5&&this._armatureDisplay._batchEnabled){if(this._renderDisplay===this._rawDisplay&&!(this._renderDisplay.$renderNode instanceof egret.sys.BitmapNode)){this._renderDisplay.$renderNode=new egret.sys.BitmapNode}}if(this._armatureDisplay._batchEnabled){if(this._renderDisplay!==this._rawDisplay&&this._renderDisplay!==this._meshDisplay){this._armatureDisplay.disableBatch()}else{var e=this._renderDisplay.$renderNode;if(!e.matrix){e.matrix=new egret.Matrix}}}};a.prototype._addDisplay=function(){if(this._armatureDisplay._batchEnabled){this._armatureDisplay.$renderNode.addNode(this._renderDisplay.$renderNode)}else{this._armatureDisplay.addChild(this._renderDisplay)}};a.prototype._replaceDisplay=function(t){var e=t;if(this._armatureDisplay._batchEnabled){var a=this._armatureDisplay.$renderNode.drawData;a[a.indexOf(e.$renderNode)]=this._renderDisplay.$renderNode}else{this._armatureDisplay.addChild(this._renderDisplay);this._armatureDisplay.swapChildren(this._renderDisplay,e);this._armatureDisplay.removeChild(e)}};a.prototype._removeDisplay=function(){if(this._armatureDisplay._batchEnabled){var t=this._armatureDisplay.$renderNode.drawData;t.splice(t.indexOf(this._renderDisplay.$renderNode),1)}else{this._renderDisplay.parent.removeChild(this._renderDisplay)}};a.prototype._updateZOrder=function(){if(this._armatureDisplay._batchEnabled){var t=this._armatureDisplay.$renderNode.drawData;t[this._zOrder]=this._renderDisplay.$renderNode}else{var e=this._armatureDisplay.getChildIndex(this._renderDisplay);if(e===this._zOrder){return}this._armatureDisplay.addChildAt(this._renderDisplay,this._zOrder)}};a.prototype._updateVisible=function(){var t=this._parent.visible&&this._visible;if(this._armatureDisplay._batchEnabled){var e=this._renderDisplay.$renderNode;e.alpha=t?1:0}else{this._renderDisplay.visible=t}};a.prototype._updateBlendMode=function(){switch(this._blendMode){case 0:this._renderDisplay.blendMode=egret.BlendMode.NORMAL;break;case 1:this._renderDisplay.blendMode=egret.BlendMode.ADD;break;case 5:this._renderDisplay.blendMode=egret.BlendMode.ERASE;break;default:break}if(this._armatureDisplay._batchEnabled){var t=this._renderDisplay.$renderNode;t.blendMode=egret.sys.blendModeToNumber(this._renderDisplay.blendMode)}};a.prototype._updateColor=function(){if(this._colorTransform.redMultiplier!==1||this._colorTransform.greenMultiplier!==1||this._colorTransform.blueMultiplier!==1||this._colorTransform.redOffset!==0||this._colorTransform.greenOffset!==0||this._colorTransform.blueOffset!==0||this._colorTransform.alphaOffset!==0){if(this._colorFilter===null){this._colorFilter=new egret.ColorMatrixFilter}var t=this._colorFilter.matrix;t[0]=this._colorTransform.redMultiplier;t[6]=this._colorTransform.greenMultiplier;t[12]=this._colorTransform.blueMultiplier;t[18]=this._colorTransform.alphaMultiplier;t[4]=this._colorTransform.redOffset;t[9]=this._colorTransform.greenOffset;t[14]=this._colorTransform.blueOffset;t[19]=this._colorTransform.alphaOffset;this._colorFilter.matrix=t;if(this._armatureDisplay._batchEnabled){var e=this._renderDisplay.$renderNode;e.filter=this._colorFilter;e.alpha=1}var a=this._renderDisplay.filters;if(!a){a=[]}if(a.indexOf(this._colorFilter)<0){a.push(this._colorFilter)}this._renderDisplay.filters=a;this._renderDisplay.alpha=1}else{if(this._armatureDisplay._batchEnabled){var e=this._renderDisplay.$renderNode;e.filter=null;e.alpha=this._colorTransform.alphaMultiplier}this._renderDisplay.filters=null;this._renderDisplay.alpha=this._colorTransform.alphaMultiplier}};a.prototype._updateFrame=function(){var e=this._deformVertices!==null&&this._display===this._meshDisplay?this._deformVertices.verticesData:null;var a=this._textureData;if(this._displayIndex>=0&&this._display!==null&&a!==null){if(this._armature.replacedTexture!==null&&this._rawDisplayDatas!==null&&this._rawDisplayDatas.indexOf(this._displayData)>=0){var r=a.parent;if(this._armature._replaceTextureAtlasData===null){r=t.BaseObject.borrowObject(t.EgretTextureAtlasData);r.copyFrom(a.parent);r.renderTexture=this._armature.replacedTexture;this._armature._replaceTextureAtlasData=r}else{r=this._armature._replaceTextureAtlasData}a=r.getTexture(a.name)}if(a.renderTexture!==null){if(e!==null){var i=e.data;var n=i.intArray;var s=i.floatArray;var o=n[e.offset+0];var l=n[e.offset+1];var h=n[e.offset+2];if(h<0){h+=65536}var f=h+o*2;var u=this._armature._armatureData.scale;var _=this._renderDisplay;var c=_.$renderNode;c.uvs.length=o*2;c.vertices.length=o*2;c.indices.length=l*3;for(var p=0,m=o*2;p0&&i.inheritDeform;var o=this._renderDisplay;var l=o.$renderNode;if(n!==null){var h=i.data;var f=h.intArray;var u=h.floatArray;var _=f[i.offset+0];var c=f[n.offset+1];if(c<0){c+=65536}for(var p=0,m=0,d=n.offset+2+r.length,v=c,y=0;p<_;++p){var g=f[d++];var b=0,D=0;for(var T=0;T=5.1;var e=function(e){__extends(a,e);function a(r){if(r===void 0){r=null}var i=e.call(this,r)||this;if(a._dragonBonesInstance===null){var n=new t.EgretArmatureDisplay;a._dragonBonesInstance=new t.DragonBones(n);a._time=egret.getTimer()*.001;egret.startTick(a._clockHandler,a)}i._dragonBones=a._dragonBonesInstance;return i}a._clockHandler=function(t){t*=.001;var e=t-this._time;a._dragonBonesInstance.advanceTime(e);this._time=t;return false};Object.defineProperty(a,"factory",{get:function(){if(a._factory===null){a._factory=new a}return a._factory},enumerable:true,configurable:true});a.prototype._isSupportMesh=function(){if(egret.Capabilities.renderMode==="webgl"||egret.Capabilities.runtimeType===egret.RuntimeType.NATIVE){return true}console.warn("Canvas can not support mesh, please change renderMode to webgl.");return false};a.prototype._buildTextureAtlasData=function(e,a){if(e!==null){if(a instanceof egret.Texture){e.renderTexture=a}else{var r=new egret.Texture;r.bitmapData=new egret.BitmapData(a);e.disposeEnabled=true;e.renderTexture=r}}else{e=t.BaseObject.borrowObject(t.EgretTextureAtlasData)}return e};a.prototype._buildArmature=function(e){var a=t.BaseObject.borrowObject(t.Armature);var r=new t.EgretArmatureDisplay;a.init(e.armature,r,r,this._dragonBones);return a};a.prototype._buildSlot=function(e,a,r){e;var i=t.BaseObject.borrowObject(t.EgretSlot);i.init(a,r,new egret.Bitmap,new egret.Mesh);return i};a.prototype.buildArmatureDisplay=function(t,e,a,r){if(e===void 0){e=""}if(a===void 0){a=""}if(r===void 0){r=""}var i=this.buildArmature(t,e||"",a||"",r||"");if(i!==null){this._dragonBones.clock.add(i);return i.display}return null};a.prototype.getTextureDisplay=function(t,e){if(e===void 0){e=null}var a=this._getTextureData(e!==null?e:"",t);if(a!==null&&a.renderTexture!==null){var r=a.renderTexture;var i=new egret.Bitmap(r);i.width=r.textureWidth*a.parent.scale;i.height=r.textureHeight*a.parent.scale;return i}return null};Object.defineProperty(a.prototype,"soundEventManager",{get:function(){return this._dragonBones.eventManager},enumerable:true,configurable:true});Object.defineProperty(a,"clock",{get:function(){return a.factory.clock},enumerable:true,configurable:true});a.prototype.addSkeletonData=function(t,e){if(e===void 0){e=null}console.warn("已废弃");this.addDragonBonesData(t,e)};a.prototype.getSkeletonData=function(t){console.warn("已废弃");return this.getDragonBonesData(t)};a.prototype.removeSkeletonData=function(t){console.warn("已废弃");this.removeDragonBonesData(t)};a.prototype.addTextureAtlas=function(t,e){if(e===void 0){e=null}console.warn("已废弃");this.addTextureAtlasData(t,e)};a.prototype.getTextureAtlas=function(t){console.warn("已废弃");return this.getTextureAtlasData(t)};a.prototype.removeTextureAtlas=function(t){console.warn("已废弃");this.removeTextureAtlasData(t)};a.prototype.buildFastArmature=function(t,e,a){if(e===void 0){e=""}if(a===void 0){a=""}console.warn("已废弃");return this.buildArmature(t,e||"",a||"")};a.prototype.dispose=function(){console.warn("已废弃");this.clear()};a._time=0;a._dragonBonesInstance=null;a._factory=null;return a}(t.BaseFactory);t.EgretFactory=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=new egret.Rectangle;var a=new egret.Matrix;var r={};function i(t,e){for(var a=0,r=t.length;a=0){e.displayConfig=this._groupConfig.display[e.displayIndex];if(e.displayConfig.type===1){var i=e.displayConfig.name in e.childMovies?e.childMovies[e.displayConfig.name]:null;if(!i){i=f(e.displayConfig.name,this._groupConfig.name);if(i){e.childMovies[e.displayConfig.name]=i}}if(i){e.display=i;e.childMovie=i}else{e.display=e.rawDisplay;e.childMovie=null}}else{e.display=e.rawDisplay;e.childMovie=null}}else{e.displayConfig=null;e.display=e.rawDisplay;e.childMovie=null}if(e.display!==a){if(a){this.addChild(e.display);this.swapChildren(e.display,a);this.removeChild(a)}this._updateSlotBlendMode(e)}if(e.display===e.rawDisplay){if(e.displayConfig&&e.displayConfig.regionIndex!==null&&e.displayConfig.regionIndex!==undefined){if(!e.displayConfig.texture){var n=this._groupConfig.textures[e.displayConfig.textureIndex||0];var s=e.displayConfig.regionIndex*4;var o=this._groupConfig.rectangleArray[s];var l=this._groupConfig.rectangleArray[s+1];var h=this._groupConfig.rectangleArray[s+2];var u=this._groupConfig.rectangleArray[s+3];e.displayConfig.texture=new egret.Texture;e.displayConfig.texture.bitmapData=n.bitmapData;e.displayConfig.texture.$initData(o,l,Math.min(h,n.textureWidth-o),Math.min(u,n.textureHeight-l),0,0,Math.min(h,n.textureWidth-o),Math.min(u,n.textureHeight-l),n.textureWidth,n.textureHeight)}if(this._batchEnabled){var _=e.displayConfig.texture;var c=e.rawDisplay.$renderNode;egret.sys.RenderNode.prototype.cleanBeforeRender.call(e.rawDisplay.$renderNode);c.image=_.bitmapData;if(t.isV5){c.drawImage(_.$bitmapX,_.$bitmapY,_.$bitmapWidth,_.$bitmapHeight,_.$offsetX,_.$offsetY,_.textureWidth,_.textureHeight);c.imageWidth=_._sourceWidth;c.imageHeight=_._sourceHeight}else{var p=_;c.drawImage(p._bitmapX,p._bitmapY,p._bitmapWidth,p._bitmapHeight,p._offsetX,p._offsetY,_.textureWidth,_.textureHeight);c.imageWidth=p._sourceWidth;c.imageHeight=p._sourceHeight}}else{e.rawDisplay.visible=true;e.rawDisplay.$setBitmapData(e.displayConfig.texture)}}else{if(this._batchEnabled){e.rawDisplay.$renderNode.image=null}else{e.rawDisplay.visible=false;e.rawDisplay.$setBitmapData(null)}}}if(e.childMovie!==r){if(r){r.stop();this._childMovies.slice(this._childMovies.indexOf(r),1)}if(e.childMovie){if(this._childMovies.indexOf(e.childMovie)<0){this._childMovies.push(e.childMovie)}if(e.config.action){e.childMovie.play(e.config.action)}else{e.childMovie.play(e.childMovie._config.action)}}}};i.prototype._getSlot=function(t){for(var e=0,a=this._slots.length;e0&&(s>=n||s<=-n)){this._isCompleted=true;o=this._playTimes;if(s<0){s=0}else{s=i}}else{this._isCompleted=false;if(s<0){o=Math.floor(-s/i);s=i- -s%i}else{o=Math.floor(s/i);s%=i}if(this._playTimes>0&&o>this._playTimes){o=this._playTimes}}if(this._currentTime===s){return}var l=Math.floor(s*this._clipConfig.cacheTimeToFrameScale);if(this._cacheFrameIndex!==l){this._cacheFrameIndex=l;var h=this._groupConfig.displayFrameArray;var f=this._groupConfig.transformArray;var u=this._groupConfig.colorArray;var c=true;var p=false;var m=false;var d=this._cacheRectangle;this._cacheRectangle=this._clipConfig.cacheRectangles[this._cacheFrameIndex];if(this._batchEnabled&&!this._cacheRectangle){m=true;this._cacheRectangle=new egret.Rectangle;this._clipConfig.cacheRectangles[this._cacheFrameIndex]=this._cacheRectangle}for(var v=0,y=this._slots.length;v=this._clipArray.length){b=this._frameSize*(this._cacheFrameIndex-1)+v*2}var D=this._clipArray[b]*2;if(D>=0){var T=h[D];var A=h[D+1]*8;var x=this._clipArray[b+1]*6;var P=false;if(g.displayIndex!==T){g.displayIndex=T;P=true;this._updateSlotDisplay(g)}if(g.colorIndex!==A||P){g.colorIndex=A;if(g.colorIndex>=0){this._updateSlotColor(g,u[A]*.01,u[A+1]*.01,u[A+2]*.01,u[A+3]*.01,u[A+4],u[A+5],u[A+6],u[A+7])}else{this._updateSlotColor(g,1,1,1,1,0,0,0,0)}}p=true;if(g.transformIndex!==x){g.transformIndex=x;if(this._batchEnabled){var O=g.display.$renderNode.matrix;if(!O){O=g.display.$renderNode.matrix=new egret.Matrix}O.a=f[x];O.b=f[x+1];O.c=f[x+2];O.d=f[x+3];O.tx=f[x+4];O.ty=f[x+5]}else{a.a=f[x];a.b=f[x+1];a.c=f[x+2];a.d=f[x+3];a.tx=f[x+4];a.ty=f[x+5];g.display.$setMatrix(a)}}if(this._batchEnabled&&m&&g.displayConfig){var O=g.display.$renderNode.matrix;e.x=0;e.y=0;e.width=g.displayConfig.texture.textureWidth;e.height=g.displayConfig.texture.textureHeight;O.$transformBounds(e);if(c){c=false;this._cacheRectangle.x=e.x;this._cacheRectangle.width=e.x+e.width;this._cacheRectangle.y=e.y;this._cacheRectangle.height=e.y+e.height}else{this._cacheRectangle.x=Math.min(this._cacheRectangle.x,e.x);this._cacheRectangle.width=Math.max(this._cacheRectangle.width,e.x+e.width);this._cacheRectangle.y=Math.min(this._cacheRectangle.y,e.y);this._cacheRectangle.height=Math.max(this._cacheRectangle.height,e.y+e.height)}}}else if(g.displayIndex!==-1){g.displayIndex=-1;this._updateSlotDisplay(g)}}if(this._cacheRectangle){if(p&&m&&c&&d){this._cacheRectangle.x=d.x;this._cacheRectangle.y=d.y;this._cacheRectangle.width=d.width;this._cacheRectangle.height=d.height}if(!t.isV5){this.$invalidateContentBounds()}}}if(this._isCompleted){this._isPlaying=false}if(!this._isStarted){this._isStarted=true;if(this.hasEventListener(_.START)){var S=egret.Event.create(_,_.START);S.movie=this;S.clipName=this._clipConfig.name;S.name="";S.slotName="";this.dispatchEvent(S)}}this._isReversing=this._currentTime>s&&this._currentPlayTimes===o;this._currentTime=s;var E=this._clipConfig.frame?this._clipConfig.frame.length:0;if(E>0){var M=Math.floor(this._currentTime*this._config.frameRate);var B=this._groupConfig.frame[this._clipConfig.frame[M]];if(this._currentFrameConfig!==B){if(E>1){var C=this._currentFrameConfig;this._currentFrameConfig=B;if(!C){var w=Math.floor(this._currentTime*this._config.frameRate);C=this._groupConfig.frame[this._clipConfig.frame[w]];if(this._isReversing){}else{if(this._currentTime<=C.position||this._currentPlayTimes!==o){C=this._groupConfig.frame[C.prev]}}}if(this._isReversing){while(C!==B){this._onCrossFrame(C);C=this._groupConfig.frame[C.prev]}}else{while(C!==B){C=this._groupConfig.frame[C.next];this._onCrossFrame(C)}}}else{this._currentFrameConfig=B;if(this._currentFrameConfig){this._onCrossFrame(this._currentFrameConfig)}}}}if(this._currentPlayTimes!==o){this._currentPlayTimes=o;if(this.hasEventListener(_.LOOP_COMPLETE)){var I=egret.Event.create(_,_.LOOP_COMPLETE);I.movie=this;I.clipName=this._clipConfig.name;I.name="";I.slotName="";this.dispatchEvent(I);egret.Event.release(I)}if(this._isCompleted&&this.hasEventListener(_.COMPLETE)){var F=egret.Event.create(_,_.COMPLETE);F.movie=this;F.clipName=this._clipConfig.name;F.name="";F.slotName="";this.dispatchEvent(F);egret.Event.release(F)}}}this._isLockDispose=false;if(this._isDelayDispose){this.dispose()}};i.prototype.play=function(t,e){if(t===void 0){t=null}if(e===void 0){e=-1}if(t){var a=null;for(var r=0,i=this._config.clip.length;r = T | null; - /** - * The HashObject class is the base class for all objects in the Egret framework.The HashObject - * class includes a hashCode property, which is a unique identification number of the instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Egret顶级对象。框架内所有对象的基类,为对象实例提供唯一的hashCode值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface IHashObject { - /** - * a unique identification number assigned to this instance. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 返回此对象唯一的哈希值,用于唯一确定一个对象。hashCode为大于等于1的整数。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - hashCode: number; - } - /** - * @private - * 哈希计数 - */ - let $hashCount: number; - /** - * The HashObject class is the base class for all objects in the Egret framework.The HashObject - * class includes a hashCode property, which is a unique identification number of the instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Egret顶级对象。框架内所有对象的基类,为对象实例提供唯一的hashCode值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HashObject implements IHashObject { - /** - * Initializes a HashObject - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 HashObject 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $hashCode: number; - /** - * a unique identification number assigned to this instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象唯一的哈希值,用于唯一确定一个对象。hashCode为大于等于1的整数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly hashCode: number; - } -} -declare namespace egret { - /** - * The EventDispatcher class is the base class for all classes that dispatchEvent events. The EventDispatcher class implements - * the IEventDispatcher interface and is the base class for the DisplayObject class. The EventDispatcher class allows - * any object on the display list to be an event target and as such, to use the methods of the IEventDispatcher interface. - * Event targets are an important part of the Egret event model. The event target serves as the focal point for how events - * flow through the display list hierarchy. When an event such as a touch tap, Egret dispatches an event object into the - * event flow from the root of the display list. The event object then makes its way through the display list until it - * reaches the event target, at which point it begins its return trip through the display list. This round-trip journey - * to the event target is conceptually divided into three phases:
- * the capture phase comprises the journey from the root to the last node before the event target's node, the target - * phase comprises only the event target node, and the bubbling phase comprises any subsequent nodes encountered on - * the return trip to the root of the display list. In general, the easiest way for a user-defined class to gain event - * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already extending - * another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, and write simple - * hooks to route calls into the aggregated EventDispatcher. - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language en_US - */ - /** - * EventDispatcher 是 Egret 的事件派发器类,负责进行事件的发送和侦听。 - * 事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生鼠标单击、触摸或按键等事件时, - * 框架会将事件对象调度到从显示列表根开始的事件流中。然后该事件对象在显示列表中前进,直到到达事件目标, - * 然后从这一点开始其在显示列表中的回程。在概念上,到事件目标的此往返行程被划分为三个阶段: - * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括回程上遇到的任何后续节点到显示列表的根。 - * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类),则可以实现 - * IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的映射,将调用连接到聚合的 EventDispatcher 中。 - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language zh_CN - */ - class EventDispatcher extends HashObject implements IEventDispatcher { - /** - * create an instance of the EventDispatcher class. - * @param target The target object for events dispatched to the EventDispatcher object. This parameter is used when - * the EventDispatcher instance is aggregated by a class that implements IEventDispatcher; it is necessary so that the - * containing object can be the target for events. Do not use this parameter in simple cases in which a class extends EventDispatcher. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 EventDispatcher 类的实例 - * @param target 此 EventDispatcher 所抛出事件对象的 target 指向。此参数主要用于一个实现了 IEventDispatcher 接口的自定义类, - * 以便抛出的事件对象的 target 属性可以指向自定义类自身。请勿在直接继承 EventDispatcher 的情况下使用此参数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(target?: IEventDispatcher); - /** - * @private - */ - $EventDispatcher: Object; - /** - * @private - * - * @param useCapture - */ - $getEventMap(useCapture?: boolean): any; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - once(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * @private - */ - $addListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): void; - $insertEventBin(list: any[], type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - $removeEventBin(list: any[], listener: Function, thisObject: any): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - hasEventListener(type: string): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - willTrigger(type: string): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - dispatchEvent(event: Event): boolean; - /** - * @private - */ - $notifyListener(event: Event, capturePhase: boolean): boolean; - /** - * Distribute a specified event parameters. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个指定参数的事件。 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispatchEventWith(type: string, bubbles?: boolean, data?: any, cancelable?: boolean): boolean; - } -} -declare namespace egret.sys { - /** - * @private - * 事件信息对象 - */ - interface EventBin { - type: string; - /** - * @private - */ - listener: Function; - /** - * @private - */ - thisObject: any; - /** - * @private - */ - priority: number; - /** - * @private - */ - target: IEventDispatcher; - /** - * @private - */ - useCapture: boolean; - /** - * @private - */ - dispatchOnce: boolean; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class Filter extends HashObject { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - type: string; - /** - * @private - */ - $id: number; - /** - * @private - */ - $uniforms: any; - /** - * @private - */ - protected paddingTop: number; - /** - * @private - */ - protected paddingBottom: number; - /** - * @private - */ - protected paddingLeft: number; - /** - * @private - */ - protected paddingRight: number; - /** - * @private - * @native Render - */ - $obj: any; - constructor(); - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - onPropertyChange(): void; - } -} -declare namespace egret { - /** - * @private - */ - const enum RenderMode { - NONE = 1, - FILTER = 2, - CLIP = 3, - SCROLLRECT = 4, - } - /** - * The DisplayObject class is the base class for all objects that can be placed on the display list. The display list - * manages all objects displayed in the runtime. Use the DisplayObjectContainer class to arrange the display - * objects in the display list. DisplayObjectContainer objects can have child display objects, while other display objects, - * such as Shape and TextField objects, are "leaf" nodes that have only parents and siblings, no children. - * The DisplayObject class supports basic functionality like the x and y position of an object, as well as more advanced - * properties of the object such as its transformation matrix.
- * The DisplayObject class contains several broadcast events.Normally, the target of any particular event is a specific - * DisplayObject instance. For example, the target of an added event is the specific DisplayObject instance that was added - * to the display list. Having a single target restricts the placement of event listeners to that target and in some cases - * the target's ancestors on the display list. With broadcast events, however, the target is not a specific DisplayObject - * instance, but rather all DisplayObject instances, including those that are not on the display list. This means that you - * can add a listener to any DisplayObject instance to listen for broadcast events. - * - * @event egret.Event.ADDED Dispatched when a display object is added to the display list. - * @event egret.Event.ADDED_TO_STAGE Dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained. - * @event egret.Event.REMOVED Dispatched when a display object is about to be removed from the display list. - * @event egret.Event.REMOVED_FROM_STAGE Dispatched when a display object is about to be removed from the display list, either directly or through the removal of a sub tree in which the display object is contained. - * @event egret.Event.ENTER_FRAME [broadcast event] Dispatched when the playhead is entering a new frame. - * @event egret.Event.RENDER [broadcast event] Dispatched when the display list is about to be updated and rendered. - * @event egret.TouchEvent.TOUCH_MOVE Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @event egret.TouchEvent.TOUCH_BEGIN Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_END Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_TAP Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language en_US - */ - /** - * DisplayObject 类是可放在显示列表中的所有对象的基类。该显示列表管理运行时中显示的所有对象。使用 DisplayObjectContainer 类排列 - * 显示列表中的显示对象。DisplayObjectContainer 对象可以有子显示对象,而其他显示对象(如 Shape 和 TextField 对象)是“叶”节点,没有子项,只有父级和 - * 同级。DisplayObject 类有一些基本的属性(如确定坐标位置的 x 和 y 属性),也有一些高级的对象属性(如 Matrix 矩阵变换)。
- * DisplayObject 类包含若干广播事件。通常,任何特定事件的目标均为一个特定的 DisplayObject 实例。例如,added 事件的目标是已添加到显示列表 - * 的目标 DisplayObject 实例。若只有一个目标,则会将事件侦听器限制为只能监听在该目标上(在某些情况下,可监听在显示列表中该目标的祖代上)。 - * 但是对于广播事件,目标不是特定的 DisplayObject 实例,而是所有 DisplayObject 实例(包括那些不在显示列表中的实例)。这意味着您可以向任何 - * DisplayObject 实例添加侦听器来侦听广播事件。 - * - * @event egret.Event.ADDED 将显示对象添加到显示列表中时调度。 - * @event egret.Event.ADDED_TO_STAGE 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @event egret.Event.REMOVED 将要从显示列表中删除显示对象时调度。 - * @event egret.Event.REMOVED_FROM_STAGE 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @event egret.Event.ENTER_FRAME [广播事件] 播放头进入新帧时调度。 - * @event egret.Event.RENDER [广播事件] 将要更新和呈现显示列表时调度。 - * @event egret.TouchEvent.TOUCH_MOVE 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @event egret.TouchEvent.TOUCH_BEGIN 当用户第一次触摸启用触摸的设备时(例如,用手指触摸手机屏幕)调度。 - * @event egret.TouchEvent.TOUCH_END 当用户移除与启用触摸的设备的接触时(例如,将手指从屏幕上抬起)调度。 - * @event egret.TouchEvent.TOUCH_TAP 当用户在启用触摸设备上的已启动接触的同一 DisplayObject 实例上抬起接触点时(例如,手机点击屏幕后抬起)调度。 - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE 当用户在启用触摸设备上的已启动接触的不同 DisplayObject 实例上抬起接触点时(例如,按住屏幕上的某个对象,然后从它上面挪开后再松开手指)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language zh_CN - */ - class DisplayObject extends EventDispatcher { - /** - * Initializes a DisplayObject object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个显示对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - $nativeDisplayObject: egret_native.NativeDisplayObject; - protected createNativeDisplayObject(): void; - /** - * @private - * 是否添加到舞台上,防止重复发送 removed_from_stage 消息 - */ - $hasAddToStage: boolean; - /** - * @private - * 能够含有子项的类将子项列表存储在这个属性里。 - */ - $children: DisplayObject[]; - private $name; - /** - * Indicates the instance name of the DisplayObject. The object can be identified in the child list of its parent - * display object container by calling the getChildByName() method of the display object container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 的实例名称。 - * 通过调用父显示对象容器的 getChildByName() 方法,可以在父显示对象容器的子列表中标识该对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * @private - */ - $parent: DisplayObjectContainer; - /** - * Indicates the DisplayObjectContainer object that contains this display object. Use the parent property to specify - * a relative path to display objects that are above the current display object in the display list hierarchy. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示包含此显示对象的 DisplayObjectContainer 对象。 - * 使用 parent 属性可以指定高于显示列表层次结构中当前显示对象的显示对象的相对路径。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly parent: DisplayObjectContainer; - /** - * @private - * 设置父级显示对象 - */ - $setParent(parent: DisplayObjectContainer): void; - /** - * @private - * 显示对象添加到舞台 - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * 显示对象从舞台移除 - */ - $onRemoveFromStage(): void; - /** - * @private - */ - $stage: Stage; - /** - * @private - * 这个对象在显示列表中的嵌套深度,舞台为1,它的子项为2,子项的子项为3,以此类推。当对象不在显示列表中时此属性值为0. - */ - $nestLevel: number; - $useTranslate: boolean; - protected $updateUseTransform(): void; - /** - * The Stage of the display object. you can create and load multiple display objects into the display list, and - * the stage property of each display object refers to the same Stage object.
- * If a display object is not added to the display list, its stage property is set to null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的舞台。 - * 例如,您可以创建多个显示对象并加载到显示列表中,每个显示对象的 stage 属性是指向相同的 Stage 对象。
- * 如果显示对象未添加到显示列表,则其 stage 属性会设置为 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stage: Stage; - /** - * A Matrix object containing values that alter the scaling, rotation, and translation of the display object.
- * Note: to change the value of a display object's matrix, you must make a copy of the entire matrix object, then copy - * the new object into the matrix property of the display object. - * @example the following code increases the tx value of a display object's matrix - *
-         *     let myMatrix:Matrix = myDisplayObject.matrix;
-         *     myMatrix.tx += 10;
-         *     myDisplayObject.matrix = myMatrix;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个 Matrix 对象,其中包含更改显示对象的缩放、旋转和平移的值。
- * 注意:要改变一个显示对象矩阵的值,您必引用整个矩阵对象,然后将它重新赋值给显示对象的 matrix 属性。 - * @example 以下代码改变了显示对象矩阵的tx属性值: - *
-         *     let myMatrix:Matrix = myDisplayObject.matrix;
-         *     myMatrix.tx += 10;
-         *     myDisplayObject.matrix = myMatrix;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - matrix: Matrix; - private $matrix; - private $matrixDirty; - /** - * @private - * 获取矩阵 - */ - $getMatrix(): Matrix; - /** - * @private - * 设置矩阵 - */ - $setMatrix(matrix: Matrix, needUpdateProperties?: boolean): void; - private $concatenatedMatrix; - /** - * @private - * 获得这个显示对象以及它所有父级对象的连接矩阵。 - */ - $getConcatenatedMatrix(): Matrix; - private $invertedConcatenatedMatrix; - /** - * @private - * 获取链接矩阵 - */ - $getInvertedConcatenatedMatrix(): Matrix; - $x: number; - /** - * Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
- * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer - * rotated 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is - * rotated 90° counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 x 坐标。
- * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * @private - * 获取x坐标 - */ - $getX(): number; - /** - * @private - * 设置x坐标 - */ - $setX(value: number): boolean; - $y: number; - /** - * Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
- * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer rotated - * 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is rotated 90° - * counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 y 坐标。
- * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * @private - * 获取y坐标 - */ - $getY(): number; - /** - * @private - * 设置y坐标 - */ - $setY(value: number): boolean; - private $scaleX; - /** - * Indicates the horizontal scale (percentage) of the object as applied from the registration point.
- * The default 1.0 equals 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从注册点开始应用的对象的水平缩放比例(百分比)。
- * 1.0 等于 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scaleX: number; - /** - * @private - * - * @returns - */ - $getScaleX(): number; - /** - * @private - * 设置水平缩放值 - */ - $setScaleX(value: number): void; - private $scaleY; - /** - * Indicates the vertical scale (percentage) of an object as applied from the registration point of the object. - * 1.0 is 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象注册点开始应用的对象的垂直缩放比例(百分比)。1.0 是 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scaleY: number; - /** - * @private - * - * @returns - */ - $getScaleY(): number; - /** - * @private - * 设置垂直缩放值 - */ - $setScaleY(value: number): void; - private $rotation; - /** - * Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation. Values from - * 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside - * this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement - * myDisplayObject.rotation = 450 is the same as myDisplayObject.rotation = 90. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例距其原始方向的旋转程度,以度为单位。 - * 从 0 到 180 的值表示顺时针方向旋转;从 0 到 -180 的值表示逆时针方向旋转。对于此范围之外的值,可以通过加上或 - * 减去 360 获得该范围内的值。例如,myDisplayObject.rotation = 450语句与 myDisplayObject.rotation = 90 是相同的。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotation: number; - /** - * @private - */ - $getRotation(): number; - $setRotation(value: number): void; - private $skewX; - private $skewXdeg; - /** - * 表示DisplayObject的x方向斜切 - * @member {number} egret.DisplayObject#skewX - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - skewX: number; - /** - * @private - * - * @param value - */ - $setSkewX(value: number): void; - private $skewY; - private $skewYdeg; - /** - * 表示DisplayObject的y方向斜切 - * @member {number} egret.DisplayObject#skewY - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - skewY: number; - /** - * @private - * - * @param value - */ - $setSkewY(value: number): void; - /** - * Indicates the width of the display object, in pixels. The width is calculated based on the bounds of the content - * of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的宽度,以像素为单位。宽度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - $explicitWidth: number; - /** - * @private - * 设置显示宽度 - */ - $setWidth(value: number): void; - /** - * Indicates the height of the display object, in pixels. The height is calculated based on the bounds of the - * content of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的高度,以像素为单位。高度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - $explicitHeight: number; - /** - * @private - * 获取显示高度 - */ - $getHeight(): number; - /** - * @private - * 设置显示高度 - */ - $setHeight(value: number): void; - /** - * 测量宽度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - readonly measuredWidth: number; - /** - * 测量高度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - readonly measuredHeight: number; - $anchorOffsetX: number; - /** - * X represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点X。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - anchorOffsetX: number; - /** - * @private - * - * @param value - * @returns - */ - $setAnchorOffsetX(value: number): void; - $anchorOffsetY: number; - /** - * Y represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点Y。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - anchorOffsetY: number; - /** - * @private - * - * @param value - * @returns - */ - $setAnchorOffsetY(value: number): void; - /** - * @private - */ - $visible: boolean; - /** - * Whether or not the display object is visible. Display objects that are not visible are disabled. For example, - * if visible=false for an DisplayObject instance, it cannot receive touch or other user input. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象是否可见。不可见的显示对象将被禁用。例如,如果实例的 visible 为 false,则无法接受触摸或用户交互操作。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - visible: boolean; - $setVisible(value: boolean): void; - /** - * @private - * cacheAsBitmap创建的缓存位图节点。 - */ - $displayList: egret.sys.DisplayList; - private $cacheAsBitmap; - /** - * If set to true, Egret runtime caches an internal bitmap representation of the display object. This caching can - * increase performance for display objects that contain complex vector content. After you set the cacheAsBitmap - * property to true, the rendering does not change, however the display object performs pixel snapping automatically. - * The execution speed can be significantly faster depending on the complexity of the content.The cacheAsBitmap - * property is best used with display objects that have mostly static content and that do not scale and rotate frequently.
- * Note: The display object will not create the bitmap caching when the memory exceeds the upper limit,even if you set it to true. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果设置为 true,则 Egret 运行时将缓存显示对象的内部位图表示形式。此缓存可以提高包含复杂矢量内容的显示对象的性能。 - * 将 cacheAsBitmap 属性设置为 true 后,呈现并不更改,但是,显示对象将自动执行像素贴紧。执行速度可能会大大加快, - * 具体取决于显示对象内容的复杂性。最好将 cacheAsBitmap 属性与主要具有静态内容且不频繁缩放或旋转的显示对象一起使用。
- * 注意:在内存超过上限的情况下,即使将 cacheAsBitmap 属性设置为 true,显示对象也不使用位图缓存。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - cacheAsBitmap: boolean; - $setHasDisplayList(value: boolean): void; - $cacheDirty: boolean; - $cacheDirtyUp(): void; - /** - * @private - */ - $alpha: number; - /** - * Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque). - * The default value is 1. Display objects with alpha set to 0 are active, even though they are invisible. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示指定对象的 Alpha 透明度值。 - * 有效值为 0(完全透明)到 1(完全不透明)。alpha 设置为 0 的显示对象是可触摸的,即使它们不可见。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - alpha: number; - /** - * @private - * - * @param value - */ - $setAlpha(value: number): void; - /** - * @private - * The default touchEnabled property of DisplayObject - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * @private - * 显示对象默认的 touchEnabled 属性 - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - static defaultTouchEnabled: boolean; - $touchEnabled: boolean; - /** - * Specifies whether this object receives touch or other user input. The default value is false, which means that - * by default any DisplayObject instance that is on the display list cannot receive touch events. If touchEnabled is - * set to false, the instance does not receive any touch events (or other user input events). Any children of - * this instance on the display list are not affected. To change the touchEnabled behavior for all children of - * an object on the display list, use DisplayObjectContainer.touchChildren. - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定此对象是否接收触摸或其他用户输入。默认值为 false,这表示默认情况下,显示列表上的任何 DisplayObject 实例都不会接收触摸事件或 - * 其他用户输入事件。如果将 touchEnabled 设置为 false,则实例将不接收任何触摸事件(或其他用户输入事件)。显示列表上的该实例的任 - * 何子级都不会受到影响。要更改显示列表上对象的所有子级的 touchEnabled 行为,请使用 DisplayObjectContainer.touchChildren。 - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchEnabled: boolean; - /** - * @private - */ - $getTouchEnabled(): boolean; - /** - * @private - */ - $setTouchEnabled(value: boolean): void; - /** - * @private - */ - $scrollRect: Rectangle; - /** - * The scroll rectangle bounds of the display object. The display object is cropped to the size defined by the rectangle, - * and it scrolls within the rectangle when you change the x and y properties of the scrollRect object. A scrolled display - * object always scrolls in whole pixel increments.You can scroll an object left and right by setting the x property of - * the scrollRect Rectangle object. You can scroll an object up and down by setting the y property of the scrollRect - * Rectangle object. If the display object is rotated 90° and you scroll it left and right, the display object actually - * scrolls up and down.
- * - * Note: to change the value of a display object's scrollRect, you must make a copy of the entire scrollRect object, then copy - * the new object into the scrollRect property of the display object. - * @example the following code increases the x value of a display object's scrollRect - *
-         *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
-         *     myRectangle.x += 10;
-         *     myDisplayObject.scrollRect = myRectangle;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的滚动矩形范围。显示对象被裁切为矩形定义的大小,当您更改 scrollRect 对象的 x 和 y 属性时,它会在矩形内滚动。 - * 滚动的显示对象始终以整像素为增量进行滚动。您可以通过设置 scrollRect Rectangle 对象的 x 属性来左右滚动对象, 还可以通过设置 - * scrollRect 对象的 y 属性来上下滚动对象。如果显示对象旋转了 90 度,并且您左右滚动它,则实际上显示对象会上下滚动。
- * - * 注意:要改变一个显示对象 scrollRect 属性的值,您必引用整个 scrollRect 对象,然后将它重新赋值给显示对象的 scrollRect 属性。 - * @example 以下代码改变了显示对象 scrollRect 的 x 属性值: - *
-         *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
-         *     myRectangle.x += 10;
-         *     myDisplayObject.scrollRect = myRectangle;//设置完scrollRect的x、y、width、height值之后,一定要对myDisplayObject重新赋值scrollRect,不然会出问题。
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollRect: Rectangle; - /** - * @private - * - * @param value - */ - private $setScrollRect(value); - /** - * @private - */ - $blendMode: number; - /** - * A value from the BlendMode class that specifies which blend mode to use. Determine how a source image (new one) - * is drawn on the target image (old one).
- * If you attempt to set this property to an invalid value, Egret runtime set the value to BlendMode.NORMAL. - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BlendMode 枚举中的一个值,用于指定要使用的混合模式,确定如何将一个源(新的)图像绘制到目标(已有)的图像上
- * 如果尝试将此属性设置为无效值,则运行时会将此值设置为 BlendMode.NORMAL。 - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - blendMode: string; - /** - * @private - * 被遮罩的对象 - */ - $maskedObject: DisplayObject; - /** - * @private - */ - $mask: DisplayObject; - /** - * @private - */ - $maskRect: Rectangle; - /** - * The calling display object is masked by the specified mask object. To ensure that masking works when the Stage - * is scaled, the mask display object must be in an active part of the display list. The mask object itself is not drawn. - * Set mask to null to remove the mask. To be able to scale a mask object, it must be on the display list. To be - * able to drag a mask object , it must be on the display list.
- * Note: A single mask object cannot be used to mask more than one calling display object. When the mask is assigned - * to a second display object, it is removed as the mask of the first object, and that object's mask property becomes null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用显示对象被指定的 mask 对象遮罩。要确保当舞台缩放时蒙版仍然有效,mask 显示对象必须处于显示列表的活动部分。 - * 但不绘制 mask 对象本身。将 mask 设置为 null 可删除蒙版。要能够缩放遮罩对象,它必须在显示列表中。要能够拖动蒙版 - * 对象,它必须在显示列表中。
- * 注意:单个 mask 对象不能用于遮罩多个执行调用的显示对象。在将 mask 分配给第二个显示对象时,会撤消其作为第一个对象的遮罩, - * 该对象的 mask 属性将变为 null。 - * - * 下面例子为 mask 为 Rectangle 类型对象,这种情况下,修改 mask 的值后,一定要对 myDisplayObject 重新赋值 mask,不然会出问题。 - * @example 以下代码改变了显示对象 mask 的 x 属性值: - *
-         *     let myMask:Rectangle = myDisplayObject.mask;
-         *     myMask.x += 10;
-         *     myDisplayObject.mask = myMask;//设置完 mask 的x、y、width、height值之后,一定要对myDisplayObject重新赋值 mask,不然会出问题。
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - mask: DisplayObject | Rectangle; - private $setMaskRect(value); - $filters: Array; - /** - * An indexed array that contains each filter object currently associated with the display object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 包含当前与显示对象关联的每个滤镜对象的索引数组。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - filters: Array; - /** - * Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object. - * @param targetCoordinateSpace The display object that defines the coordinate system to use. - * @param resultRect A reusable instance of Rectangle for saving the results. Passing this parameter can reduce the number of reallocate objects - *, which allows you to get better code execution performance.. - * @returns The rectangle that defines the area of the display object relative to the targetCoordinateSpace object's coordinate system. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个矩形,该矩形定义相对于 targetCoordinateSpace 对象坐标系的显示对象区域。 - * @param targetCoordinateSpace 定义要使用的坐标系的显示对象。 - * @param resultRect 一个用于存储结果的可复用Rectangle实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 定义与 targetCoordinateSpace 对象坐标系统相关的显示对象面积的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTransformedBounds(targetCoordinateSpace: DisplayObject, resultRect?: Rectangle): Rectangle; - /** - * Obtain measurement boundary of display object - * @param resultRect {Rectangle} Optional. It is used to import Rectangle object for saving results, preventing duplicate object creation. - * @param calculateAnchor {boolean} Optional. It is used to determine whether to calculate anchor point. - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取显示对象的测量边界 - * @param resultRect {Rectangle} 可选参数,传入用于保存结果的Rectangle对象,避免重复创建对象。 - * @param calculateAnchor {boolean} 可选参数,是否会计算锚点。 - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getBounds(resultRect?: Rectangle, calculateAnchor?: boolean): egret.Rectangle; - /** - * @private - */ - $getTransformedBounds(targetCoordinateSpace: DisplayObject, resultRect?: Rectangle): Rectangle; - /** - * Converts the point object from the Stage (global) coordinates to the display object's (local) coordinates. - * @param stageX the x value in the global coordinates - * @param stageY the y value in the global coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将从舞台(全局)坐标转换为显示对象的(本地)坐标。 - * @param stageX 舞台坐标x - * @param stageY 舞台坐标y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 具有相对于显示对象的坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - globalToLocal(stageX?: number, stageY?: number, resultPoint?: Point): Point; - /** - * Converts the point object from the display object's (local) coordinates to the Stage (global) coordinates. - * @param localX the x value in the local coordinates - * @param localY the x value in the local coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the Stage. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的(本地)坐标转换为舞台(全局)坐标。 - * @param localX 本地坐标 x - * @param localY 本地坐标 y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 一个具有相对于舞台坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - localToGlobal(localX?: number, localY?: number, resultPoint?: Point): Point; - /** - * @private - * 获取显示对象占用的矩形区域集合,通常包括自身绘制的测量区域,如果是容器,还包括所有子项占据的区域。 - */ - $getOriginalBounds(): Rectangle; - /** - * @private - * 测量子项占用的矩形区域 - * @param bounds 测量结果存储在这个矩形对象内 - */ - $measureChildBounds(bounds: Rectangle): void; - /** - * @private - */ - $getContentBounds(): Rectangle; - /** - * @private - * 测量自身占用的矩形区域,注意:此测量结果并不包括子项占据的区域。 - * @param bounds 测量结果存储在这个矩形对象内 - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $parentDisplayList: egret.sys.DisplayList; - /** - * @private - * 渲染节点,不为空表示自身有绘制到屏幕的内容 - */ - $renderNode: sys.RenderNode; - $renderDirty: boolean; - /** - * @private - * 获取渲染节点 - */ - $getRenderNode(): sys.RenderNode; - $updateRenderMode(): void; - $renderMode: RenderMode; - /** - * @private - */ - private $measureFiltersOffset(fromParent); - /** - * @private - * 获取相对于指定根节点的连接矩阵。 - * @param root 根节点显示对象 - * @param matrix 目标显示对象相对于舞台的完整连接矩阵。 - */ - $getConcatenatedMatrixAt(root: DisplayObject, matrix: Matrix): void; - /** - * @private - * 更新renderNode - */ - $updateRenderNode(): void; - /** - * @private - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * Calculate the display object to determine whether it overlaps or crosses with the points specified by the x and y parameters. The x and y parameters specify the points in the coordinates of the stage, rather than the points in the display object container that contains display objects (except the situation where the display object container is a stage). - * Note: Don't use accurate pixel collision detection on a large number of objects. Otherwise, this will cause serious performance deterioration. - * @param x {number} x coordinate of the object to be tested. - * @param y {number} y coordinate of the object to be tested. - * @param shapeFlag {boolean} Whether to check the actual pixel of object (true) or check that of border (false).Write realized. - * @returns {boolean} If display object overlaps or crosses with the specified point, it is true; otherwise, it is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计算显示对象,以确定它是否与 x 和 y 参数指定的点重叠或相交。x 和 y 参数指定舞台的坐标空间中的点,而不是包含显示对象的显示对象容器中的点(除非显示对象容器是舞台)。 - * 注意,不要在大量物体中使用精确碰撞像素检测,这回带来巨大的性能开销 - * @param x {number} 要测试的此对象的 x 坐标。 - * @param y {number} 要测试的此对象的 y 坐标。 - * @param shapeFlag {boolean} 是检查对象 (true) 的实际像素,还是检查边框 (false) 的实际像素。 - * @returns {boolean} 如果显示对象与指定的点重叠或相交,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - hitTestPoint(x: number, y: number, shapeFlag?: boolean): boolean; - /** - * @private - */ - static $enterFrameCallBackList: DisplayObject[]; - /** - * @private - */ - static $renderCallBackList: DisplayObject[]; - /** - * @private - */ - $addListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - dispatchEvent(event: Event): boolean; - /** - * @private - * 获取事件流列表。注意:Egret框架的事件流与Flash实现并不一致。 - * - * 事件流有三个阶段:捕获,目标,冒泡。 - * Flash里默认的的事件监听若不开启useCapture将监听目标和冒泡阶段。若开始capture将只能监听捕获当不包括目标的事件。 - * 可以在Flash中写一个简单的测试:实例化一个非容器显示对象,例如TextField。分别监听useCapture为true和false时的鼠标事件。 - * 点击后将只有useCapture为false的回调函数输出信息。也就带来一个问题「Flash的捕获阶段不能监听到最内层对象本身,只在父级列表有效」。 - * - * 而HTML里的事件流设置useCapture为true时是能监听到目标阶段的,也就是目标阶段会被触发两次,在捕获和冒泡过程各触发一次。这样可以避免 - * 前面提到的监听捕获无法监听目标本身的问题。 - * - * Egret最终采用了HTML里目标节点触发两次的事件流方式。 - */ - $getPropagationList(target: DisplayObject): DisplayObject[]; - /** - * @private - */ - $dispatchPropagationEvent(event: Event, list: DisplayObject[], targetIndex: number): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - willTrigger(type: string): boolean; - /** - * inspired by pixi.js - */ - private _tint; - /** - * @private - */ - $tintRGB: number; - /** - * Set a tint color for the current object - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 给当前对象设置填充色 - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - tint: number; - /** - * @private - * inspired by pixi.js - */ - $sortDirty: boolean; - sortChildren(): void; - /** - * @private - */ - private _zIndex; - /** - * the z-order (front-to-back order) of the object - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 设置对象的 Z 轴顺序(前后顺序) - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - zIndex: number; - /** - * @private - */ - $lastSortedIndex: number; - /** - * Allow objects to use zIndex sorting - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 允许对象使用 zIndex 排序 - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - sortableChildren: boolean; - } -} -declare namespace egret { - let $TextureScaleFactor: number; - /** - * The Texture class encapsulates different image resources on different platforms. - * In HTML5, resource is an HTMLElement object - * In OpenGL / WebGL, resource is a texture ID obtained after the GPU is submitted - * The Texture class encapsulates the details implemented on the underlayer. Developers just need to focus on interfaces - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @see http://edn.egret.com/cn/docs/page/123 Several ways of access to resources - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language en_US - */ - /** - * 纹理类是对不同平台不同的图片资源的封装 - * 在HTML5中,资源是一个HTMLElement对象 - * 在OpenGL / WebGL中,资源是一个提交GPU后获取的纹理id - * Texture类封装了这些底层实现的细节,开发者只需要关心接口即可 - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @see http://edn.egret.com/cn/docs/page/123 获取资源的几种方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language zh_CN - */ - class Texture extends HashObject { - /** - * Create an egret.Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * Whether to destroy the corresponding BitmapData when the texture is destroyed - * @version Egret 5.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁纹理时是否销毁对应BitmapData - * @version Egret 5.0.8 - * @platform Web,Native - * @language zh_CN - */ - disposeBitmapData: boolean; - /** - * @private - * 表示这个纹理在 bitmapData 上的 x 起始位置 - */ - $bitmapX: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的 y 起始位置 - */ - $bitmapY: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的宽度 - */ - $bitmapWidth: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的高度 - */ - $bitmapHeight: number; - /** - * @private - * 表示这个纹理显示了之后在 x 方向的渲染偏移量 - */ - $offsetX: number; - /** - * @private - * 表示这个纹理显示了之后在 y 方向的渲染偏移量 - */ - $offsetY: number; - /** - * @private - * 纹理宽度 - */ - private $textureWidth; - /** - * Texture width, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理宽度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textureWidth: number; - $getTextureWidth(): number; - /** - * @private - * 纹理高度 - */ - private $textureHeight; - /** - * Texture height, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理高度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textureHeight: number; - $getTextureHeight(): number; - $getScaleBitmapWidth(): number; - $getScaleBitmapHeight(): number; - /** - * @private - * 表示bitmapData.width - */ - $sourceWidth: number; - /** - * @private - * 表示bitmapData.height - */ - $sourceHeight: number; - /** - * @private - */ - $bitmapData: BitmapData; - /** - * @private - */ - $ktxData: ArrayBuffer; - /** - * @private - */ - $rotated: boolean; - /** - * The BitmapData object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 BitmapData 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bitmapData: BitmapData; - /** - * Set the BitmapData object. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 BitmapData 对象。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - _setBitmapData(value: BitmapData): void; - /** - * The KTX object being referenced. - * @version Egret 5.2.21 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 KTXData 对象。 - * @version Egret 5.2.21 - * @platform Web,Native - * @language zh_CN - */ - ktxData: ArrayBuffer; - /** - * Set the KTXData object. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 KTXData 对象。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - _setKtxData(value: ArrayBuffer): void; - /** - * @private - * 设置Texture数据 - * @param bitmapX - * @param bitmapY - * @param bitmapWidth - * @param bitmapHeight - * @param offsetX - * @param offsetY - * @param textureWidth - * @param textureHeight - * @param sourceWidth - * @param sourceHeight - */ - $initData(bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, sourceWidth: number, sourceHeight: number, rotated?: boolean): void; - /** - * @deprecated - */ - getPixel32(x: number, y: number): number[]; - /** - * Obtain the color value for the specified pixel region - * @param x The x coordinate of the pixel region - * @param y The y coordinate of the pixel region - * @param width The width of the pixel region - * @param height The height of the pixel region - * @returns Specifies the color value for the pixel region - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定像素区域的颜色值 - * @param x 像素区域的X轴坐标 - * @param y 像素区域的Y轴坐标 - * @param width 像素区域的宽度 - * @param height 像素区域的高度 - * @returns 指定像素区域的颜色值 - * @version Egret 3.2.1 - * @platform Web - * @language zh_CN - */ - getPixels(x: number, y: number, width?: number, height?: number): number[]; - /** - * Convert base64 string, if the picture (or pictures included) cross-border or null - * @param type Type conversions, such as "image / png" - * @param rect The need to convert the area - * @param smoothing Whether to convert data to the smoothing process - * @returns {any} base64 string - * @version Egret 2.4 - * @language en_US - */ - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如 "image/png" - * @param rect 需要转换的区域 - * @param {any} encoderOptions 编码用的参数 - * @returns {any} base64字符串 - * @version Egret 2.4 - * @language zh_CN - */ - toDataURL(type: string, rect?: egret.Rectangle, encoderOptions?: any): string; - /** - * Crop designated area and save it as image. - * native support only "image / png" and "image / jpeg"; Web browser because of the various implementations are not the same, it is recommended to use only these two kinds. - * @param type Type conversions, such as "image / png" - * @param filePath The path name of the image (the home directory for the game's private space, the path can not have "../",Web supports only pass names.) - * @param rect The need to convert the area - * @version Egret 2.4 - * @platform Native - * @language en_US - */ - /** - * 裁剪指定区域并保存成图片。 - * native只支持 "image/png" 和 "image/jpeg";Web中由于各个浏览器的实现不一样,因此建议也只用这2种。 - * @param type 转换的类型,如 "image/png" - * @param filePath 图片的名称的路径(主目录为游戏的私有空间,路径中不能有 "../",Web只支持传名称。) - * @param rect 需要转换的区域 - * @version Egret 2.4 - * @platform Native - * @language zh_CN - */ - saveToFile(type: string, filePath: string, rect?: egret.Rectangle): void; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispose(): void; - } -} -declare namespace egret { - /** - * The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event - * listeners when an event occurs.The properties of the Event class carry basic information about an event, such as - * the event's type or whether the event's default behavior can be canceled. For many events, such as the events represented - * by the Event class constants, this basic information is sufficient. Other events, however, may require more detailed - * information. Events associated with a touch tap, for example, need to include additional information about the - * location of the touch event. You can pass such additional information to event listeners by extending the Event class, - * which is what the TouchEvent class does. Egret API defines several Event subclasses for common events that require - * additional information. Events associated with each of the Event subclasses are described in the documentation for - * each class.The methods of the Event class can be used in event listener functions to affect the behavior of the event - * object. Some events have an associated default behavior. Your event listener can cancel this behavior by calling the - * preventDefault() method. You can also make the current event listener the last one to process an event by calling - * the stopPropagation() or stopImmediatePropagation() method. - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language en_US - */ - /** - * Event 类作为创建事件实例的基类,当发生事件时,Event 实例将作为参数传递给事件侦听器。Event 类的属性包含有关事件的基本信息,例如事件 - * 的类型或者是否可以取消事件的默认行为。对于许多事件(如由 Event 类常量表示的事件),此基本信息就足够了。但其他事件可能需要更详细的信息。 - * 例如,与触摸关联的事件需要包括有关触摸事件的位置信息。您可以通过扩展 Event 类(TouchEvent 类执行的操作)将此类其他信息传递给事件侦听器。 - * Egret API 为需要其他信息的常见事件定义多个 Event 子类。与每个 Event 子类关联的事件将在每个类的文档中加以介绍。Event 类的方法可以在 - * 事件侦听器函数中使用以影响事件对象的行为。某些事件有关联的默认行为,通过调用 preventDefault() 方法,您的事件侦听器可以取消此行为。 - * 可以通过调用 stopPropagation() 或 stopImmediatePropagation() 方法,将当前事件侦听器作为处理事件的最后一个事件侦听器。 - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language zh_CN - */ - class Event extends HashObject { - /** - * Dispatched when a display object is added to the on stage display list, either directly or through the addition - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADDED_TO_STAGE: string; - /** - * Dispatched when a display object is about to be removed from the display list, either directly or through the removal - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static REMOVED_FROM_STAGE: string; - /** - * Dispatched when a display object is added to the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象添加到显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADDED: string; - /** - * Dispatched when a display object is about to be removed from the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将要从显示列表中删除显示对象时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static REMOVED: string; - /** - * [broadcast event] Dispatched when the playhead is entering a new frame. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * [广播事件] 进入新的一帧,监听此事件将会在下一帧开始时触发一次回调。这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ENTER_FRAME: string; - /** - * Dispatched when the display list is about to be updated and rendered. - * Note: Every time you want to receive a render event,you must call the stage.invalidate() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 渲染事件,监听此事件将会在本帧末即将开始渲染的前一刻触发回调,这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * 注意:每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 stage.invalidate() 方法,由于每帧只会触发一次屏幕刷新, - * 若在 Event.RENDER 回调函数执行期间再次调用stage.invalidate(),将会被忽略。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RENDER: string; - /** - * Dispatched when the size of stage or UIComponent is changed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台尺寸或UI组件尺寸发生改变 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RESIZE: string; - /** - * Dispatched when the value or selection of a property is chaned. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态发生改变。通常是按钮的选中状态,或者列表的选中项索引改变。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CHANGE: string; - /** - * Dispatched when the value or selection of a property is going to change.you can cancel this by calling the - * preventDefault() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态即将发生改变,通常是按钮的选中状态,或者列表的选中项索引改变。可以通过调用 preventDefault() 方法阻止索引发生更改。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CHANGING: string; - /** - * Dispatched when the net request is complete. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 网络请求加载完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static COMPLETE: string; - /** - * Dispatched when loop completed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 循环完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LOOP_COMPLETE: string; - /** - * Dispatched when the TextInput instance gets focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_IN: string; - /** - * Dispatched when the TextInput instance loses focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_OUT: string; - /** - * Dispatched when the playback is ended. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 动画声音等播放完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ENDED: string; - /** - * 游戏激活 - * @version Egret 2.4 - * @platform Web,Native - */ - static ACTIVATE: string; - /** - * 取消激活 - * @version Egret 2.4 - * @platform Web,Native - */ - static DEACTIVATE: string; - /** - * Event.CLOSE 常量定义 close 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static CLOSE: string; - /** - * Event.CONNECT 常量定义 connect 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static CONNECT: string; - /** - * Event.LEAVE_STAGE 常量定义 leaveStage 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static LEAVE_STAGE: string; - /** - * Event.SOUND_COMPLETE 常量定义 在声音完成播放后调度。 - * @version Egret 2.4 - * @platform Web,Native - */ - static SOUND_COMPLETE: string; - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param data the optional data associated with this event - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param data 与此事件对象关联的可选数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, data?: any); - /** - * the optional data associated with this event - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 与此事件对象关联的可选数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: any; - /** - * @private - */ - $type: string; - /** - * The type of event. The type is case-sensitive. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件的类型。类型区分大小写。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly type: string; - /** - * @private - */ - $bubbles: boolean; - /** - * Indicates whether an event is a bubbling event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示事件是否为冒泡事件。如果事件可以冒泡,则此值为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly bubbles: boolean; - /** - * @private - */ - $cancelable: boolean; - /** - * Indicates whether the behavior associated with the event can be prevented. If the behavior can be - * canceled, this value is true; otherwise it is false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示是否可以阻止与事件相关联的行为。如果可以取消该行为,则此值为 true;否则为 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly cancelable: boolean; - /** - * @private - */ - $eventPhase: number; - /** - * The current phase in the event flow. This property can contain the following numeric values: - * The capture phase (EventPhase.CAPTURING_PHASE). - * The target phase (EventPhase.AT_TARGET) - * The bubbling phase (EventPhase.BUBBLING_PHASE). - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件流中的当前阶段。此属性可以包含以下数值: - * 捕获阶段 (EventPhase.CAPTURING_PHASE)。 - * 目标阶段 (EventPhase.AT_TARGET)。 - * 冒泡阶段 (EventPhase.BUBBLING_PHASE)。 - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly eventPhase: number; - /** - * @private - */ - $currentTarget: any; - /** - * The object that is actively processing the Event object with an event listener. For example, if a - * user clicks an OK button, the current target could be the node containing that button or one of its ancestors - * that has registered an event listener for that event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前正在使用某个事件侦听器处理 Event 对象的对象。例如,如果用户单击“确定”按钮, - * 则当前目标可以是包含该按钮的节点,也可以是它的已为该事件注册了事件侦听器的始祖之一。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly currentTarget: any; - /** - * @private - */ - $target: any; - /** - * The event target. This property contains the target node. For example, if a user clicks an OK button, - * the target node is the display list node containing that button. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件目标。此属性包含目标节点。例如,如果用户单击“确定”按钮,则目标节点就是包含该按钮的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly target: any; - $setTarget(target: any): boolean; - /** - * @private - */ - $isDefaultPrevented: boolean; - /** - * Checks whether the preventDefault() method has been called on the event. If the preventDefault() method has been - * called, returns true; otherwise, returns false. - * @returns If preventDefault() has been called, returns true; otherwise, returns false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查是否已对事件调用 preventDefault() 方法。 - * @returns 如果已调用 preventDefault() 方法,则返回 true;否则返回 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - isDefaultPrevented(): boolean; - /** - * Cancels an event's default behavior if that behavior can be canceled.Many events have associated behaviors that - * are carried out by default. For example, if a user types a character into a text input, the default behavior - * is that the character is displayed in the text input. Because the TextEvent.TEXT_INPUT event's default behavior - * can be canceled, you can use the preventDefault() method to prevent the character from appearing. - * You can use the Event.cancelable property to check whether you can prevent the default behavior associated with - * a particular event. If the value of Event.cancelable is true, then preventDefault() can be used to cancel the event; - * otherwise, preventDefault() has no effect. - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果可以取消事件的默认行为,则取消该行为。 - * 许多事件都有默认执行的关联行为。例如,如果用户在文本字段中键入一个字符,则默认行为就是在文本字段中显示该字符。 - * 由于可以取消 TextEvent.TEXT_INPUT 事件的默认行为,因此您可以使用 preventDefault() 方法来防止显示该字符。 - * 您可以使用 Event.cancelable 属性来检查是否可以防止与特定事件关联的默认行为。如果 Event.cancelable 的值为 true, - * 则可以使用 preventDefault() 来取消事件;否则,preventDefault() 无效。 - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - preventDefault(): void; - /** - * @private - */ - $isPropagationStopped: boolean; - /** - * Prevents processing of any event listeners in nodes subsequent to the current node in the event flow. This method - * does not affect any event listeners in the current node (currentTarget). In contrast, the stopImmediatePropagation() - * method prevents processing of event listeners in both the current node and subsequent nodes. Additional calls to this - * method have no effect. This method can be called in any phase of the event flow.
- * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。此方法不会影响当前节点 currentTarget 中的任何事件侦听器。 - * 相比之下,stopImmediatePropagation() 方法可以防止对当前节点中和后续节点中的事件侦听器进行处理。 - * 对此方法的其它调用没有任何效果。可以在事件流的任何阶段中调用此方法。
- * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stopPropagation(): void; - /** - * @private - */ - $isPropagationImmediateStopped: boolean; - /** - * Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow. - * This method takes effect immediately, and it affects event listeners in the current node. In contrast, the - * stopPropagation() method doesn't take effect until all the event listeners in the current node finish processing.
- * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。此方法会立即生效,并且会影响当前节点中的事件侦听器。 - * 相比之下,在当前节点中的所有事件侦听器都完成处理之前,stopPropagation() 方法不会生效。
- * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stopImmediatePropagation(): void; - /** - * This method will be called automatically when you pass the event object as the parameters to the Event.release() method. - * If your custom event is designed for reusable,you should override this method to make sure all the references to external - * objects are cleaned. if not,it may cause memory leaking. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当事件实例传递给Event.release()静态方法时,实例上的clean()方法将会被自动调用。 - * 若此自定义事件的实例设计为可以循环复用的,为了避免引起内存泄露,自定义事件需要覆盖此方法来确保实例被缓存前断开对外部对象的一切引用。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - protected clean(): void; - /** - * EventDispatcher object using the specified event object thrown Event. Objects thrown objects will be cached in the pool for the next round robin. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 EventDispatcher 对象来抛出 Event 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchEvent(target: IEventDispatcher, type: string, bubbles?: boolean, data?: any): boolean; - /** - * @private - * - * @param EventClass - * @returns - */ - static _getPropertyData(EventClass: any): any; - /** - * Gets one event instance from the object pool or create a new one. We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
- * Note: If you want to use this method to initialize your custom event object,you must make sure the constructor - * of your custom event is the same as the constructor of egret.Event. - * @param EventClass Event Class。 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;    //optional,initializes custom data here
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的事件实例。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
- * 注意:若使用此方法来创建自定义事件的实例,自定义的构造函数参数列表必须跟Event类一致。 - * @param EventClass Event类名。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;  //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(EventClass: { - new (type: string, bubbles?: boolean, cancelable?: boolean): T; - eventPool?: Event[]; - }, type: string, bubbles?: boolean, cancelable?: boolean): T; - /** - * Releases an event object and cache it into the object pool.We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
- * Note: The parameters of this method only accepts an instance created by the Event.create() method. - * if not,it may throw an error. - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data; //optional,initializes custom data here
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个事件对象,并缓存到对象池。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
- * 注意:此方法只能传入由Event.create()创建的事件实例,传入非法对象实例可能会导致报错。 - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;   //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(event: Event): void; - } -} -/** - * Is debug mode. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ -/** - * 是否为 debug 模式。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ -declare let DEBUG: boolean; -/** - * Is release mode. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ -/** - * 是否为 release 模式。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ -declare let RELEASE: boolean; -declare namespace egret { - /** - * @private - */ - function $error(code: number, ...params: any[]): void; - /** - * @private - */ - function $warn(code: number, ...params: any[]): void; - /** - * @private - */ - function getString(code: number, ...params: any[]): string; - /** - * @private - */ - function $markCannotUse(instance: any, property: string, defaultVale: any): void; -} -declare namespace egret { - /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal - * axis and y represents the vertical axis. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language en_US - */ - /** - * Point 对象表示二维坐标系统中的某个位置,其中 x 表示水平轴,y 表示垂直轴。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language zh_CN - */ - class Point extends HashObject { - /** - * Releases a point instance to the object pool - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Point实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(point: Point): void; - /** - * get a point instance from the object pool or create a new one. - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Point对象。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(x: number, y: number): Point; - /** - * Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(x?: number, y?: number); - /** - * The horizontal coordinate. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该点的水平坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * The vertical coordinate. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该点的垂直坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * The length of the line segment from (0,0) to this point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 (0,0) 到此点的线段长度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly length: number; - /** - * Sets the members of Point to the specified values - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 的成员设置为指定值 - * @param x 该对象的x属性值 - * @param y 该对象的y属性值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(x: number, y: number): Point; - /** - * Creates a copy of this Point object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 克隆点对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Point; - /** - * Determines whether two points are equal. Two points are equal if they have the same x and y values. - * @param toCompare The point to be compared. - * @returns A value of true if the object is equal to this Point object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个点是否相同。如果两个点具有相同的 x 和 y 值,则它们是相同的点。 - * @param toCompare 要比较的点。 - * @returns 如果该对象与此 Point 对象相同,则为 true 值,如果不相同,则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(toCompare: Point): boolean; - /** - * Returns the distance between pt1 and pt2. - * @param p1 The first point. - * @param p2 The second point. - * @returns The distance between the first and second points. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 pt1 和 pt2 之间的距离。 - * @param p1 第一个点 - * @param p2 第二个点 - * @returns 第一个点和第二个点之间的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static distance(p1: Point, p2: Point): number; - /** - * Copies all of the point data from the source Point object into the calling Point object. - * @param sourcePoint The Point object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Point 对象中的所有点数据复制到调用方 Point 对象中。 - * @param sourcePoint 要从中复制数据的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(sourcePoint: Point): void; - /** - * Adds the coordinates of another point to the coordinates of this point to create a new point. - * @param v The point to be added. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将另一个点的坐标添加到此点的坐标以创建一个新点。 - * @param v 要添加的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - add(v: Point): Point; - /** - * Determines a point between two specified points. - * The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2. The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2). - * @param pt1 The first point. - * @param pt2 The second point. - * @param f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned. - * @returns The new interpolated point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个指定点之间的点。 - * 参数 f 确定新的内插点相对于参数 pt1 和 pt2 指定的两个端点所处的位置。参数 f 的值越接近 1.0,则内插点就越接近第一个点(参数 pt1)。参数 f 的值越接近 0,则内插点就越接近第二个点(参数 pt2)。 - * @param pt1 第一个点。 - * @param pt2 第二个点。 - * @param f 两个点之间的内插级别。表示新点将位于 pt1 和 pt2 连成的直线上的什么位置。如果 f=1,则返回 pt1;如果 f=0,则返回 pt2。 - * @returns 新的内插点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static interpolate(pt1: Point, pt2: Point, f: number): Point; - /** - * Scales the line segment between (0,0) and the current point to a set length. - * @param thickness The scaling value. For example, if the current point is (0,5), and you normalize it to 1, the point returned is at (0,1). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 (0,0) 和当前点之间的线段缩放为设定的长度。 - * @param thickness 缩放值。例如,如果当前点为 (0,5) 并且您将它规范化为 1,则返回的点位于 (0,1) 处。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - normalize(thickness: number): void; - /** - * Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value. - * @param dx The amount by which to offset the horizontal coordinate, x. - * @param dy The amount by which to offset the vertical coordinate, y. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量偏移 Point 对象。dx 的值将添加到 x 的原始值中以创建新的 x 值。dy 的值将添加到 y 的原始值中以创建新的 y 值。 - * @param dx 水平坐标 x 的偏移量。 - * @param dy 水平坐标 y 的偏移量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offset(dx: number, dy: number): void; - /** - * Converts a pair of polar coordinates to a Cartesian point coordinate. - * @param len The length coordinate of the polar pair. - * @param angle The angle, in radians, of the polar pair. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一对极坐标转换为笛卡尔点坐标。 - * @param len 极坐标对的长度。 - * @param angle 极坐标对的角度(以弧度表示)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static polar(len: number, angle: number): Point; - /** - * Subtracts the coordinates of another point from the coordinates of this point to create a new point. - * @param v The point to be subtracted. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从此点的坐标中减去另一个点的坐标以创建一个新点。 - * @param v 要减去的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - subtract(v: Point): Point; - /** - * Returns a string that contains the values of the x and y coordinates. The string has the form "(x=x, y=y)", so calling the toString() method for a point at 23,17 would return "(x=23, y=17)". - * @returns The string representation of the coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回包含 x 和 y 坐标的值的字符串。该字符串的格式为 "(x=x, y=y)",因此为点 23,17 调用 toString() 方法将返回 "(x=23, y=17)"。 - * @returns 坐标的字符串表示形式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempPoint: Point; -} -declare namespace egret { - /** - * The DisplayObjectContainer class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language en_US - */ - /** - * DisplayObjectContainer 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language zh_CN - */ - class DisplayObjectContainer extends DisplayObject { - /** - * @private - */ - static $EVENT_ADD_TO_STAGE_LIST: DisplayObject[]; - /** - * @private - */ - static $EVENT_REMOVE_FROM_STAGE_LIST: DisplayObject[]; - /** - * Creates a new DisplayObjectContainer instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * Returns the number of children of this object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象的子项数目。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly numChildren: number; - /** - * Set children sort mode. - * @param value {string} The sort mode - * @see egret.ChildrenSortMode - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * 设置子项目的排序方式 - * @param value {string} 排序方式 - * @see egret.ChildrenSortMode - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - setChildrenSortMode(value: string): void; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added to the front - * (top) of all other children in this DisplayObjectContainer instance. (To add a child to a specific index position, - * use the addChildAt() method.)If you add a child object that already has a different display object container - * as a parent, the object is removed from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @returns 在 child The DisplayObject instance that you pass in the child parameter. - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。子项将被添加到该 DisplayObjectContainer 实例中其他 - * 所有子项的前(上)面。(要将某子项添加到特定索引位置,请使用 addChildAt() 方法。) - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addChild(child: DisplayObject): DisplayObject; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added at the index position - * specified. An index of 0 represents the back (bottom) of the display list for this DisplayObjectContainer object. - * If you add a child object that already has a different display object container as a parent, the object is removed - * from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @param index The index position to which the child is added. If you specify a currently occupied index position, - * the child object that exists at that position and all higher positions are moved up one position in the child list. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。该子项将被添加到指定的索引位置。索引为 0 表示该 - * DisplayObjectContainer 对象的显示列表的后(底)部。如果添加一个已将其它显示对象容器作为父项的子对象,则会从其它显示对象容器的子列表中删除该对象。 - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @param index 添加该子项的索引位置。 如果指定当前占用的索引位置,则该位置以及所有更高位置上的子对象会在子级列表中上移一个位置。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addChildAt(child: DisplayObject, index: number): DisplayObject; - /** - * @private - */ - $doAddChild(child: DisplayObject, index: number, notifyListeners?: boolean): DisplayObject; - /** - * Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance - * itself. The search includes the entire display list including this DisplayObjectContainer instance. Grandchildren, - * great-grandchildren, and so on each return true. - * @param child The child object to test. - * @returns true if the child object is a child of the DisplayObjectContainer or the container itself; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定指定显示对象是 DisplayObjectContainer 实例的子项或该实例本身。搜索包括整个显示列表(其中包括此 DisplayObjectContainer 实例)。 - * 孙项、曾孙项等,每项都返回 true。 - * @param child 要测试的子对象。 - * @returns 如果 child 对象是 DisplayObjectContainer 的子项或容器本身,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - contains(child: DisplayObject): boolean; - /** - * Returns the child display object instance that exists at the specified index. - * @param index The index position of the child object. - * @returns The child display object at the specified index position. - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回位于指定索引处的子显示对象实例。 - * @param index 子对象的索引位置。 - * @returns 位于指定索引位置处的子显示对象。 - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildAt(index: number): DisplayObject; - /** - * Returns the index position of a child DisplayObject instance. - * @param child The DisplayObject instance to identify. - * @returns The index position of the child display object to identify. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 DisplayObject 的 child 实例的索引位置。 - * @param child 要测试的子对象。 - * @returns 要查找的子显示对象的索引位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildIndex(child: egret.DisplayObject): number; - /** - * Returns the child display object that exists with the specified name. If more that one child display object has - * the specified name, the method returns the first object in the child list.The getChildAt() method is faster than - * the getChildByName() method. The getChildAt() method accesses a child from a cached array, whereas the getChildByName() - * method has to traverse a linked list to access a child. - * @param name The name of the child to return. - * @returns The child display object with the specified name. - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回具有指定名称的子显示对象。如果多个子显示对象具有指定名称,则该方法会返回子级列表中的第一个对象。 - * getChildAt() 方法比 getChildByName() 方法快。getChildAt() 方法从缓存数组中访问子项,而 getChildByName() 方法则必须遍历链接的列表来访问子项。 - * @param name 要返回的子项的名称。 - * @returns 具有指定名称的子显示对象。 - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildByName(name: string): DisplayObject; - /** - * Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance. - * The parent property of the removed child is set to null , and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are - * decreased by 1. - * @param child The DisplayObject instance to remove. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子列表中删除指定的 child DisplayObject 实例。将已删除子项的 parent 属性设置为 null; - * 如果不存在对该子项的任何其它引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param child 要删除的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChild(child: DisplayObject): DisplayObject; - /** - * Removes a child DisplayObject from the specified index position in the child list of the DisplayObjectContainer. - * The parent property of the removed child is set to null, and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are decreased by 1. - * @param index The child index of the DisplayObject to remove. - * @returns The DisplayObject instance that was removed. - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 的子列表中指定的 index 位置删除子 DisplayObject。将已删除子项的 parent 属性设置为 null; - * 如果没有对该子项的任何其他引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param index 要删除的 DisplayObject 的子索引。 - * @returns 已删除的 DisplayObject 实例。 - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChildAt(index: number): DisplayObject; - /** - * @private - */ - $doRemoveChild(index: number, notifyListeners?: boolean): DisplayObject; - /** - * Changes the position of an existing child in the display object container. This affects the layering of child objects. - * @param child The child DisplayObject instance for which you want to change the index number. - * @param index The resulting index number for the child display object. - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改现有子项在显示对象容器中的位置。这会影响子对象的分层。 - * @param child 要为其更改索引编号的 DisplayObject 子实例。 - * @param index 生成的 child 显示对象的索引编号。当新的索引编号小于0或大于已有子元件数量时,新加入的DisplayObject对象将会放置于最上层。 - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setChildIndex(child: DisplayObject, index: number): void; - /** - * @private - */ - private doSetChildIndex(child, index); - /** - * Swaps the z-order (front-to-back order) of the child objects at the two specified index positions in the child - * list. All other child objects in the display object container remain in the same index positions. - * @param index1 The index position of the first child object. - * @param index2 The index position of the second child object. - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在子级列表中两个指定的索引位置,交换子对象的 Z 轴顺序(前后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param index1 第一个子对象的索引位置。 - * @param index2 第二个子对象的索引位置。 - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - swapChildrenAt(index1: number, index2: number): void; - /** - * Swaps the z-order (front-to-back order) of the two specified child objects. All other child objects in the - * display object container remain in the same index positions. - * @param child1 The first child object. - * @param child2 The second child object. - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 交换两个指定子对象的 Z 轴顺序(从前到后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param child1 第一个子对象。 - * @param child2 第二个子对象。 - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - swapChildren(child1: DisplayObject, child2: DisplayObject): void; - /** - * @private - */ - private doSwapChildrenAt(index1, index2); - /** - * Removes all child DisplayObject instances from the child list of the DisplayObjectContainer instance. The parent - * property of the removed children is set to null , and the objects are garbage collected if no other references to the children exist. - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子级列表中删除所有 child DisplayObject 实例。 - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChildren(): void; - /** - * @private - * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - $childAdded(child: DisplayObject, index: number): void; - /** - * @private - * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - $childRemoved(child: DisplayObject, index: number): void; - /** - * @private - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - */ - $measureChildBounds(bounds: Rectangle): void; - $touchChildren: boolean; - /** - * Determines whether or not the children of the object are touch, or user input device, enabled. If an object is - * enabled, a user can interact with it by using a touch or user input device. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定对象的子级是否支持触摸或用户输入设备。如果对象支持触摸或用户输入设备,用户可以通过使用触摸或用户输入设备与之交互。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchChildren: boolean; - /** - * @private - * - * @returns - */ - $getTouchChildren(): boolean; - /** - * @private - */ - $setTouchChildren(value: boolean): boolean; - /** - * @private - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - private _sortChildrenFunc(a, b); - sortChildren(): void; - } -} -declare namespace egret { - /** - * SpriteSheet is a mosaic of multiple sub-bitmaps, comprising a plurality of Texture objects. - * Each Texture object shares the set bitmap of SpriteSheet, but it points to its different areas. - * On WebGL / OpenGL, this operation can significantly improve performance. - * At the same time, SpriteSheet can carry out material integration easily to reduce the number of HTTP requests - * For specification of the SpriteSheet format, see the document https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language en_US - */ - /** - * SpriteSheet 是一张由多个子位图拼接而成的集合位图,它包含多个 Texture 对象。 - * 每一个 Texture 都共享 SpriteSheet 的集合位图,但是指向它的不同的区域。 - * 在WebGL / OpenGL上,这种做法可以显著提升性能 - * 同时,SpriteSheet可以很方便的进行素材整合,降低HTTP请求数量 - * SpriteSheet 格式的具体规范可以参见此文档 https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language zh_CN - */ - class SpriteSheet extends HashObject { - /** - * Create an egret.SpriteSheet object - * @param texture {Texture} Texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.SpriteSheet 对象 - * @param texture {Texture} 纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(texture: Texture); - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置x。 - */ - private _bitmapX; - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置y。 - */ - private _bitmapY; - /** - * @private - * 共享的位图数据 - */ - $texture: Texture; - /** - * @private - * 纹理缓存字典 - */ - _textureMap: MapLike; - /** - * Obtain a cached Texture object according to the specified texture name - * @param name {string} Cache the name of this Texture object - * @returns {egret.Texture} The Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据指定纹理名称获取一个缓存的 Texture 对象 - * @param name {string} 缓存这个 Texture 对象所使用的名称 - * @returns {egret.Texture} Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTexture(name: string): Texture; - /** - * Create a new Texture object for the specified area on SpriteSheet and cache it - * @param name {string} Cache the name of this Texture object. If the name already exists, the previous Texture object will be overwrited. - * @param bitmapX {number} Starting coordinate x of texture area on bitmapData - * @param bitmapY {number} Starting coordinate y of texture area on bitmapData - * @param bitmapWidth {number} Width of texture area on bitmapData - * @param bitmapHeight {number} Height of texture area on bitmapData - * @param offsetX {number} Starting point x for a non-transparent area of the original bitmap - * @param offsetY {number} Starting point y for a non-transparent area of the original bitmap - * @param textureWidth {number} Width of the original bitmap. If it is not passed, use the bitmapWidth value. - * @param textureHeight {number} Height of the original bitmap. If it is not passed, use the bitmapHeight value. - * @returns {egret.Texture} The created Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为 SpriteSheet 上的指定区域创建一个新的 Texture 对象并缓存它 - * @param name {string} 缓存这个 Texture 对象所使用的名称,如果名称已存在,将会覆盖之前的 Texture 对象 - * @param bitmapX {number} 纹理区域在 bitmapData 上的起始坐标x - * @param bitmapY {number} 纹理区域在 bitmapData 上的起始坐标y - * @param bitmapWidth {number} 纹理区域在 bitmapData 上的宽度 - * @param bitmapHeight {number} 纹理区域在 bitmapData 上的高度 - * @param offsetX {number} 原始位图的非透明区域 x 起始点 - * @param offsetY {number} 原始位图的非透明区域 y 起始点 - * @param textureWidth {number} 原始位图的高度,若不传入,则使用 bitmapWidth 的值。 - * @param textureHeight {number} 原始位图的宽度,若不传入,则使用 bitmapHeight 的值。 - * @returns {egret.Texture} 创建的 Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createTexture(name: string, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX?: number, offsetY?: number, textureWidth?: number, textureHeight?: number): Texture; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispose(): void; - } -} -declare namespace egret { - /** - * @private - */ - let $locale_strings: any; - /** - * @private - */ - let $language: string; -} -declare namespace egret.sys { - /** - * @private - * 全局多语言翻译函数 - * @param code 要查询的字符串代码 - * @param args 替换字符串中{0}标志的参数列表 - * @returns 返回拼接后的字符串 - */ - function tr(code: number, ...args: any[]): string; -} -declare namespace egret { - /** - * The Bitmap class represents display objects that represent bitmap images. - * The Bitmap() constructor allows you to create a Bitmap object that contains a reference to a BitmapData object. - * After you create a Bitmap object, use the addChild() or addChildAt() method of the parent DisplayObjectContainer - * instance to place the bitmap on the display list.A Bitmap object can share its texture reference among several - * Bitmap objects, independent of translation or rotation properties. Because you can create multiple Bitmap objects - * that reference the same texture object, multiple display objects can use the same complex texture object - * without incurring the memory overhead of a texture object for each display object instance. - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language en_US - */ - /** - * Bitmap 类表示用于显示位图图片的显示对象。 - * 利用 Bitmap() 构造函数,可以创建包含对 BitmapData 对象引用的 Bitmap 对象。创建了 Bitmap 对象后, - * 使用父级 DisplayObjectContainer 实例的 addChild() 或 addChildAt() 方法可以将位图放在显示列表中。 - * 一个 Bitmap 对象可在若干 Bitmap 对象之中共享其 texture 引用,与缩放或旋转属性无关。 - * 由于能够创建引用相同 texture 对象的多个 Bitmap 对象,因此,多个显示对象可以使用相同的 texture 对象, - * 而不会因为每个显示对象实例使用一个 texture 对象而产生额外内存开销。 - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language zh_CN - */ - class Bitmap extends DisplayObject { - /** - * Initializes a Bitmap object to refer to the specified Texture object. - * @param value The Texture object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 Texture 实例的 Bitmap 对象 - * @param value 被引用的 Texture 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(value?: Texture); - protected $texture: Texture; - $bitmapData: BitmapData; - protected $bitmapX: number; - protected $bitmapY: number; - protected $bitmapWidth: number; - protected $bitmapHeight: number; - protected $offsetX: number; - protected $offsetY: number; - protected $textureWidth: number; - protected $textureHeight: number; - protected $sourceWidth: number; - protected $sourceHeight: number; - protected $smoothing: boolean; - protected $explicitBitmapWidth: number; - protected $explicitBitmapHeight: number; - protected createNativeDisplayObject(): void; - /** - * @private - * 显示对象添加到舞台 - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * 显示对象从舞台移除 - */ - $onRemoveFromStage(): void; - /** - * The Texture object being referenced. - * If you pass the constructor of type BitmapData or last set for bitmapData, this value returns null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 Texture 对象。 - * 如果传入构造函数的类型为 BitmapData 或者最后设置的为 bitmapData,则此值返回 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - texture: Texture; - /** - * @private - */ - $setTexture(value: Texture): boolean; - $setBitmapData(value: any): void; - /** - * @private - */ - protected setBitmapDataToWasm(data?: Texture): void; - /** - * @private - */ - $refreshImageData(): void; - /** - * @private - */ - private setImageData(bitmapData, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, sourceWidth, sourceHeight); - /** - * @private - */ - $scale9Grid: egret.Rectangle; - /** - * Represent a Rectangle Area that the 9 scale area of Image. - * Notice: This property is valid only when fillMode - * is BitmapFillMode.SCALE. - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形区域,它定义素材对象的九个缩放区域。 - * 注意:此属性仅在fillModeBitmapFillMode.SCALE时有效。 - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scale9Grid: egret.Rectangle; - protected $setScale9Grid(value: egret.Rectangle): void; - /** - * @private - */ - $fillMode: string; - /** - * Determines how the bitmap fills in the dimensions. - *

When set to BitmapFillMode.REPEAT, the bitmap - * repeats to fill the region.

- *

When set to BitmapFillMode.SCALE, the bitmap - * stretches to fill the region.

- * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 确定位图填充尺寸的方式。 - *

设置为 BitmapFillMode.REPEAT时,位图将重复以填充区域。

- *

设置为 BitmapFillMode.SCALE时,位图将拉伸以填充区域。

- * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - fillMode: string; - $setFillMode(value: string): boolean; - /** - * The default value of whether or not is smoothed when scaled. - * When object such as Bitmap is created,smoothing property will be set to this value. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理的默认值。 - * 在 Bitmap 等对象创建时,smoothing 属性会被设置为该值。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - static defaultSmoothing: boolean; - /** - * Whether or not the bitmap is smoothed when scaled. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否对位图进行平滑处理。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - smoothing: boolean; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - /** - * @private - * 获取显示宽度 - */ - $getHeight(): number; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $updateRenderNode(): void; - private _pixelHitTest; - /** - * Specifies whether this object use precise hit testing by checking the alpha value of each pixel.If pixelHitTest - * is set to true,the transparent area of the bitmap will be touched through.
- * Note:If the image is loaded from cross origin,that we can't access to the pixel data,so it might cause - * the pixelHitTest property invalid. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否开启精确像素碰撞。设置为true显示对象本身的透明区域将能够被穿透。
- * 注意:若图片资源是以跨域方式从外部服务器加载的,将无法访问图片的像素数据,而导致此属性失效。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pixelHitTest: boolean; - $hitTest(stageX: number, stageY: number): DisplayObject; - } -} -declare namespace egret.sys { - /** - * @private - * 渲染节点类型 - */ - const enum RenderNodeType { - /** - * 位图渲染节点 - */ - BitmapNode = 1, - /** - * 文本渲染节点 - */ - TextNode = 2, - /** - * 矢量渲染节点 - */ - GraphicsNode = 3, - /** - * 组渲染节点 - */ - GroupNode = 4, - /** - * Mesh 节点 - */ - MeshNode = 5, - /** - * 普通位图渲染节点 - */ - NormalBitmapNode = 6, - } - /** - * @private - * 渲染节点基类 - */ - class RenderNode { - /** - * 节点类型.. - */ - type: number; - /** - * 绘制数据 - */ - drawData: any[]; - /** - * 绘制次数 - */ - protected renderCount: number; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - $getRenderCount(): number; - } -} -declare namespace egret.sys { - /** - * @private - * 路径类型 - */ - const enum PathType { - /** - * 纯色填充路径 - */ - Fill = 1, - /** - * 渐变填充路径 - */ - GradientFill = 2, - /** - * 线条路径 - */ - Stroke = 3, - } - /** - * @private - * 2D路径命令 - */ - const enum PathCommand { - MoveTo = 1, - LineTo = 2, - CurveTo = 3, - CubicCurveTo = 4, - } - /** - * @private - * 2D路径 - */ - class Path2D { - /** - * 路径类型 - */ - type: number; - $commands: number[]; - $data: number | number[][]; - protected commandPosition: number; - protected dataPosition: number; - /** - * 当前移动到的坐标X - * 注意:目前只有drawArc之前会被赋值 - */ - $lastX: number; - /** - * 当前移动到的坐标Y - * 注意:目前只有drawArc之前会被赋值 - */ - $lastY: number; - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - moveTo(x: number, y: number): void; - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - lineTo(x: number, y: number): void; - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - */ - curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - */ - cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - drawRect(x: number, y: number, width: number, height: number): void; - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - */ - drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - */ - drawCircle(x: number, y: number, radius: number): void; - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - drawEllipse(x: number, y: number, width: number, height: number): void; - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - */ - drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean): void; - /** - * 绘制一段圆弧路径 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radiusX 圆弧的半径 x。 - * @param radiusY 圆弧的半径 y。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意:必须为正数。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意:与startAngle差值必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * 注意:如果为true,endAngle必须小于startAngle,反之必须大于。 - */ - private arcToBezier(x, y, radiusX, radiusY, startAngle, endAngle, anticlockwise?); - } -} -declare namespace egret { - /** - * Writes an error message to the console if the assertion is false. If the assertion is true, nothing will happen. - * @param assertion Any boolean expression. If the assertion is false, the message will get written to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 判断参数assertion是否为true,若为false则抛出异常并且在console输出相应信息,反之什么也不做。 - * @param assertion 一个 boolean 表达式,若结果为false,则抛出错误并输出信息。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外可选信息 - * @language zh_CN - */ - function assert(assertion?: boolean, message?: string, ...optionalParams: any[]): void; - /** - * Writes a warning message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个警告信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function warn(message?: any, ...optionalParams: any[]): void; - /** - * Writes an error message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个错误信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function error(message?: any, ...optionalParams: any[]): void; - /** - * Writes an message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个日志信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function log(message?: any, ...optionalParams: any[]): void; -} -/** - * @private - */ -declare namespace egret { - /** - * @private - */ - let fontMapping: {}; -} -/** - * @private - */ -declare namespace egret_native { - function readUpdateFileSync(filePath: any): any; - function readResourceFileSync(filePath: any): any; - function sendInfoToPlugin(info: string): void; - function receivedPluginInfo(info: string): void; - function nrInit(): void; - function nrDownloadBuffers(callback: (displayCmdBuffer: Float32Array) => void): void; - function nrSetRenderMode(mode: number): void; - function nrRenderDisplayObject(id: number, scale: number, useClip: boolean, clipX: number, clipY: number, clipW: number, clipH: number): void; - function nrRenderDisplayObject2(id: number, offsetX: number, offsetY: number, forHitTest: boolean): void; - function nrLocalToGlobal(id: number, localX: number, localY: number): string; - function nrGlobalToLocal(id: number, globalX: number, globalY: number): string; - function nrGetTextFieldWidth(id: number): number; - function nrGetTextFieldHeight(id: number): number; - function nrGetTextWidth(id: number): number; - function nrGetTextHeight(id: number): number; - function nrResize(width: number, height: number): void; - function nrSetCanvasScaleFactor(factor: number, scalex: number, scaley: number): void; - function nrUpdate(): void; - function nrRender(): void; - function nrSendTextFieldData(textFieldId: number, strData: string): void; - function nrUpdateCallbackList(dt: number): void; - function nrActiveBuffer(id: number, width: number, height: number): void; - function nrGetPixels(x: number, y: number, width: number, height: number, pixels: Uint8Array): void; - function nrGetCustomImageId(type: number): number; - function nrSetCustomImageData(customImageId: number, pvrtcData: any, width: any, height: any, mipmapsCount: any, format: any): void; - class NrNode { - constructor(id: number, type: number); - } -} -/** - * @private - */ -declare namespace egret_native { - let rootWebGLBuffer: egret.sys.RenderBuffer; - let forHitTest: boolean; - let addModuleCallback: (callback: Function, thisObj: any) => void; - let initNativeRender: () => void; - let updateNativeRender: () => void; - let activateBuffer: (buffer: egret.sys.RenderBuffer) => void; - let getJsCustomFilterVertexSrc: (key: any) => any; - let getJsCustomFilterFragSrc: (key: any) => any; - let getJsCustomFilterUniforms: (key: any) => any; - let nrABIVersion: number; - let nrMinEgretVersion: string; -} -declare namespace egret_native { - /** - * @private - */ - class NativeRenderSurface { - width: number; - height: number; - constructor(currRenderBuffer: any, w?: number, h?: number, root?: boolean); - resize(w: number, h: number): void; - } - /** - * @private - */ - class NativeBitmapData { - $init(): any; - $id: any; - } - /** - * @private - */ - class NativeDisplayObject { - id: number; - constructor(type: number); - setChildrenSortMode(mode: string): void; - addChildAt(childId: number, index: number): void; - removeChild(childId: number): void; - swapChild(index1: number, index2: number): void; - setX(value: number): void; - setY(value: number): void; - setRotation(value: number): void; - setScaleX(value: number): void; - setScaleY(value: number): void; - setSkewX(value: number): void; - setSkewY(value: number): void; - setAlpha(value: number): void; - setAnchorOffsetX(value: number): void; - setAnchorOffsetY(value: number): void; - setVisible(value: boolean): void; - setBlendMode(value: number): void; - setMaskRect(x: number, y: number, w: number, h: number): void; - setScrollRect(x: number, y: number, w: number, h: number): void; - setFilters(filters: Array): void; - static createFilter(filter: egret.Filter): void; - static setFilterPadding(filterId: number, paddingTop: number, paddingBottom: number, paddingLeft: number, paddingRight: number): void; - setMask(value: number): void; - static setSourceToNativeBitmapData(nativeBitmapData: egret_native.NativeBitmapData, source: any): any; - setTexture(texture: egret.Texture): void; - setBitmapDataToMesh(texture: egret.Texture): void; - setBitmapDataToParticle(texture: egret.Texture): void; - setWidth(value: number): void; - setHeight(value: number): void; - setCacheAsBitmap(value: boolean): void; - setBitmapFillMode(fillMode: string): void; - setScale9Grid(x: number, y: number, w: number, h: number): void; - setMatrix(a: number, b: number, c: number, d: number, tx: number, ty: number): void; - setIsTyping(value: boolean): void; - setDataToBitmapNode(id: number, texture: egret.Texture, arr: number[]): void; - setDataToMesh(vertexArr: number[], indiceArr: number[], uvArr: number[]): void; - static setDataToFilter(currFilter: egret.Filter): void; - static disposeNativeBitmapData(nativeBitmapData: egret_native.NativeBitmapData): void; - static disposeTextData(node: egret.TextField): void; - static disposeGraphicData(graphic: egret.Graphics): void; - setFontSize(value: number): void; - setLineSpacing(value: number): void; - setTextColor(value: number): void; - setTextFieldWidth(value: number): void; - setTextFieldHeight(value: number): void; - setFontFamily(value: string): void; - setTextFlow(textArr: Array): void; - setTextAlign(value: string): void; - setVerticalAlign(value: string): void; - setText(value: string): void; - setBold(value: boolean): void; - setItalic(value: boolean): void; - setWordWrap(value: boolean): void; - setMaxChars(value: number): void; - setType(value: string): void; - setStrokeColor(value: number): void; - setStroke(value: number): void; - setScrollV(value: number): void; - setMultiline(value: boolean): void; - setBorder(value: boolean): void; - setBorderColor(value: number): void; - setBackground(value: boolean): void; - setBackgroundColor(value: number): void; - setInputType(value: string): void; - setBeginFill(color: number, alpha?: number): void; - setBeginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix: egret.Matrix): void; - setEndFill(): void; - setLineStyle(thickness?: number, color?: number, alpha?: number, pixelHinting?: boolean, scaleMode?: string, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): void; - setDrawRect(x: number, y: number, width: number, height: number): void; - setDrawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - setDrawCircle(x: number, y: number, radius: number): void; - setDrawEllipse(x: number, y: number, width: number, height: number): void; - setMoveTo(x: number, y: number): void; - setLineTo(x: number, y: number): void; - setCurveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - setCubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - setDrawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - setGraphicsClear(): void; - } -} -/** - * @private - */ -declare namespace egret_native { - /** - * @private - */ - const enum NativeObjectType { - /** - * 容器 - */ - CONTAINER = 0, - /** - * 位图 - */ - BITMAP = 1, - /** - * 位图数据 - */ - BITMAP_DATA = 2, - /** - * 滤镜 - */ - FILTER = 6, - /** - * 文本 - */ - TEXT = 7, - /** - * 矢量绘图 - */ - GRAPHICS = 8, - /** - * 含一个适量绘图的容器 - */ - SPRITE = 9, - /** - * 粒子系统 - */ - PARTICLE_SYSTEM = 10, - /** - * 位图文本 - */ - BITMAP_TEXT = 11, - /** - * 网格 - */ - MESH = 12, - /** - * 舞台(根容器) - */ - STAGE = 13, - } -} -declare namespace egret { - /** - * @private - */ - interface MapLike { - [key: string]: T; - [key: number]: T; - } - /** - * @private - */ - function createMap(): MapLike; -} -declare namespace egret { - /** - * @class egret.GlowFilter - * @classdesc - * 使用 GlowFilter 类可以对显示对象应用发光效果。在投影滤镜的 distance 和 angle 属性设置为 0 时,发光滤镜与投影滤镜极为相似。 - * @extends egret.Filter - * @version Egret 3.1.4 - * @platform Web,Native - */ - class GlowFilter extends Filter { - /** - * @private - */ - $red: number; - /** - * @private - */ - $green: number; - /** - * @private - */ - $blue: number; - /** - * Initializes a new GlowFilter instance. - * @method egret.GlowFilter#constructor - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 GlowFilter 对象 - * @method egret.GlowFilter#constructor - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - constructor(color?: number, alpha?: number, blurX?: number, blurY?: number, strength?: number, quality?: number, inner?: boolean, knockout?: boolean); - /** - * @private - */ - $color: number; - /** - * The color of the glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 光晕颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - color: number; - /** - * @private - */ - $alpha: number; - /** - * The alpha transparency value for the color. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 颜色的 Alpha 透明度值。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - alpha: number; - /** - * @private - */ - $blurX: number; - /** - * The amount of horizontal blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - blurX: number; - /** - * @private - */ - $blurY: number; - /** - * The amount of vertical blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - blurY: number; - /** - * @private - */ - $strength: number; - /** - * The strength of the imprint or spread. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 印记或跨页的强度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - strength: number; - /** - * @private - */ - $quality: number; - /** - * The number of times to apply the filter. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 应用滤镜的次数。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - quality: number; - /** - * @private - */ - $inner: boolean; - /** - * Specifies whether the glow is an inner glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定发光是否为内侧发光。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - inner: boolean; - /** - * @private - */ - $knockout: boolean; - /** - * Specifies whether the object has a knockout effect. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定对象是否具有挖空效果。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - knockout: boolean; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - } -} -declare namespace egret { - /** - * The Stage class represents the main drawing area.The Stage object is not globally accessible. You need to access - * it through the stage property of a DisplayObject instance.
- * The Stage class has several ancestor classes — Sprite, DisplayObject, and EventDispatcher — from which it inherits - * properties and methods. Many of these properties and methods are inapplicable to Stage objects. - * @event egret.Event.RESIZE Dispatched when the stageWidth or stageHeight property of the Stage object is changed. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language en_US - */ - /** - * Stage 类代表主绘图区。 - * 可以利用 DisplayObject 实例的 stage 属性进行访问。
- * Stage 类具有多个祖代类: Sprite、DisplayObject 和 EventDispatcher,属性和方法便是从这些类继承而来的。 - * 从这些继承的许多属性和方法不适用于 Stage 对象。 - * @event egret.Event.RESIZE 当stageWidth或stageHeight属性发生改变时调度 - * @event egret.Event.DEACTIVATE 当stage失去焦点后调度 - * @event egret.Event.ACTIVATE 当stage获得焦点后调度 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language zh_CN - */ - class Stage extends DisplayObjectContainer { - /** - * @private - * Stage不许允许自行实例化 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * Gets and sets the frame rate of the stage. The frame rate is defined as frames per second. Valid range for the - * frame rate is from 0.01 to 1000 frames per second.
- * Note: setting the frameRate property of one Stage object changes the frame rate for all Stage objects - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取并设置舞台的帧速率。帧速率是指每秒显示的帧数。帧速率的有效范围为每秒 0.01 到 60 个帧。
- * 注意: 修改任何一个Stage的frameRate属性都会同步修改其他Stage的帧率。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - frameRate: number; - /** - * @private - */ - $stageWidth: number; - /** - * Indicates the width of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前宽度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageWidth: number; - /** - * @private - */ - $stageHeight: number; - /** - * Indicates the height of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageHeight: number; - /** - * After you call the invalidate() method, when the display list is next rendered, the Egret runtime sends a render - * event to each display object that has registered to listen for the render event. You must call the invalidate() - * method each time you want the Egret runtime to send render events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用 invalidate() 方法后,在显示列表下次呈现时,Egret 会向每个已注册侦听 Event.RENDER 事件的显示对象发送一个 Event.RENDER 事件。 - * 每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 invalidate() 方法。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - invalidate(): void; - /** - * @deprecated - */ - registerImplementation(interfaceName: string, instance: any): void; - /** - * @deprecated - */ - getImplementation(interfaceName: string): any; - /** - * @private - * 设备屏幕引用 - */ - $screen: egret.sys.Screen; - $scaleMode: string; - /** - * A StageScaleMode class that specifies which scale mode to use. The following are valid values:
- *
    - *
  • StageScaleMode.EXACT_FIT -- The entire application be visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, the application may be stretched or compressed.
  • - *
  • StageScaleMode.SHOW_ALL -- The entire application is visible in the specified area without distortion while maintaining the application of the original aspect ratio. Applications may display border.
  • - *
  • StageScaleMode.NO_SCALE -- The size of the entire application is fixed, so that even if the size of the player window changes, it remains unchanged. If the player window is smaller than the content, it may do some trimming.
  • - *
  • StageScaleMode.NO_BORDER -- Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
  • - *
  • StageScaleMode.FIXED_WIDTH -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
  • - *
  • StageScaleMode.FIXED_HEIGHT -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
  • - *
- * @default egret.StageScaleMode.SHOW_ALL - * @language en_US - */ - /** - * 一个 StageScaleMode 类中指定要使用哪种缩放模式的值。以下是有效值:
- *
    - *
  • StageScaleMode.EXACT_FIT -- 整个应用程序在指定区域中可见,但不尝试保持原始高宽比。可能会发生扭曲,应用程序可能会拉伸或压缩显示。
  • - *
  • StageScaleMode.SHOW_ALL -- 整个应用程序在指定区域中可见,且不发生扭曲,同时保持应用程序的原始高宽比。应用程序的可能会显示边框。
  • - *
  • StageScaleMode.NO_SCALE -- 整个应用程序的大小固定,因此,即使播放器窗口的大小更改,它也会保持不变。如果播放器窗口比内容小,则可能进行一些裁切。
  • - *
  • StageScaleMode.NO_BORDER -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
  • - *
  • StageScaleMode.FIXED_WIDTH -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
  • - *
  • StageScaleMode.FIXED_HEIGHT -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
  • - *
- * @default egret.StageScaleMode.SHOW_ALL - * @language zh_CN - */ - scaleMode: string; - $orientation: string; - /** - * Horizontal and vertical screen display screen, can only be set under the current Native in the configuration file. A egret.OrientationMode class that specifies which display mode to use. The following are valid values:
- *
    - *
  • egret.OrientationMode.AUTO -- Always follow the direction of application display screen, always guaranteed by the look down.
  • - *
  • egret.OrientationMode.PORTRAIT -- Applications remain portrait mode, namely horizontal screen look, the screen from left to right.
  • - *
  • egret.OrientationMode.LANDSCAPE -- Applications remain horizontal screen mode, namely vertical screen, the screen from right to left.
  • - *
  • egret.OrientationMode.LANDSCAPE_FLIPPED -- Applications remain horizontal screen mode, namely vertical screen, the screen from left to right.
  • - *
- * @platform Web - * @version 2.4 - * @language en_US - */ - /** - * 屏幕横竖屏显示方式,目前 Native 下只能在配置文件里设置。一个 egret.OrientationMode 类中指定要使用哪种显示方式。以下是有效值:
- *
    - *
  • egret.OrientationMode.AUTO -- 应用始终跟随屏幕的方向显示,始终保证由上往下看。
  • - *
  • egret.OrientationMode.PORTRAIT -- 应用始终保持竖屏模式,即横屏看时,屏幕由左往右看。
  • - *
  • egret.OrientationMode.LANDSCAPE -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由右往左。
  • - *
  • egret.OrientationMode.LANDSCAPE_FLIPPED -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由左往右。
  • - *
- * @platform Web - * @version 2.4 - * @language zh_CN - */ - orientation: string; - /** - * Draw texture zoom ratio - * @default 1 - * @language en_US - */ - /** - * 绘制纹理的缩放比率,默认值为1 - * @default 1 - * @language zh_CN - */ - textureScaleFactor: number; - $maxTouches: number; - /** - * Set the number of screens can simultaneously touch. Above this amount will not be triggered in response. - * @default 99 - * @language en_US - */ - /** - * 设置屏幕同时可以触摸的数量。高于这个数量将不会被触发响应。 - * @default 99 - * @language zh_CN - */ - maxTouches: number; - /** - * Set resolution size - * @param width width - * @param height height - * @version Egret 2.5.5 - * @platform Web,Native - * @language en_US - */ - /** - * 设置分辨率尺寸 - * @param width 宽度 - * @param height 高度 - * @version Egret 2.5.5 - * @platform Web,Native - * @language zh_CN - */ - setContentSize(width: number, height: number): void; - } -} -declare namespace egret { - /** - * A class that provides constant values for visual blend mode effects. These constants are used in the blendMode - * property of the DisplayObject class. - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language en_US - */ - /** - * 提供混合模式可视效果的常量值的类,通常用于 DisplayObject 的 blendMode 属性上。 - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language zh_CN - */ - class BlendMode { - /** - * The display object appears in front of the background. Pixel values of the display object override the pixel - * values of the background. Where the display object is transparent, the background is visible. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该显示对象出现在背景前面。显示对象的像素值会覆盖背景的像素值。在显示对象为透明的区域,背景是可见的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static NORMAL: string; - /** - * Adds the values of the constituent colors of the display object to the colors of its background, applying a - * ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between two objects.
- * For example, if the display object has a pixel with an RGB value of 0xAAA633, and the background pixel has an - * RGB value of 0xDD2200, the resulting RGB value for the displayed pixel is 0xFFC833 (because 0xAA + 0xDD > 0xFF, - * 0xA6 + 0x22 = 0xC8, and 0x33 + 0x00 = 0x33). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的原色值添加到它的背景颜色中,上限值为 0xFF。此设置通常用于使两个对象间的加亮溶解产生动画效果。
- * 例如,如果显示对象的某个像素的 RGB 值为 0xAAA633,背景像素的 RGB 值为 0xDD2200,则显示像素的结果 RGB 值为 0xFFC833 - * (因为 0xAA + 0xDD > 0xFF,0xA6 + 0x22 = 0xC8,且 0x33 + 0x00 = 0x33)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADD: string; - /** - * Erases the background based on the alpha value of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据显示对象的 Alpha 值擦除背景。Alpha 值不为0的区域将被擦除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ERASE: string; - } -} -declare namespace egret.sys { - /** - * @private - * 转换 blendMode 字符串为数字。 - */ - function blendModeToNumber(blendMode: string): number; - /** - * @private - * 转换数字为 blendMode 字符串。 - */ - function numberToBlendMode(blendMode: number): string; -} -declare namespace egret { - /** - * The ChildrenSortMode class defines a pattern enumeration for children sort mode of egret.DisplayObjectContainer. - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * BitmapFillMode 类定义egret.DisplayObjectContainer的子项目排序方式。 - * @version Egret 5.2.19 - * @platform Native - * @language zh_CN - */ - const ChildrenSortMode: { - DEFAULT: string; - INCREASE_Y: string; - DECREASE_Y: string; - }; -} -declare namespace egret { - /** - * The CapsStyle class is an enumeration of constant values that specify the caps style to use in drawing lines. - * The constants are provided for use as values in the caps parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * CapsStyle 类是可指定在绘制线条中使用的端点样式的常量值枚举。常量可用作 egret.Graphics.lineStyle() 方法的 caps 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - const CapsStyle: { - NONE: string; - ROUND: string; - SQUARE: string; - }; -} -declare namespace egret { - /** - * @private - */ - class WebGLUtils { - static compileProgram(gl: WebGLRenderingContext, vertexSrc: string, fragmentSrc: string): WebGLProgram; - static compileFragmentShader(gl: WebGLRenderingContext, shaderSrc: string): WebGLShader; - static compileVertexShader(gl: WebGLRenderingContext, shaderSrc: string): WebGLShader; - private static _compileShader(gl, shaderSrc, shaderType); - private static canUseWebGL; - static checkCanUseWebGL(): boolean; - static deleteWebGLTexture(webglTexture: WebGLTexture): void; - /** - * inspired by pixi.js - */ - static premultiplyTint(tint: number, alpha: number): number; - } -} -declare namespace egret { - /** - * The EventPhase class provides values for the eventPhase property of the Event class. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventPhase.ts - * @language en_US - */ - /** - * EventPhase 可为 Event 类的 eventPhase 属性提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventPhase.ts - * @language zh_CN - */ - const enum EventPhase { - /** - * The capturing phase, which is the first phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 捕获阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - CAPTURING_PHASE = 1, - /** - * The target phase, which is the second phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 目标阶段,是事件流的第二个阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - AT_TARGET = 2, - /** - * The bubbling phase, which is the third phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 冒泡阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BUBBLING_PHASE = 3, - } -} -declare namespace egret { - /** - * When the user changes the focus from one object in the display list to another object, the object dispatches a FocusEvent object. Currently only supports input text. - * Focus events: FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用户将焦点从显示列表中的一个对象更改到另一个对象时,对象将调度 FocusEvent 对象。目前只支持输入文本。 - * 焦点事件:FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class FocusEvent extends egret.Event { - /** - * Gets focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_IN: "focusIn"; - /** - * Loses focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_OUT: "focusOut"; - /** - * Create a egret.FocusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.FocusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - } -} -declare namespace egret { - interface Geolocation { - addEventListener(type: "ioError", listener: (this: Z, e: GeolocationEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * The GeolocationEvent represents the position and altitude of the device on Earth, - * and show errors occurred while getting the location of the device. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language en_US - */ - /** - * GeolocationEvent 提供设备的地理位置信息和获取位置时发生的错误信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language zh_CN - */ - class GeolocationEvent extends Event { - /** - * The acquisition of the location information failed because of app don't have permission. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由于用户拒绝访问位置信息,获取位置信息失败 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static PERMISSION_DENIED: string; - /** - * The acquisition of the location failed because at least one internal source of position returned an internal error. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设备位置服务不可用或者超时等原因没有得到位置信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static UNAVAILABLE: string; - /** - * The position's longitude in decimal degrees. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前位置的经度信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - longitude: number; - /** - * The position's latitude in decimal degrees. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前位置的纬度信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - latitude: number; - /** - * The velocity of the device in meters per second. This value can be null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前设备的速度 单位是 米/秒,这个值可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - speed: number; - /** - * The direction in which the device is traveling. This value, specified in degrees, - * indicates how far off from heading due north the device is. 0 degrees represents - * true true north, and the direction is determined clockwise (which means that east - * is 90 degrees and west is 270 degrees). If speed is 0, heading is NaN. If the - * device is unable to provide heading information, this value is null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备正在前进的方向,单位是度。heading 表示从正北开始顺时针旋转到当前方向的角度, - * 比如正东是 90 度,正西是 270 度,如果 speed 是 0,heading 为 NaN。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - heading: number; - /** - * The position's altitude in metres, relative to sea level. - * This value can be null if the implementation cannot provide the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该位置的海拔信息,如果设备没有实现这个属性时,这个值有可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - altitude: number; - /** - * The accuracy of the latitude and longitude properties, expressed in meters. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 经纬度的准确性,单位是米 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - accuracy: number; - /** - * The accuracy of the altitude expressed in meters. This value can be null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该位置海拔信息的准确性,单位是米,这个值有可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - altitudeAccuracy: number; - /** - * The type of error occurred while get the location of the device. The value could be: - * @see egret.GeolocationEvent.PERMISSION_DENIED - * @see egret.GeolocationEvent.UNAVAILABLE - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位置信息错误时的错误类型。值可能为: - * @see egret.GeolocationEvent.PERMISSION_DENIED - * @see egret.GeolocationEvent.UNAVAILABLE - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - errorType: string; - /** - * The error message occurred while get the location of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位置信息错误的错误信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - errorMessage: string; - } -} -declare namespace egret { - /** - * When a network request returns an HTTP status code, the application dispatches HTTPStatusEvent objects. - * Before error or completion events will always send HTTPStatusEvent object. HTTPStatusEvent object does not necessarily indicate an error condition; it simply reflects the HTTP status code provided by the network stack (if any). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在网络请求返回 HTTP 状态代码时,应用程序将调度 HTTPStatusEvent 对象。 - * 在错误或完成事件之前,将始终发送 HTTPStatusEvent 对象。HTTPStatusEvent 对象不一定表示错误条件;它仅反映网络堆栈提供的 HTTP 状态代码(如果有的话)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HTTPStatusEvent extends Event { - /** - * HTTPStatusEvent.HTTP_STATUS constant defines the value of the type property httpStatus event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HTTPStatusEvent.HTTP_STATUS 常量定义 httpStatus 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static HTTP_STATUS: "httpStatus"; - /** - * Create a egret.HTTPStatusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.HTTPStatusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * @private - */ - private _status; - /** - * he server returns the HTTP status code. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由服务器返回的 HTTP 状态代码。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly status: number; - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param status {number} The server returns the HTTP status code - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param status {number} 由服务器返回的 HTTP 状态代码 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchHTTPStatusEvent(target: IEventDispatcher, status: number): boolean; - } -} -declare namespace egret { - /** - * The IEventDispatcher interface defines methods for adding or removing event listeners, checks whether specific types - * of event listeners are registered, and dispatches events. Event targets are an important part of the Egret event model. - * The event target serves as the focal point for how events flow through the display list hierarchy. When an event - * such as a touch tap occurs, an event object is dispatched into the event flow from the root of the display list. - * The event object makes a round-trip journey to the event target, which is conceptually divided into three phases:
- * the capture phase includes the journey from the root to the last node before the event target's node; the target - * phase includes only the event target node; and the bubbling phase includes any subsequent nodes encountered on the - * return trip to the root of the display list.In general, the easiest way for a user-defined class to gain event - * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already - * extending another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, - * and write simple hooks to route calls into the aggregated EventDispatcher. - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IEventDispatcher.ts - * @language en_US - */ - /** - * IEventDispatcher 接口定义用于添加或删除事件侦听器的方法,检查是否已注册特定类型的事件侦听器,并调度事件。 - * 事件目标是 Egret 事件模型的重要组成部分。事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生触摸轻拍事件时, - * 会将事件对象调度到从显示列表根开始的事件流中。事件对象进行到事件目标的往返行程,在概念上,此往返行程被划分为三个阶段:
- * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括到显示列表的根的回程上遇到的任何后续节点。 - * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类), - * 则可以实现 IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的挂钩,将调用连接到聚合的 EventDispatcher 中。 - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IEventDispatcher.ts - * @language zh_CN - */ - interface IEventDispatcher extends HashObject { - /** - * Registers an event listener object with an EventDispatcher object so that the listener receives notification of an - * event. You can register event listeners on all nodes in the display list for a specific type of event, phase, - * and priority.After you successfully register an event listener, you cannot change its priority through additional - * calls to on(). To change a listener's priority, you must first call removeEventListener(). Then you can register the - * listener again with the new priority level.After the listener is registered, subsequent calls to on() with a - * different value for either type or useCapture result in the creation of a separate listener registration.
- * When you no longer need an event listener, remove it by calling EventDispatcher.removeEventListener(); otherwise, memory - * problems might result. Objects with registered event listeners are not automatically removed from memory because - * the garbage collector does not remove objects that still have references.Copying an EventDispatcher instance does - * not copy the event listeners attached to it. (If your newly created node needs an event listener, you must attach - * the listener after creating the node.) However, if you move an EventDispatcher instance, the event listeners attached - * to it move along with it.If the event listener is being registered on a node while an event is also being processed - * on this node, the event listener is not triggered during the current phase but may be triggered during a later phase - * in the event flow, such as the bubbling phase.If an event listener is removed from a node while an event is being - * processed on the node, it is still triggered by the current actions. After it is removed, the event listener is - * never invoked again (unless it is registered again for future processing). - * @param type The type of event. - * @param listener The listener function that processes the event. This function must accept an event object as - * its only parameter and must return nothing, as this example shows: function(evt:Event):void The function can - * have any name. - * @param thisObject the listener function's "this" - * @param useCapture Determines whether the listener works in the capture phase or the bubbling phases. If useCapture - * is set to true, the listener processes the event only during the capture phase and not in the bubbling phase. - * If useCapture is false, the listener processes the event only during the bubbling phase. To listen for the event - * in all three phases, call on() twice, once with useCapture set to true, then again with useCapture set to false. - * @param priority The priority level of the event listener. Priorities are designated by a integer. The higher - * the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. - * If two or more listeners share the same priority, they are processed in the order in which they were added. - * The default priority is - * @see #once() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。可以为特定类型的事件、阶段和优先级在显示列表的所有节 - * 点上注册事件侦听器。成功注册一个事件侦听器后,无法通过额外调用 on() 来更改其优先级。要更改侦听器的优先级,必须 - * 先调用 removeEventListener()。然后,可以使用新的优先级再次注册该侦听器。注册该侦听器后,如果继续调用具有不同 type 或 useCapture - * 值的 on(),则会创建单独的侦听器注册。
- * 如果不再需要某个事件侦听器,可调用 EventDispatcher.removeEventListener() - * 删除它;否则会产生内存问题。由于垃圾回收器不会删除仍包含引用的对象,因此不会从内存中自动删除使用已注册事件侦听器的对象。复制 - * EventDispatcher 实例时并不复制其中附加的事件侦听器。(如果新近创建的节点需要一个事件侦听器,必须在创建该节点后附加该侦听器。) - * 但是,如果移动 EventDispatcher 实例,则其中附加的事件侦听器也会随之移动。如果在正在处理事件的节点上注册事件侦听器,则不会在当 - * 前阶段触发事件侦听器,但会在事件流的稍后阶段触发,如冒泡阶段。如果从正在处理事件的节点中删除事件侦听器,则该事件侦听器仍由当前操 - * 作触发。删除事件侦听器后,决不会再次调用该事件侦听器(除非再次注册以备将来处理)。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在冒泡阶段处理事件。 - * 要在两个阶段都侦听事件,请调用 on() 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see #once() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Registers an event listener object with an EventDispatcher object so that the listener receives notification of an - * event. Different from the on() method,the listener receives notification only once,and then it will be removed - * automatically. - * @param type The type of event. - * @param listener The listener function that processes the event. This function must accept an event object as - * its only parameter and must return nothing, as this example shows: function(evt:Event):void The function can - * have any name. - * @param thisObject the listener function's "this" - * @param useCapture Determines whether the listener works in the capture phase or the bubbling phases. If useCapture - * is set to true, the listener processes the event only during the capture phase and not in the bubbling phase. - * If useCapture is false, the listener processes the event only during the bubbling phase. To listen for the event - * in all three phases, call on() twice, once with useCapture set to true, then again with useCapture set to false. - * @param priority The priority level of the event listener. Priorities are designated by a integer. The higher - * the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. - * If two or more listeners share the same priority, they are processed in the order in which they were added. - * The default priority is - * @see #on() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 添加仅回调一次的事件侦听器,此方法与on()方法不同,on()方法会持续产生回调,而此方法在第一次回调时就会自动移除监听。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在冒泡阶段处理事件。 - * 要在两个阶段都侦听事件,请调用 once() 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see #on() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - once(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Removes a listener from the EventDispatcher object. If there is no matching listener registered with the - * EventDispatcher object, a call to this method has no effect. - * @param type The type of event. - * @param listener The listener object to remove. - * @param thisObject the listener function's "this" - * @param useCapture Specifies whether the listener was registered for the capture phase or the bubbling phases. - * If the listener was registered for both the capture phase and the bubbling phases, two calls to removeEventListener() - * are required to remove both: one call with useCapture set to true, and another call with useCapture set to false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 EventDispatcher 对象中删除侦听器。如果没有向 EventDispatcher 对象注册任何匹配的侦听器,则对此方法的调用没有任何效果。 - * @param type 事件的类型。 - * @param listener 要删除的侦听器对象 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 指出是为捕获阶段还是为冒泡阶段注册了侦听器。如果为捕获阶段以及冒泡阶段注册了侦听器,则需要对 - * removeEventListener() 进行两次调用才能将这两个侦听器删除:一次调用将 useCapture 设置为 true,另一次调用将 useCapture 设置为 false。。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - /** - * Checks whether the EventDispatcher object has any listeners registered for a specific type of event. This allows - * you to determine where an EventDispatcher object has altered handling of an event type in the event flow hierarchy. - * To determine whether a specific event type will actually trigger an event listener, use IEventDispatcher.willTrigger(). - * The difference between hasEventListener() and willTrigger() is that hasEventListener() examines only the object to - * which it belongs, whereas willTrigger() examines the entire event flow for the event specified by the type parameter. - * @param type The type of event. - * @returns A value of true if a listener of the specified type is registered; false otherwise. - * @see #willTrigger() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。这样,您就可以确定 EventDispatcher 对象在事件流层次结构中的哪个 - * 位置改变了对事件类型的处理。要确定特定事件类型是否确实会触发事件侦听器,请使用 IEventDispatcher.willTrigger()。hasEventListener() - * 与 willTrigger() 的区别是:hasEventListener() 只检查它所属的对象,而 willTrigger() 检查整个事件流以查找由 type 参数指定的事件。 - * @param type 事件的类型。 - * @returns 如果指定类型的侦听器已注册,则值为 true;否则,值为 false。 - * @see #willTrigger() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - hasEventListener(type: string): boolean; - /** - * Dispatches an event into the event flow. The event target is the EventDispatcher object upon which dispatchEvent() is called. - * @param event The event object dispatched into the event flow. - * @returns A value of true unless preventDefault() is called on the event, in which case it returns false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将事件分派到事件流中。事件目标是对其调用 dispatchEvent() 方法的 EventDispatcher 对象。 - * @param event 调度到事件流中的 Event 对象。 - * @returns 如果成功调度了事件,则值为 true。值 false 表示失败或对事件调用了 preventDefault()。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispatchEvent(event: Event): boolean; - /** - * Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the - * specified event type. This method returns true if an event listener is triggered during any phase of the event - * flow when an event of the specified type is dispatched to this EventDispatcher object or any of its descendants. - * @param type The type of event. - * @returns A value of true if a listener of the specified type will be triggered; false otherwise. - * @see #hasEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查是否用此 EventDispatcher 对象或其任何始祖为指定事件类型注册了事件侦听器。将指定类型的事件调度给此 - * EventDispatcher 对象或其任一后代时,如果在事件流的任何阶段触发了事件侦听器,则此方法返回 true。 - * hasEventListener() 与 willTrigger() 方法的区别是:hasEventListener() 只检查它所属的对象, - * 而 willTrigger() 方法检查整个事件流以查找由 type 参数指定的事件。 - * @param type 事件类型 - * @returns 是否注册过监听器,如果注册过返回true,反之返回false - * @see #hasEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - willTrigger(type: string): boolean; - } -} -declare namespace egret { - interface HttpRequest { - addEventListener(type: "ioError", listener: (this: Z, e: IOErrorEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language en_US - */ - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language zh_CN - */ - class IOErrorEvent extends Event { - /** - * io error - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * io发生错误 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static IO_ERROR: "ioError"; - /** - * Create a egret.IOErrorEvent objects - * @param type {string} Type of event, accessible as Event.type. - * @param bubbles {boolean} Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable {boolean} Determine whether the Event object can be canceled. The default value is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.IOErrorEvent 对象 - * @param type {string} 事件的类型,可以作为 Event.type 访问。 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchIOErrorEvent(target: IEventDispatcher): boolean; - } -} -declare namespace egret { - /** - * MotionEvent represents the device's movement - * Acceleration and accelerationIncludingGravity to represents the device's acceleration - * RotationRate to represents the device's rotation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language en_US - */ - /** - * MotionEvent 类呈现设备运动的具体信息 - * Acceleration 和 accelerationIncludingGravity 呈现设备三个维度的加速度信息 - * RotationRate 呈现设备的旋转状态信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language zh_CN - */ - class MotionEvent extends Event { - /** - * An object giving the acceleration of the device on the three axis X, Y and Z. Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * acceleration 表示设备在 X Y Z 轴方将的加速度信息,单位是 m/s2,不包含重力 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - acceleration: DeviceAcceleration; - /** - * An object giving the acceleration of the device on the three axis X, Y and Z with the effect of gravity. Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * acceleration 表示设备在 X Y Z 轴方将的加速度信息,单位是 m/s2,包含重力 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - accelerationIncludingGravity: DeviceAcceleration; - /** - * An object giving the rate of change of the device's orientation on the three orientation axis alpha, beta and gamma. Rotation rate is express in degrees per seconds. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * rotationRate 表示设备在 alpha、 beta 和 gamma 三个轴向的角速度信息,单位是 角度每秒 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotationRate: DeviceRotationRate; - } -} -declare namespace egret { - /** - * The OrientationEvent provides information from the physical orientation of the device. - * Note: Currently, Browsers on the iOS and Android does not handle the coordinates the same way. - * Take care about this while using them. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language en_US - */ - /** - * OrientationEvent 提供设备的方向信息 - * 注意: 目前各个浏览器和操作系统处理方向的方式不完全相同,请根据使用场景做相应的校正, - * 比如使用两次方向数据的变化而不是直接使用方向的值 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language zh_CN - */ - class OrientationEvent extends Event { - /** - * A number representing the motion of the device around the z axis, - * express in degrees with values ranging from 0 to 360 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 Z 轴的角度,单位是 角度 范围是 0 到 360 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - alpha: number; - /** - * A number representing the motion of the device around the x axis, - * express in degrees with values ranging from -180 to 180. - * This represents a front to back motion of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 X 轴的角度,单位是 角度 范围是 -180 到 180. - * 这个值表示设备从前向后的旋转状态 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - beta: number; - /** - * A number representing the motion of the device around the y axis, - * express in degrees with values ranging from -90 to 90. - * This represents a left to right motion of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 Y 轴的角度,单位是 角度 范围是 -90 到 90. - * 这个值表示设备从前向后的旋转状态 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - gamma: number; - } -} -declare namespace egret { - interface HttpRequest { - addEventListener(type: "progress", listener: (this: Z, e: ProgressEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * When a load operation has begun or a socket has received data, ProgressEvent object is dispatched. - * There are two types of progress events: ProgressEvent.PROGRESS and ProgressEvent.SOCKET_DATA. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当加载操作已开始或套接字已接收到数据时,将调度 ProgressEvent 对象。 - * 有两种类型的进程事件:ProgressEvent.PROGRESS 和 ProgressEvent.SOCKET_DATA。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class ProgressEvent extends egret.Event { - /** - * Changes in the loading progress - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 加载进度发生变化 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static PROGRESS: "progress"; - /** - * Get the data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取到数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static SOCKET_DATA: "socketData"; - /** - * Number of items or bytes when the listener processes the event。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在侦听器处理事件时加载的项数或字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bytesLoaded: number; - /** - * If the loading process succeeds, the total number or the total number of bytes that will be loaded term. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果加载过程成功,将加载的总项数或总字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bytesTotal: number; - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, bytesLoaded?: number, bytesTotal?: number); - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param type The type of the event, accessible as Event.type. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchProgressEvent(target: IEventDispatcher, type: string, bytesLoaded?: number, bytesTotal?: number): boolean; - } -} -declare namespace egret { - interface Stage { - addEventListener(type: "orientationChange", listener: (this: Z, e: StageOrientationEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * When the direction of the stage of change, Stage object dispatches StageOrientationEvent object. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language en_US - */ - /** - * 当舞台的方向更改时,Stage 对象将调度 StageOrientationEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language zh_CN - */ - class StageOrientationEvent extends Event { - /** - * After screen rotation distribute events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 屏幕旋转后派发的事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ORIENTATION_CHANGE: "orientationChange"; - /** - * Creating contains specific information related to the event and the stage direction of StageOrientationEvent object. - * @param type Event types:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles It indicates whether the Event object participates in the bubbling stage of the event flow. - * @param cancelable It indicates whether the Event object can be canceled. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建包含与舞台方向事件相关的特定信息的 StageOrientationEvent 对象。 - * @param type 事件的类型:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles 表示 Event 对象是否参与事件流的冒泡阶段。 - * @param cancelable 表示是否可以取消 Event 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {egret.IEventDispatcher} 派发事件类型 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} Distribute event target - * @param type {egret.IEventDispatcher} Distribute event type - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchStageOrientationEvent(target: IEventDispatcher, type: string): boolean; - } -} -declare namespace egret { - /** - * When a user clicks a hyperlink rich text object dispatches TextEvent object. Text Event Type: TextEvent.LINK. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language en_US - */ - /** - * 用户在富文本中单击超链接时,对象将调度 TextEvent 对象。文本事件类型:TextEvent.LINK。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language zh_CN - */ - class TextEvent extends Event { - /** - * TextEvent create an object that contains information about text events. - * @param type Type of event, you can access the TextEvent.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determine whether the Event object can be canceled. The default value is false. - * @param text One or more characters of text entered by the user. Event listeners can access this information through the text property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TextEvent 对象,其中包含有关文本事件的信息。 - * @param type 事件的类型,可以作为 TextEvent.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param text 用户输入的一个或多个文本字符。事件侦听器可以通过 text 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, text?: string); - /** - * It defines the value of the type property of a link event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 定义 link 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LINK: "link"; - /** - * In TextEvent.LINK event, event corresponding string. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在 TextEvent.LINK 事件中,event对应的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * EventDispatcher object using the specified event object thrown TextEvent. The objects will be thrown in the object cache pool for the next round robin. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param text Text TextEvent object assignment - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出TextEvent事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件类型 - * @param text TextEvent对象的text赋值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTextEvent(target: IEventDispatcher, type: string, text: string): boolean; - } -} -declare namespace egret { - interface Timer { - addEventListener(type: "timer" | "timerComplete", listener: (this: Z, e: TimerEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * A Timer object dispatches a TimerEvent objects whenever the Timer object reaches the interval specified by the Timer.delay property. - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language en_US - */ - /** - * 每当 Timer 对象达到由 Timer.delay 属性指定的间隔时,Timer 对象即会调度 TimerEvent 对象。 - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language zh_CN - */ - class TimerEvent extends Event { - /** - * Dispatched whenever a Timer object reaches an interval specified according to the Timer.delay property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当 Timer 对象达到根据 Timer.delay 属性指定的间隔时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TIMER: "timer"; - /** - * Dispatched whenever it has completed the number of requests set by Timer.repeatCount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当它完成 Timer.repeatCount 设置的请求数后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TIMER_COMPLETE: "timerComplete"; - /** - * Creates an Event object with specific information relevant to timer events. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Event 对象,其中包含有关 timer 事件的特定信息。 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @example - *
-         *    function onTimer(event:TimerEvent):void {
-         *        if (40 < mySp.x && mySp.x < 375) {
-         *            mySp.x-= 50;
-         *        } else {
-         *            mySp.x=374;
-         *        }
-         *        event.updateAfterEvent();
-         *    }
-         *
-         *    let moveTimer:Timer=new Timer(50,250);
-         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
-         *    moveTimer.start();
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @example - *
-         *    function onTimer(event:TimerEvent):void {
-         *        if (40 < mySp.x && mySp.x < 375) {
-         *            mySp.x-= 50;
-         *        } else {
-         *            mySp.x=374;
-         *        }
-         *        event.updateAfterEvent();
-         *    }
-         *
-         *    let moveTimer:Timer=new Timer(50,250);
-         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
-         *    moveTimer.start();
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - updateAfterEvent(): void; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 事件派发目标 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTimerEvent(target: IEventDispatcher, type: string, bubbles?: boolean, cancelable?: boolean): boolean; - } -} -declare namespace egret { - class CompressedTextureData { - glInternalFormat: number; - width: number; - height: number; - byteArray: Uint8Array; - face: number; - level: number; - } - const etc_alpha_mask = "etc_alpha_mask"; - const engine_default_empty_texture = "engine_default_empty_texture"; - const is_compressed_texture = "is_compressed_texture"; - const glContext = "glContext"; - const UNPACK_PREMULTIPLY_ALPHA_WEBGL = "UNPACK_PREMULTIPLY_ALPHA_WEBGL"; - /** - * A BitmapData object contains an array of pixel data. This data can represent either a fully opaque bitmap or a - * transparent bitmap that contains alpha channel data. Either type of BitmapData object is stored as a buffer of 32-bit - * integers. Each 32-bit integer determines the properties of a single pixel in the bitmap.
- * Each 32-bit integer is a combination of four 8-bit channel values (from 0 to 255) that describe the alpha transparency - * and the red, green, and blue (ARGB) values of the pixel. (For ARGB values, the most significant byte represents the - * alpha channel value, followed by red, green, and blue.) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapData 对象是一个包含像素数据的数组。此数据可以表示完全不透明的位图,或表示包含 Alpha 通道数据的透明位图。 - * 以上任一类型的 BitmapData 对象都作为 32 位整数的缓冲区进行存储。每个 32 位整数确定位图中单个像素的属性。
- * 每个 32 位整数都是四个 8 位通道值(从 0 到 255)的组合,这些值描述像素的 Alpha 透明度以及红色、绿色、蓝色 (ARGB) 值。 - * (对于 ARGB 值,最高有效字节代表 Alpha 通道值,其后的有效字节分别代表红色、绿色和蓝色通道值。) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class BitmapData extends HashObject { - /** - * The width of the bitmap image in pixels. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 位图图像的宽度,以像素为单位。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * The height of the bitmap image in pixels. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 位图图像的高度,以像素为单位。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - /** - * Original bitmap image. - * HTMLImageElement|HTMLCanvasElement|HTMLVideoElement - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 原始位图图像。 - * HTMLImageElement|HTMLCanvasElement|HTMLVideoElement - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language zh_CN - */ - $source: any; - /** - * WebGL texture. - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * WebGL纹理。 - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language zh_CN - */ - webGLTexture: any; - /** - * Texture format. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理格式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - format: string; - /** - * @private - * webgl纹理生成后,是否删掉原始图像数据 - */ - $deleteSource: boolean; - /** - * @private - * id - */ - $nativeBitmapData: egret_native.NativeBitmapData; - /** - * @private - * - */ - readonly compressedTextureData: Array>; - debugCompressedTextureURL: string; - etcAlphaMask: Nullable; - /** - * Initializes a BitmapData object to refer to the specified source object. - * @param source The source object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 source 实例的 BitmapData 对象 - * @param source 被引用的 source 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(source: any); - source: any; - static create(type: "arraybuffer", data: ArrayBuffer, callback?: (bitmapData: BitmapData) => void): BitmapData; - static create(type: "base64", data: string, callback?: (bitmapData: BitmapData) => void): BitmapData; - $dispose(): void; - private static _displayList; - static $addDisplayObject(displayObject: DisplayObject, bitmapData: BitmapData): void; - static $removeDisplayObject(displayObject: DisplayObject, bitmapData: BitmapData): void; - static $invalidate(bitmapData: BitmapData): void; - static $dispose(bitmapData: BitmapData): void; - private _getCompressedTextureData(level, face); - getCompressed2dTextureData(): CompressedTextureData; - hasCompressed2d(): boolean; - clearCompressedTextureData(): void; - } -} -declare namespace egret { - interface DisplayObject { - addEventListener(type: "touchMove" | "touchBegin" | "touchEnd" | "touchCancel" | "touchTap" | "touchReleaseOutside" | "touchRollOut" | "touchRollOver", listener: (this: Z, e: TouchEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * The TouchEvent class lets you handle events on devices that detect user contact with the device (such as a finger - * on a touch screen).When a user interacts with a device such as a mobile phone or tablet with a touch screen, the - * user typically touches the screen with his or her fingers or a pointing device. You can develop applications that - * respond to basic touch events (such as a single finger tap) with the TouchEvent class. Create event listeners using - * the event types defined in this class. - * Note: When objects are nested on the display list, touch events target the deepest possible nested object that is - * visible in the display list. This object is called the target node. To have a target node's ancestor (an object - * containing the target node in the display list) receive notification of a touch event, use EventDispatcher.addEventListener() - * on the ancestor node with the type parameter set to the specific touch event you want to detect. - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language en_US - */ - /** - * 使用 TouchEvent 类,您可以处理设备上那些检测用户与设备之间的接触的事件。 - * 当用户与带有触摸屏的移动电话或平板电脑等设备交互时,用户通常使用手指或指针设备接触屏幕。可使用 TouchEvent - * 类开发响应基本触摸事件(如单个手指点击)的应用程序。使用此类中定义的事件类型创建事件侦听器。 - * 注意:当对象嵌套在显示列表中时,触摸事件的目标将是显示列表中可见的最深的可能嵌套对象。 - * 此对象称为目标节点。要使目标节点的祖代(祖代是一个包含显示列表中所有目标节点的对象,从舞台到目标节点的父节点均包括在内) - * 接收触摸事件的通知,请对祖代节点使用 EventDispatcher.on() 并将 type 参数设置为要检测的特定触摸事件。 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language zh_CN - */ - class TouchEvent extends Event { - /** - * Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_MOVE: "touchMove"; - /** - * Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户第一次触摸启用触摸的设备时(例如,用手指触摸配有触摸屏的移动电话或平板电脑)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_BEGIN: "touchBegin"; - /** - * Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone - * or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户移除与启用触摸的设备的接触时(例如,将手指从配有触摸屏的移动电话或平板电脑上抬起)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_END: "touchEnd"; - /** - * Dispatched when an event of some kind occurred that canceled the touch. - * Such as the eui.Scroller will dispatch 'TOUCH_CANCEL' when it start move, the 'TOUCH_END' and 'TOUCH_TAP' will not be triggered. - * @version Egret 3.0.1 - * @platform Web,Native - * @language en_US - */ - /** - * 由于某个事件取消了触摸时触发。比如 eui.Scroller 在开始滚动后会触发 'TOUCH_CANCEL' 事件,不再触发后续的 'TOUCH_END' 和 'TOUCH_TAP' 事件 - * @version Egret 3.0.1 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_CANCEL: "touchCancel"; - /** - * Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact - * was initiated on a touch-enabled device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的同一 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_TAP: "touchTap"; - /** - * Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact - * was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display - * object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的不同 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_RELEASE_OUTSIDE: "touchReleaseOutside"; - /** - * Creates an Event object that contains information about touch events. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number assigned to the touch point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TouchEvent 对象,其中包含有关Touch事件的信息 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, stageX?: number, stageY?: number, touchPointID?: number); - /** - * @private - */ - $initTo(stageX: number, stageY: number, touchPointID: number): void; - /** - * @private - */ - $stageX: number; - /** - * The horizontal coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageX: number; - /** - * @private - */ - $stageY: number; - /** - * The vertical coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageY: number; - private _localX; - /** - * The horizontal coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly localX: number; - private _localY; - /** - * The vertical coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly localY: number; - private targetChanged; - /** - * @private - */ - private getLocalXY(); - $setTarget(target: any): boolean; - /** - * A unique identification number assigned to the touch point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 分配给触摸点的唯一标识号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchPointID: number; - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - updateAfterEvent(): void; - /** - * Whether the touch is pressed (true) or not pressed (false). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示触摸已按下 (true) 还是未按下 (false)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchDown: boolean; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number (as an int) assigned to the touch point. - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTouchEvent(target: IEventDispatcher, type: string, bubbles?: boolean, cancelable?: boolean, stageX?: number, stageY?: number, touchPointID?: number, touchDown?: boolean): boolean; - } -} -declare namespace egret { - /** - * h5 and native interaction. - * @see http://edn.egret.com/cn/article/index/id/714 Egret basic skills to communicate with Native - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/external/ExternalInterface.ts - * @language en_US - */ - /** - * h5与native交互。 - * @see http://edn.egret.com/cn/article/index/id/714 Egret 与 Native 通信基本技巧 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/external/ExternalInterface.ts - * @language zh_CN - */ - interface ExternalInterface { - } - let ExternalInterface: { - /** - * Call functionName, and the value passed to the native. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用 functionName,并将value传入到native中。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - call(functionName: string, value: string): void; - /** - * FunctionName callback listener, you need to have to call functionName this field in native rather than such a call. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 监听 functionName 回调,需要在native中有调用 functionName 这个字段,而不是 此类的call。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addCallback(functionName: string, listener: (value: string) => void): void; - }; -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - const enum BitmapFilterQuality { - /** - * 定义低品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - LOW = 1, - /** - * 定义中等品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - MEDIUM = 2, - /** - * 定义高品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - HIGH = 3, - } -} -declare namespace egret { - /** - * The BlurFilter class lets you apply a blur visual effect to display objects. A blur effect softens the details of an image. - * You can produce blurs that range from a softly unfocused look to a Gaussian blur, a hazy appearance like viewing an image through semi-opaque glass. - * @version Egret 3.0.1 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language en_US - */ - /** - * 可使用 BlurFilter 类将模糊视觉效果应用于显示对象。模糊效果可以柔化图像的细节。 - * 您可以生成一些模糊效果,范围从创建一个柔化的、未聚焦的外观到高斯模糊(就像通过半透明玻璃查看图像一样的朦胧的外观)。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language zh_CN - */ - class BlurFilter extends Filter { - /** - * Initializes a BlurFilter object. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param quality {number} The number of times to apply the filter. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 BlurFilter 对象。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - constructor(blurX?: number, blurY?: number, quality?: number); - /** - * @private - */ - blurXFilter: IBlurXFilter; - /** - * @private - */ - blurYFilter: IBlurYFilter; - /** - * @private - */ - $quality: number; - /** - * The amount of horizontal blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - blurX: number; - /** - * @private - */ - $blurX: number; - /** - * The amount of vertical blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - blurY: number; - /** - * @private - */ - $blurY: number; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - onPropertyChange(): void; - } - /** - * @private - */ - interface IBlurXFilter extends Filter { - type: string; - $uniforms: any; - blurX: number; - } - /** - * @private - */ - interface IBlurYFilter extends Filter { - type: string; - $uniforms: any; - blurY: number; - } -} -declare namespace egret { - /** - * The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color and alpha values of every pixel in the input image to produce a result with a new set of RGBA color and alpha values. - * It allows saturation changes, hue rotation, luminance to alpha, and various other effects. - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language en_US - */ - /** - * 使用 ColorMatrixFilter 类可以将 4 x 5 矩阵转换应用于输入图像上的每个像素的 RGBA 颜色和 Alpha 值,以生成具有一组新的 RGBA 颜色和 Alpha 值的结果。 - * 该类允许饱和度更改、色相旋转、亮度为 Alpha 以及各种其他效果。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language zh_CN - */ - class ColorMatrixFilter extends Filter { - /** - * @private - */ - $matrix: number[]; - /** - * @private - */ - private matrix2; - /** - * Initializes a ColorMatrixFilter object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 ColorMatrixFilter 对象。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - constructor(matrix?: number[]); - /** - * A comma delimited list of 20 doubles that comprise a 4x5 matrix applied to the rendered element. - * The matrix is in row major order -- that is, the first five elements are multipled by the vector [srcR,srcG,srcB,srcA,1] to determine the output red value, the second five determine the output green value, etc. - * The value must either be an array or comma delimited string of 20 numbers. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 构成应用于所呈示的元素的一个 4x5 矩阵的、以逗号分隔的 20 个双精度数的列表。 - * 矩阵以行作为主要顺序,即用第一行五个元素乘以矢量 [srcR,srcG,srcB,srcA,1] 以确定输出的红色值,用第二行的五个元素确定输出的绿色值,等等。 - * 该值必须为 20 个数字组成的数组或以逗号分隔的字符串。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - matrix: number[]; - /** - * @private - */ - private setMatrix(value); - /** - * @private - */ - $toJson(): string; - } -} -declare namespace egret { - /** - * custom filter, now support WebGL mode only. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 自定义滤镜,目前仅支持WebGL模式 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - class CustomFilter extends Filter { - /** - * @private - */ - $vertexSrc: string; - /** - * @private - */ - $fragmentSrc: string; - /** - * @private - */ - $shaderKey: string; - /** - * @private - */ - type: string; - private $padding; - /** - * The inner margin of the filter. - * If the desired area of the custom filter is larger than the original area (stroke, etc.), you need to set it manually. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 滤镜的内边距 - * 如果自定义滤镜所需区域比原区域大(描边等),需要手动设置 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - padding: number; - /** - * The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - readonly uniforms: any; - /** - * Initialize the CustomFilter object. - * @param vertexSrc Custom vertex shader program. - * @param fragmentSrc Custom fragment shader program. - * @param uniforms The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 初始化 CustomFilter 对象 - * @param vertexSrc 自定义的顶点着色器程序。 - * @param fragmentSrc 自定义的片段着色器程序。 - * @param uniforms 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - constructor(vertexSrc: string, fragmentSrc: string, uniforms?: any); - onPropertyChange(): void; - } -} -declare namespace egret { - /** - * @class egret.DropShadowFilter - * @classdesc - * 可使用 DropShadowFilter 类向显示对象添加投影。 - * @extends egret.GlowFilter - * @version Egret 3.1.4 - * @platform Web,Native - */ - class DropShadowFilter extends GlowFilter { - /** - * Initializes a new DropShadowFilter instance. - * @method egret.DropShadowFilter#constructor - * @param distance {number} The offset distance of the bevel. Valid values are in pixels (floating point). - * @param angle {number} The angle of the bevel. Valid values are from 0 to 360°. - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @param hideObject {number} Indicates whether or not the object is hidden. The value true indicates that the object itself is not drawn; only the shadow is visible. The default is false, meaning that the object is shown. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 DropShadowFilter 对象 - * @method egret.DropShadowFilter#constructor - * @param distance {number} 阴影的偏移距离,以像素为单位。 - * @param angle {number} 阴影的角度,0 到 360 度(浮点)。 - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @param hideObject {number} 表示是否隐藏对象。如果值为 true,则表示没有绘制对象本身,只有阴影是可见的。默认值为 false(显示对象)。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - constructor(distance?: number, angle?: number, color?: number, alpha?: number, blurX?: number, blurY?: number, strength?: number, quality?: number, inner?: boolean, knockout?: boolean, hideObject?: boolean); - /** - * @private - */ - $distance: number; - /** - * The offset distance of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的偏移距离,以像素为单位。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - distance: number; - /** - * @private - */ - $angle: number; - /** - * The angle of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的角度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - angle: number; - /** - * @private - */ - $hideObject: boolean; - /** - * Indicates whether or not the object is hidden. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 表示是否隐藏对象。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - hideObject: boolean; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - } -} -declare namespace egret { - /** - * The GradientType class provides values for the type parameter in the beginGradientFill() methods of the egret.Graphics class. - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * GradientType 类为 egret.Graphics 类的 beginGradientFill() 方法中的 type 参数提供值。 - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class GradientType { - /** - * Value used to specify a linear gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定线性渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LINEAR: string; - /** - * Value used to specify a radial gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定放射状渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RADIAL: string; - } -} -declare namespace egret { - /** - * The Graphics class contains a set of methods for creating vector shape. Display objects that support drawing include Sprite and Shape objects. Each class in these classes includes the graphics attribute that is a Graphics object. - * The following auxiliary functions are provided for ease of use: drawRect(), drawRoundRect(), drawCircle(), and drawEllipse(). - * @see http://edn.egret.com/cn/docs/page/136 Draw Rectangle - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language en_US - */ - /** - * Graphics 类包含一组可用来创建矢量形状的方法。支持绘制的显示对象包括 Sprite 和 Shape 对象。这些类中的每一个类都包括 graphics 属性,该属性是一个 Graphics 对象。 - * 以下是为便于使用而提供的一些辅助函数:drawRect()、drawRoundRect()、drawCircle() 和 drawEllipse()。 - * @see http://edn.egret.com/cn/docs/page/136 绘制矩形 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language zh_CN - */ - class Graphics extends HashObject { - /** - * Initializes a Graphics object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Graphics 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $renderNode: sys.GraphicsNode; - /** - * 绑定到的目标显示对象 - */ - $targetDisplay: DisplayObject; - $targetIsSprite: boolean; - /** - * @private - * 设置绑定到的目标显示对象 - */ - $setTarget(target: DisplayObject): void; - /** - * 当前移动到的坐标X - */ - private lastX; - /** - * 当前移动到的坐标Y - */ - private lastY; - /** - * 当前正在绘制的填充 - */ - private fillPath; - /** - * 当前正在绘制的线条 - */ - private strokePath; - /** - * 线条的左上方宽度 - */ - private topLeftStrokeWidth; - /** - * 线条的右下方宽度 - */ - private bottomRightStrokeWidth; - /** - * 对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - private setStrokeWidth(width); - /** - * Specify a simple single color fill that will be used for subsequent calls to other Graphics methods (for example, lineTo() and drawCircle()) when drawing. - * Calling the clear() method will clear the fill. - * @param color Filled color - * @param alpha Filled Alpha value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - beginFill(color: number, alpha?: number): void; - /** - * Specifies a gradient fill used by subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) for the object. - * Calling the clear() method clears the fill. - * @param type A value from the GradientType class that specifies which gradient type to use: GradientType.LINEAR or GradientType.RADIAL. - * @param colors An array of RGB hexadecimal color values used in the gradient; for example, red is 0xFF0000, blue is 0x0000FF, and so on. You can specify up to 15 colors. For each color, specify a corresponding value in the alphas and ratios parameters. - * @param alphas An array of alpha values for the corresponding colors in the colors array; - * @param ratios An array of color distribution ratios; valid values are 0-255. - * @param matrix A transformation matrix as defined by the egret.Matrix class. The egret.Matrix class includes a createGradientBox() method, which lets you conveniently set up the matrix for use with the beginGradientFill() method. - * @platform Web,Native - * @version Egret 2.4 - * @language en_US - */ - /** - * 指定一种渐变填充,用于随后调用对象的其他 Graphics 方法(如 lineTo() 或 drawCircle())。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @platform Web,Native - * @version Egret 2.4 - * @language zh_CN - */ - beginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix?: egret.Matrix): void; - /** - * Apply fill to the lines and curves added after the previous calling to the beginFill() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对从上一次调用 beginFill()方法之后添加的直线和曲线应用填充。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - endFill(): void; - /** - * Specify a line style that will be used for subsequent calls to Graphics methods such as lineTo() and drawCircle(). - * @param thickness An integer, indicating the thickness of the line in points. Valid values are 0 to 255. If a number is not specified, or if the parameter is undefined, a line is not drawn. If a value less than 0 is passed, the default value is 0. Value 0 indicates hairline thickness; the maximum thickness is 255. If a value greater than 255 is passed, the default value is 255. - * @param color A hexadecimal color value of the line (for example, red is 0xFF0000, and blue is 0x0000FF, etc.). If no value is specified, the default value is 0x000000 (black). Optional. - * @param alpha Indicates Alpha value of the line's color. Valid values are 0 to 1. If no value is specified, the default value is 1 (solid). If the value is less than 0, the default value is 0. If the value is greater than 1, the default value is 1. - * @param pixelHinting A boolean value that specifies whether to hint strokes to full pixels. This affects both the position of anchors of a curve and the line stroke size itself. With pixelHinting set to true, the line width is adjusted to full pixel width. With pixelHinting set to false, disjoints can appear for curves and straight lines. - * @param scaleMode Specifies the scale mode to be used - * @param caps Specifies the value of the CapsStyle class of the endpoint type at the end of the line. (default = CapsStyle.ROUND) - * @param joints Specifies the type of joint appearance of corner. (default = JointStyle.ROUND) - * @param miterLimit Indicates the limit number of cut miter. - * @param lineDash set the line dash. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param pixelHinting 布尔型值,指定是否提示笔触采用完整像素。它同时影响曲线锚点的位置以及线条笔触大小本身。在 pixelHinting 设置为 true 的情况下,线条宽度会调整到完整像素宽度。在 pixelHinting 设置为 false 的情况下,对于曲线和直线可能会出现脱节。 - * @param scaleMode 用于指定要使用的比例模式 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - * @param lineDash 设置虚线样式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineStyle(thickness?: number, color?: number, alpha?: number, pixelHinting?: boolean, scaleMode?: string, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): void; - /** - * Draw a rectangle - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawRect(x: number, y: number, width: number, height: number): void; - /** - * Draw a rectangle with rounded corners. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @param ellipseWidth Width used to draw an ellipse with rounded corners (in pixels). - * @param ellipseHeight Height used to draw an ellipse with rounded corners (in pixels). (Optional) If no value is specified, the default value matches the value of the ellipseWidth parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - /** - * Draw a circle. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param r Radius of the circle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawCircle(x: number, y: number, radius: number): void; - /** - * Draw an ellipse. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawEllipse(x: number, y: number, width: number, height: number): void; - /** - * Move the current drawing position to (x, y). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - moveTo(x: number, y: number): void; - /** - * Draw a straight line from the current drawing position to (x, y) using the current line style; the current drawing position is then set to (x, y). - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineTo(x: number, y: number): void; - /** - * Draw a quadratic Bezier curve from the current drawing position to (anchorX, anchorY) using the current line style according to the control points specified by (controlX, controlY). The current drawing position is then set to (anchorX, anchorY). - * If the curveTo() method is called before the moveTo() method, the default value of the current drawing position is (0, 0). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * The drawn curve is a quadratic Bezier curve. A quadratic Bezier curve contains two anchor points and one control point. The curve interpolates the two anchor points and bends to the control point. - * @param controlX A number indicating the horizontal position of the control point, relative to the registration point of the parent display object. - * @param controlY A number indicating the vertical position of the control point, relative to the registration point of the parent display object. - * @param anchorX A number indicating the horizontal position of the next anchor point, relative to the registration point of the parent display object. - * @param anchorY A number indicating the vertical position of the next anchor point, relative to the registration point of the parent display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - /** - * Draws a cubic Bezier curve from the current drawing position to the specified anchor. Cubic Bezier curves consist of two anchor points and two control points. The curve interpolates the two anchor points and two control points to the curve. - * @param controlX1 Specifies the first control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY1 Specifies the first control point relative to the registration point of the parent display the vertical position of the object. - * @param controlX2 Specify the second control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY2 Specify the second control point relative to the registration point of the parent display the vertical position of the object. - * @param anchorX Specifies the anchor point relative to the registration point of the parent display the horizontal position of the object. - * @param anchorY Specifies the anchor point relative to the registration point of the parent display the vertical position of the object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - /** - * adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending - * at endAngle going in the given direction by anticlockwise (defaulting to clockwise). - * @param x The x coordinate of the arc's center. - * @param y The y coordinate of the arc's center. - * @param radius The arc's radius. - * @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. - * @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. - * @param anticlockwise if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - private dirty(); - /** - * @private - * 测量圆弧的矩形大小 - */ - private arcBounds(x, y, radius, startAngle, endAngle); - /** - * Clear graphics that are drawn to this Graphics object, and reset fill and line style settings. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除绘制到此 Graphics 对象的图形,并重置填充和线条样式设置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clear(): void; - /** - * @private - */ - private minX; - /** - * @private - */ - private minY; - /** - * @private - */ - private maxX; - /** - * @private - */ - private maxY; - /** - * @private - */ - private extendBoundsByPoint(x, y); - /** - * @private - */ - private extendBoundsByX(x); - /** - * @private - */ - private extendBoundsByY(y); - /** - * @private - */ - private updateNodeBounds(); - /** - * 是否已经包含上一次moveTo的坐标点 - */ - private includeLastPosition; - /** - * 更新当前的lineX和lineY值,并标记尺寸失效。 - * @private - */ - private updatePosition(x, y); - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - * - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * The Matrix class represents a transformation matrix that determines how to map points from one coordinate space to - * another. You can perform various graphical transformations on a display object by setting the properties of a Matrix - * object, applying that Matrix object to the matrix property of a display object, These transformation functions include - * translation (x and y repositioning), rotation, scaling, and skewing. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language en_US - */ - /** - * Matrix 类表示一个转换矩阵,它确定如何将点从一个坐标空间映射到另一个坐标空间。 - * 您可以对一个显示对象执行不同的图形转换,方法是设置 Matrix 对象的属性,将该 Matrix - * 对象应用于显示对象的 matrix 属性。这些转换函数包括平移(x 和 y 重新定位)、旋转、缩放和倾斜。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language zh_CN - */ - class Matrix extends HashObject { - /** - * Releases a matrix instance to the object pool - * @param matrix matrix that Needs to be recycled - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Matrix实例到对象池 - * @param matrix 需要回收的 matrix - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(matrix: Matrix): void; - /** - * get a matrix instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Matrix对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(): Matrix; - /** - * Creates a new Matrix object with the specified parameters. - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定参数创建一个 Matrix 对象 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - /** - * The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - a: number; - /** - * The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 旋转或倾斜图像时影响像素沿 y 轴定位的值 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - b: number; - /** - * The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 旋转或倾斜图像时影响像素沿 x 轴定位的值 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - c: number; - /** - * The value that affects the positioning of pixels along the y axis when scaling or rotating an image. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - d: number; - /** - * The distance by which to translate each point along the x axis. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 x 轴平移每个点的距离 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - tx: number; - /** - * The distance by which to translate each point along the y axis. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 y 轴平移每个点的距离 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ty: number; - /** - * Returns a new Matrix object that is a clone of this matrix, with an exact copy of the contained object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Matrix 对象,它是此矩阵的克隆,带有与所含对象完全相同的副本。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Matrix; - /** - * Concatenates a matrix with the current matrix, effectively combining the geometric effects of the two. In mathematical - * terms, concatenating two matrixes is the same as combining them using matrix multiplication. - * @param other The matrix to be concatenated to the source matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将某个矩阵与当前矩阵连接,从而将这两个矩阵的几何效果有效地结合在一起。在数学术语中,将两个矩阵连接起来与使用矩阵乘法将它们结合起来是相同的。 - * @param other 要连接到源矩阵的矩阵。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - concat(other: Matrix): void; - /** - * Copies all of the matrix data from the source Point object into the calling Matrix object. - * @param other The Matrix object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Matrix 对象中的所有矩阵数据复制到调用方 Matrix 对象中。 - * @param other 要拷贝的目标矩阵 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(other: Matrix): Matrix; - /** - * Sets each matrix property to a value that causes a null transformation. An object transformed by applying an - * identity matrix will be identical to the original. After calling the identity() method, the resulting matrix - * has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为每个矩阵属性设置一个值,该值将导致矩阵无转换。通过应用恒等矩阵转换的对象将与原始对象完全相同。 - * 调用 identity() 方法后,生成的矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0 和 ty=0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - identity(): void; - /** - * Performs the opposite transformation of the original matrix. You can apply an inverted matrix to an object to - * undo the transformation performed when applying the original matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行原始矩阵的逆转换。 - * 您可以将一个逆矩阵应用于对象来撤消在应用原始矩阵时执行的转换。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - invert(): void; - /** - * @private - */ - $invertInto(target: Matrix): void; - /** - * Applies a rotation transformation to the Matrix object. - * The rotate() method alters the a, b, c, and d properties of the Matrix object. - * @param angle The rotation angle in radians. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对 Matrix 对象应用旋转转换。 - * rotate() 方法将更改 Matrix 对象的 a、b、c 和 d 属性。 - * @param angle 以弧度为单位的旋转角度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotate(angle: number): void; - /** - * Applies a scaling transformation to the matrix. The x axis is multiplied by sx, and the y axis it is multiplied by sy. - * The scale() method alters the a and d properties of the Matrix object. - * @param sx A multiplier used to scale the object along the x axis. - * @param sy A multiplier used to scale the object along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对矩阵应用缩放转换。x 轴乘以 sx,y 轴乘以 sy。 - * scale() 方法将更改 Matrix 对象的 a 和 d 属性。 - * @param sx 用于沿 x 轴缩放对象的乘数。 - * @param sy 用于沿 y 轴缩放对象的乘数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scale(sx: number, sy: number): void; - /** - * Sets the members of Matrix to the specified values - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Matrix 的成员设置为指定值 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * Returns the result of applying the geometric transformation represented by the Matrix object to the specified point. - * @param pointX The x coordinate for which you want to get the result of the Matrix transformation. - * @param pointY The y coordinate for which you want to get the result of the Matrix transformation. - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns The point resulting from applying the Matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @param pointX 想要获得其矩阵转换结果的点的x坐标。 - * @param pointY 想要获得其矩阵转换结果的点的y坐标。 - * @param resultPoint 框架建议尽可能减少创建对象次数来优化性能,可以从外部传入一个复用的Point对象来存储结果,若不传入将创建一个新的Point对象返回。 - * @returns 由应用矩阵转换所产生的点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - transformPoint(pointX: number, pointY: number, resultPoint?: Point): Point; - /** - * Translates the matrix along the x and y axes, as specified by the dx and dy parameters. - * @param dx The amount of movement along the x axis to the right, in pixels. - * @param dy The amount of movement down along the y axis, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 x 和 y 轴平移矩阵,由 dx 和 dy 参数指定。 - * @param dx 沿 x 轴向右移动的量(以像素为单位)。 - * @param dy 沿 y 轴向下移动的量(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - translate(dx: number, dy: number): void; - /** - * Determines whether two matrixes are equal. - * @param other The matrix to be compared. - * @returns A value of true if the object is equal to this Matrix object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否与另一个矩阵数据相等 - * @param other 要比较的另一个矩阵对象。 - * @returns 是否相等,ture表示相等。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(other: Matrix): boolean; - /** - * prepend matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 前置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - prepend(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * append matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 后置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - append(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs. - * Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters tx and ty. - * @param point The point for which you want to get the result of the matrix transformation. - * @returns The point resulting from applying the matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果给定预转换坐标空间中的点,则此方法返回发生转换后该点的坐标。 - * 与使用 transformPoint() 方法应用的标准转换不同,deltaTransformPoint() 方法的转换不考虑转换参数 tx 和 ty。 - * @param point 想要获得其矩阵转换结果的点 - * @returns 由应用矩阵转换所产生的点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - deltaTransformPoint(point: Point): Point; - /** - * Returns a text value listing the properties of the Matrix object. - * @returns A string containing the values of the properties of the Matrix object: a, b, c, d, tx, and ty. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @returns 一个字符串,它包含 Matrix 对象的属性值:a、b、c、d、tx 和 ty。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - /** - * Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters. - * @param scaleX The factor by which to scale horizontally. - * @param scaleY The factor by which scale vertically. - * @param rotation The amount to rotate, in radians. - * @param tx The number of pixels to translate (move) to the right along the x axis. - * @param ty The number of pixels to translate (move) down along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 包括用于缩放、旋转和转换的参数。当应用于矩阵时,该方法会基于这些参数设置矩阵的值。 - * @param scaleX 水平缩放所用的系数 - * @param scaleY 垂直缩放所用的系数 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移(移动)的像素数 - * @param ty 沿 y 轴向下平移(移动)的像素数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createBox(scaleX: number, scaleY: number, rotation?: number, tx?: number, ty?: number): void; - /** - * Creates the specific style of matrix expected by the beginGradientFill() and lineGradientStyle() methods of the Graphics class. - * Width and height are scaled to a scaleX/scaleY pair and the tx/ty values are offset by half the width and height. - * @param width The width of the gradient box. - * @param height The height of the gradient box. - * @param rotation The amount to rotate, in radians. - * @param tx The distance, in pixels, to translate to the right along the x axis. This value is offset by half of the width parameter. - * @param ty The distance, in pixels, to translate down along the y axis. This value is offset by half of the height parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 Graphics 类的 beginGradientFill() 和 lineGradientStyle() 方法所需的矩阵的特定样式。 - * 宽度和高度被缩放为 scaleX/scaleY 对,而 tx/ty 值偏移了宽度和高度的一半。 - * @param width 渐变框的宽度 - * @param height 渐变框的高度 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移的距离(以像素为单位)。此值将偏移 width 参数的一半 - * @param ty 沿 y 轴向下平移的距离(以像素为单位)。此值将偏移 height 参数的一半 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createGradientBox(width: number, height: number, rotation?: number, tx?: number, ty?: number): void; - /** - * @private - */ - $transformBounds(bounds: Rectangle): void; - /** - * @private - */ - private getDeterminant(); - /** - * @private - */ - $getScaleX(): number; - /** - * @private - */ - $getScaleY(): number; - /** - * @private - */ - $getSkewX(): number; - /** - * @private - */ - $getSkewY(): number; - /** - * @private - */ - $updateScaleAndRotation(scaleX: number, scaleY: number, skewX: number, skewY: number): void; - /** - * @private - * target = other * this - */ - $preMultiplyInto(other: Matrix, target: Matrix): void; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempMatrix: Matrix; -} -declare namespace egret { - /** - * A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its - * width and its height.
- * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of - * one property has no effect on the others. However, the right and bottom properties are integrally related to those - * four properties. For example, if you change the value of the right property, the value of the width property changes; - * if you change the bottom property, the value of the height property changes. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language en_US - */ - /** - * Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language zh_CN - */ - class Rectangle extends HashObject { - /** - * Releases a rectangle instance to the object pool. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Rectangle实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(rect: Rectangle): void; - /** - * get a rectangle instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Rectangle对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(): Rectangle; - /** - * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified - * width and height parameters. - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个新 Rectangle 对象,其左上角由 x 和 y 参数指定,并具有指定的 width 和 height 参数。 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(x?: number, y?: number, width?: number, height?: number); - /** - * The x coordinate of the top-left corner of the rectangle. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 x 坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * The y coordinate of the top-left corner of the rectangle. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 y 坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * The width of the rectangle, in pixels. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形的宽度(以像素为单位)。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * 矩形的高度(以像素为单位)。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * The height of the rectangle, in pixels. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - /** - * The sum of the x and width properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * x 和 width 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - right: number; - /** - * The sum of the y and height properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * y 和 height 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bottom: number; - /** - * The x coordinate of the top-left corner of the rectangle. Changing the left property of a Rectangle object has - * no effect on the y and height properties. However it does affect the width property, whereas changing the x value - * does not affect the width property. - * The value of the left property is equal to the value of the x property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 x 坐标。更改 Rectangle 对象的 left 属性对 y 和 height 属性没有影响。但是,它会影响 width 属性,而更改 x 值不会影响 width 属性。 - * left 属性的值等于 x 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - left: number; - /** - * The y coordinate of the top-left corner of the rectangle. Changing the top property of a Rectangle object has - * no effect on the x and width properties. However it does affect the height property, whereas changing the y - * value does not affect the height property.
- * The value of the top property is equal to the value of the y property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 y 坐标。更改 Rectangle 对象的 top 属性对 x 和 width 属性没有影响。但是,它会影响 height 属性,而更改 y 值不会影响 height 属性。
- * top 属性的值等于 y 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - top: number; - /** - * The location of the Rectangle object's top-left corner, determined by the x and y coordinates of the point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由该点的 x 和 y 坐标确定的 Rectangle 对象左上角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - topLeft: Point; - /** - * The location of the Rectangle object's bottom-right corner, determined by the values of the right and bottom properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由 right 和 bottom 属性的值确定的 Rectangle 对象的右下角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bottomRight: Point; - /** - * Copies all of rectangle data from the source Rectangle object into the calling Rectangle object. - * @param sourceRect The Rectangle object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Rectangle 对象中的所有矩形数据复制到调用方 Rectangle 对象中。 - * @param sourceRect 要从中复制数据的 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(sourceRect: Rectangle): Rectangle; - /** - * Sets the members of Rectangle to the specified values - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 的成员设置为指定值 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(x: number, y: number, width: number, height: number): Rectangle; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * @param x The x coordinate (horizontal position) of the point. - * @param y The y coordinate (vertical position) of the point. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * @param x 检测点的x轴 - * @param y 检测点的y轴 - * @returns 如果检测点位于矩形内,返回true,否则,返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - contains(x: number, y: number): boolean; - /** - * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns - * the area of intersection as a Rectangle object. If the rectangles do not intersect, this method returns an empty - * Rectangle object with its properties set to 0. - * @param toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object. - * @returns A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method - * returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果在 toIntersect 参数中指定的 Rectangle 对象与此 Rectangle 对象相交,则返回交集区域作为 Rectangle 对象。如果矩形不相交, - * 则此方法返回一个空的 Rectangle 对象,其属性设置为 0。 - * @param toIntersect 要对照比较以查看其是否与此 Rectangle 对象相交的 Rectangle 对象。 - * @returns 等于交集区域的 Rectangle 对象。如果该矩形不相交,则此方法返回一个空的 Rectangle 对象;即,其 x、y、width 和 - * height 属性均设置为 0 的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - intersection(toIntersect: Rectangle): Rectangle; - /** - * Increases the size of the Rectangle object by the specified amounts, in pixels. - * The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. - * @param dx The value to be added to the left and the right of the Rectangle object. - * @param dy The value to be added to the top and the bottom of the Rectangle. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量增加 Rectangle 对象的大小(以像素为单位) - * 保持 Rectangle 对象的中心点不变,使用 dx 值横向增加它的大小,使用 dy 值纵向增加它的大小。 - * @param dx Rectangle 对象横向增加的值。 - * @param dy Rectangle 对象纵向增加的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - inflate(dx: number, dy: number): void; - /** - * @private - */ - $intersectInPlace(clipRect: Rectangle): Rectangle; - /** - * Determines whether the object specified in the toIntersect parameter intersects with this Rectangle object. - * This method checks the x, y, width, and height properties of the specified Rectangle object to see if it - * intersects with this Rectangle object. - * @param toIntersect The Rectangle object to compare against this Rectangle object. - * @returns A value of true if the specified object intersects with this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toIntersect 参数中指定的对象是否与此 Rectangle 对象相交。此方法检查指定的 Rectangle - * 对象的 x、y、width 和 height 属性,以查看它是否与此 Rectangle 对象相交。 - * @param toIntersect 要与此 Rectangle 对象比较的 Rectangle 对象。 - * @returns 如果两个矩形相交,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - intersects(toIntersect: Rectangle): boolean; - /** - * Determines whether or not this Rectangle object is empty. - * @returns A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象是否为空。 - * @returns 如果 Rectangle 对象的宽度或高度小于等于 0,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - isEmpty(): boolean; - /** - * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 对象的所有属性设置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setEmpty(): void; - /** - * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @returns A new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @returns 新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Rectangle; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. - * @param point The point, as represented by its x and y coordinates. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * 此方法与 Rectangle.contains() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 包含点对象 - * @returns 如果包含,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - containsPoint(point: Point): boolean; - /** - * Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object. - * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * @param rect The Rectangle object being checked. - * @returns A value of true if the Rectangle object that you specify is contained by this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象内是否包含由 rect 参数指定的 Rectangle 对象。 - * 如果一个 Rectangle 对象完全在另一个 Rectangle 的边界内,我们说第二个 Rectangle 包含第一个 Rectangle。 - * @param rect 所检查的 Rectangle 对象 - * @returns 如果此 Rectangle 对象包含您指定的 Rectangle 对象,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - containsRect(rect: egret.Rectangle): boolean; - /** - * Determines whether the object specified in the toCompare parameter is equal to this Rectangle object. - * This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object. - * @param The rectangle to compare to this Rectangle object. - * @returns A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toCompare 参数中指定的对象是否等于此 Rectangle 对象。 - * 此方法将某个对象的 x、y、width 和 height 属性与此 Rectangle 对象所对应的相同属性进行比较。 - * @param toCompare 要与此 Rectangle 对象进行比较的矩形。 - * @returns 如果对象具有与此 Rectangle 对象完全相同的 x、y、width 和 height 属性值,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(toCompare: Rectangle): boolean; - /** - * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. - * @param point 此 Point 对象的 x 属性用于增加 Rectangle 对象的水平尺寸。y 属性用于增加 Rectangle 对象的垂直尺寸。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 增加 Rectangle 对象的大小。此方法与 Rectangle.inflate() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - inflatePoint(point: Point): void; - /** - * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. - * @param dx Moves the x value of the Rectangle object by this amount. - * @param dy Moves the y value of the Rectangle object by this amount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量调整 Rectangle 对象的位置(由其左上角确定)。 - * @param dx 将 Rectangle 对象的 x 值移动此数量。 - * @param dy 将 Rectangle 对象的 t 值移动此数量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offset(dx: number, dy: number): void; - /** - * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. - * @param point A Point object to use to offset this Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 对象用作参数来调整 Rectangle 对象的位置。此方法与 Rectangle.offset() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 要用于偏移此 Rectangle 对象的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offsetPoint(point: Point): void; - /** - * Builds and returns a string that lists the horizontal and vertical positions and the width and height of the Rectangle object. - * @returns A string listing the value of each of the following properties of the Rectangle object: x, y, width, and height. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 生成并返回一个字符串,该字符串列出 Rectangle 对象的水平位置和垂直位置以及高度和宽度。 - * @returns 一个字符串,它列出了 Rectangle 对象的下列各个属性的值:x、y、width 和 height。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - /** - * Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles. - * @param toUnion A Rectangle object to add to this Rectangle object. - * @returns A new Rectangle object that is the union of the two rectangles. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过填充两个矩形之间的水平和垂直空间,将这两个矩形组合在一起以创建一个新的 Rectangle 对象。 - * @param toUnion 要添加到此 Rectangle 对象的 Rectangle 对象。 - * @returns 充当两个矩形的联合的新 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - union(toUnion: Rectangle): Rectangle; - /** - * @private - */ - $getBaseWidth(angle: number): number; - /** - * @private - */ - $getBaseHeight(angle: number): number; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempRectangle: Rectangle; -} -declare namespace egret { -} -declare namespace egret { - /** - * The JointStyle class is an enumeration of constant values that specify the joint style to use in drawing lines. - * These constants are provided for use as values in the joints parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * JointStyle 类是指定要在绘制线条中使用的联接点样式的常量值枚举。提供的这些常量用作 egret.Graphics.lineStyle() 方法的 joints 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - const JointStyle: { - BEVEL: string; - MITER: string; - ROUND: string; - }; -} -declare namespace egret { -} -/** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/localStorage/localStorage.ts - */ -declare namespace egret.localStorage { - /** - * Read data - * @param key {string} Name of the key to be read - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 读取数据 - * @param key {string} 要读取的键名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let getItem: (key: string) => string; - /** - * Save data - * @param key {string} Name of the key to be saved - * @param value {string} Value to be saved - * @returns {boolean} Whether data is saved successfully - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 保存数据 - * @param key {string} 要保存的键名称 - * @param value {string} 要保存的值 - * @returns {boolean} 数据保存是否成功 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let setItem: (key: string, value: string) => boolean; - /** - * Delete data - * @param key {string} Name of the key to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除数据 - * @param key {string} 要删除的键名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let removeItem: (key: string) => void; - /** - * Clear all data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将所有数据清空 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let clear: () => void; -} -declare namespace egret.sys { - /** - * @private - * @param channel - */ - function $pushSoundChannel(channel: SoundChannel): void; - /** - * @private - * @param channel - */ - function $popSoundChannel(channel: SoundChannel): boolean; -} -declare namespace egret { - /** - * The Sound class lets you work with sound in an application. - * The Sound class lets you create a Sound object, load and play an external audio file into that object. - * More detailed control of the sound is performed through the SoundChannel - * - * @event egret.Event.COMPLETE Dispatch when the audio resource is loaded and ready to play - * @event egret.IOErrorEvent.IO_ERROR Dispatch when the audio resource is failed to load - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language en_US - */ - /** - * Sound 允许您在应用程序中使用声音。使用 Sound 类可以创建 Sound 对象、将外部音频文件加载到该对象并播放该文件。 - * 可通过 SoundChannel 对声音执行更精细的控制,如控制音量和监控播放进度。 - * @see http://edn.egret.com/cn/docs/page/156 音频系统 - * - * @event egret.Event.COMPLETE 音频加载完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 音频加载失败时抛出 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language zh_CN - */ - interface Sound extends EventDispatcher { - /** - * Initiates loading of an external audio file from the specified URL. - * @param url Audio file URL - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动从指定 URL 加载外部音频文件的过程。 - * @param url 需要加载的音频文件URL - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string): void; - /** - * Generates a new SoundChannel object to play back the sound. - * @param startTime The initial position in seconds at which playback should start, (default = 0) - * @param loops Plays, the default value is 0. Greater than 0 to the number of plays, such as 1 to play 1, less than or equal to 0, to loop. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 生成一个新的 SoundChannel 对象来播放该声音。此方法返回 SoundChannel 对象,访问该对象可停止声音调整音量。 - * @param startTime 应开始播放的初始位置(以秒为单位),默认值是 0 - * @param loops 播放次数,默认值是 0,循环播放。 大于 0 为播放次数,如 1 为播放 1 次;小于等于 0,为循环播放。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(startTime?: number, loops?: number): SoundChannel; - /** - * Closes the stream, causing any download of data to cease - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭该流,从而停止所有数据的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - close(): void; - /** - * Type, default is egret.Sound.EFFECT. - * In the native and runtime environment, while only play a background music, sound length so as not to be too long. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 类型,默认为 egret.Sound.EFFECT。 - * 在 native 和 runtime 环境下,背景音乐同时只能播放一个,音效长度尽量不要太长。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - type: string; - /** - * Length of the current sound (in seconds). - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前声音的长度(以秒为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - length: number; - } - /** - * @copy egret.Sound - */ - let Sound: { - /** - * Create Sound object, load an external audio file and play - * @param url Audio file URL, Sound will start to load the media if url is not empty - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 Sound 对象、将外部音频文件加载到该对象并播放该文件 - * @param url 需要加载的音频文件URL,如果指定了 url, Sound会立即开始加载指定的媒体文件 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - new (): Sound; - /** - * Background music - * @default "music" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 背景音乐 - * @default "music" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - MUSIC: string; - /** - * EFFECT - * @default "effect" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音效 - * @default "effect" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - EFFECT: string; - }; -} -declare namespace egret { - /** - * The SoundChannel class controls a sound in an application. - * Every sound is assigned to a sound channel, and the application - * can have multiple sound channels that are mixed together. - * The SoundChannel class contains a stop() method, properties for - * set the volume of the channel - * - * @event egret.Event.SOUND_COMPLETE Dispatch when a sound has finished playing at last time - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language en_US - */ - /** - * SoundChannel 类控制应用程序中的声音。每个声音均分配给一个声道,而且应用程序可以具有混合在一起的多个声道。 - * SoundChannel 类包含 stop() 方法、用于设置音量和监视播放进度的属性。 - * - * @event egret.Event.SOUND_COMPLETE 音频最后一次播放完成时抛出 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language zh_CN - */ - interface SoundChannel extends IEventDispatcher { - /** - * The volume, ranging from 0 (silent) to 1 (full volume). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音量范围从 0(静音)至 1(最大音量)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - volume: number; - /** - * When the sound is playing, the position property indicates - * in seconds the current point that is being played in the sound file. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当播放声音时,position 属性表示声音文件中当前播放的位置(以秒为单位) - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - position: number; - /** - * Stops the sound playing in the channel. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止在该声道中播放声音。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - } -} -declare namespace egret { - /** - * The Video class lets you work with video in an application. - * The Video class lets you create a Video object, load and play an external video file into that object. - * Note: On most mobile device, the video is playback in the full screen mode.
- * - * @param url URL of the media to play, Video will start to load if the url is not empty - * - * @event egret.Event.COMPLETE Dispatch when the video resource is loaded and ready to play - * @event egret.Event.ENDED Dispatch when the video playback ended - * @event egret.IOErrorEvent.IO_ERROR when the video is failed to load - * @version Egret 2.4 - * @platform Web - * @includeExample egret/media/Video.ts - * @language en_US - */ - /** - * Video 允许您在应用程序中使用视频。使用 Video 类可以创建 Video 对象、将外部视频文件加载到该对象并播放该文件。
- * 注意: 在大多数移动设备中,视频是强制全屏播放的,所以你可以直接调用 play() 方法全屏播放视频,不用将它绘制在Stage中。 - * @see http://edn.egret.com/cn/docs/page/657 视频系统 - * - * @param url 要播放的视频的URL,如果url不为空,Video会立即加载这个视频 - * - * @event egret.Event.COMPLETE 视频加载完成时抛出 - * @event egret.Event.ENDED 视频播放完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 视频加载失败时触发 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/media/Video.ts - * @language zh_CN - */ - interface Video extends DisplayObject { - /** - * Initiates loading of an external video file from the specified URL. - * @param url Audio file URL - * * @param cache Should cache the video,only used in Native - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动从指定 URL 加载外部视频文件的过程。 - * @param url 需要加载的视频文件URL - * @param cache 是否需要缓存到本地,只在 Native 上使用 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string, cache?: boolean): void; - /** - * Play back the video. - * @param startTime The initial position in seconds at which playback should start, (default = 0) - * @param loop Defines should play the video again when the video is ended. (default = false) - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 播放该视频 - * @param startTime 应开始播放的初始位置(以秒为单位),默认值是视频上次结束的位置 - * @param loop 是否需要循环播放,默认值是 false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(startTime?: number, loop?: boolean): any; - /** - * Closes the stream, causing any download of data to cease - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭该流,从而停止所有数据的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - close(): void; - /** - * The URL of the video you want to play. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 想要播放的视频的URL - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - src: string; - /** - * The URL of an image you want to display before the video is loaded or video cannot been draw on the canvas on some mobile device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 视频加载前,或者在不支持将 video 画在 canvas 的设备上,想要显示的视频截图地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - poster: string; - /** - * Should play the video in fullscreen mode (default = true). - * Currently only supports full-screen mobile terminal web. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否全屏播放这个视频(默认值是 true)。 - * 目前移动端 web 只支持全屏。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fullscreen: boolean; - /** - * The volume, ranging from 0 (silent) to 1 (full volume). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音量范围从 0(静音)至 1(最大音量)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - volume: number; - /** - * When the video is playing, the position property indicates - * in seconds the current point that is being played in the video file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当播放视频时,position 属性表示视频文件中当前播放的位置(以秒为单位) - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - position: number; - /** - * Pause the video playing. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停播放。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Get bitmapData of the video file, you can use the video as bitmapData on the stage. - * Note: On most mobile device, the video is playback in the full screen mode. - * So you can just use the play() method instead of draw it on the Stage - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 获取视频的 bitmapData, 你可以将视频绘制到舞台上。 - * 注意: 在大多数移动设备中,视频是全屏播放的,所以你可以直接调用 play() 方法全屏播放视频,不用将它绘制在Stage中。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - bitmapData?: BitmapData; - /** - * Whether current video is paused. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前视频是否在暂停状态。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - paused: boolean; - /** - * Length of the current video (in seconds). - * @version Egret 3.0.8 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前视频的长度(以秒为单位)。 - * @version Egret 3.0.8 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - length: number; - } - /** - * @copy egret.Video - */ - let Video: { - new (url?: string, cache?: boolean): Video; - }; -} -declare namespace egret { - /** - * The HttpMethod class provides values that specify whether the HttpRequest object should use the POST method - * or the GET method when sending data to a server. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HttpRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时, - * HttpRequest 对象应使用 POST 方法还是 GET 方法。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace HttpMethod { - /** - * Specifies that the HttpRequest object is a GET. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 GET。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const GET = "GET"; - /** - * Specifies that the HttpRequest object is a POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const POST = "POST"; - } -} -declare namespace egret { - /** - * The HttpRequest class downloads data from a URL as text or binary data. It is useful for downloading text files, - * XML, or other information to be used in a dynamic, data-driven application. A HttpRequest object downloads all - * of the data from a URL before making it available to code in the applications. It sends out notifications about - * the progress of the download, which you can monitor through the bytesLoaded and bytesTotal properties, - * as well as through dispatched events. - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.Event.IO_ERROR Dispatched when the net request is failed. - * @event egret.ProgressEvent.PROGRESS Dispatched when data is received as the download operation progresses. - * @see egret.HttpMethod - * @see egret.HttpResponseType - * @includeExample egret/net/HttpRequestExample.ts - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HttpRequest 类以文本或二进制数据的形式从 URL 下载数据。 - * HttpRequest 对象会先从 URL 中下载所有数据,然后才将数据用于应用程序中的代码。它会发出有关下载进度的通知, - * 通过 bytesLoaded 和 bytesTotal 属性以及已调度的事件,可以监视下载进度。 - * @event egret.Event.COMPLETE 加载完成 - * @event egret.Event.IO_ERROR 加载失败 - * @event egret.ProgressEvent.PROGRESS 加载进度,可通过event.bytesLoaded和event.bytesTotal统计进度信息。 - * @see egret.HttpMethod - * @see egret.HttpResponseType - * @includeExample egret/net/HttpRequestExample.ts - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface HttpRequest extends EventDispatcher { - /** - * The data received from the load operation. The format of the data depends on the setting of the responseType property. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 本次请求返回的数据,数据类型根据 responseType 设置的值确定。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - response: any; - /** - * Controls whether the downloaded data is received as text (HttpResponseType.TEXT) or raw binary data (HttpResponseType.ArrayBuffer)
- * Note:If you attempt to set this property to an invalid value, Egret runtime set the value to HttpResponseType.TEXT. - * @default egret.HttpResponseType.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置返回的数据格式为文本(HttpResponseType.TEXT)还是二进制数据(HttpResponseType.ArrayBuffer)
- * 注意:若尝试设置此属性为一个非法的值,运行时将使用HttpResponseType.TEXT。 - * @default egret.HttpResponseType.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - responseType: string; - /** - * Can be set to a time in milliseconds.When set to a non-zero value will cause fetching to terminate after the given time has passed. - * @default egret.HttpResponseType.TEXT - * @version Egret 5.2.15 - * @platform Web,Native - * @language en_US - */ - /** - * 代表着一个请求在被自动终止前所消耗的毫秒数。默认值为 0,意味着没有超时。 - * @default egret.HttpResponseType.TEXT - * @version Egret 5.2.15 - * @platform Web,Native - * @language zh_CN - */ - timeout: number; - /** - * indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies - * or authorization headers. (This never affects same-site requests.) - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表明在进行跨站(cross-site)的访问控制(Access-Control)请求时,是否使用认证信息(例如cookie或授权的header)。(这个标志不会影响同站的请求) - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - withCredentials: boolean; - /** - * Initializes a request.
- * Note: Calling this method for an already active request (one for which open() or openRequest() has already been - * called) is the equivalent of calling abort(). - * @param url The URL to send the request to. - * @param method The HTTP method to use, please use the const value in the HttpMethod class. - * @see egret.HttpMethod - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 初始化一个请求.
- * 注意: 若在已经发出请求的对象上调用此方法,相当于立即调用abort(). - * @param url 该请求所要访问的URL该请求所要访问的URL - * @param method 请求所使用的HTTP方法, 请使用 HttpMethod 定义的枚举值. - * @see egret.HttpMethod - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - open(url: string, method?: string): void; - /** - * Sends the request. - * @param data the data to send. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 发送请求. - * @param data 需要发送的数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - send(data?: any): void; - /** - * Aborts the request if it has already been sent. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果请求已经被发送,则立刻中止请求. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - abort(): void; - /** - * Returns all the response headers as a string, or null if no response has been received. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回所有响应头信息(响应头名和值), 如果响应头还没接受,则返回"". - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getAllResponseHeaders(): string; - /** - * Sets the value of an HTTP request header. You must call setRequestHeader() after open(). - * @param header The name of the header whose value is to be set. - * @param value The value to set as the body of the header. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 给指定的HTTP请求头赋值.在这之前,您必须确认已经调用 open() 方法打开了一个url. - * @param header 将要被赋值的请求头名称. - * @param value 给指定的请求头赋的值. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setRequestHeader(header: string, value: string): void; - /** - * Returns the string containing the text of the specified header, or null if either the response has not yet been - * received or the header doesn't exist in the response. - * @param header The name of the header whose value is to be get. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回指定的响应头的值, 如果响应头还没被接受,或该响应头不存在,则返回"". - * @param header 要返回的响应头名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getResponseHeader(header: string): string; - } - /** - * Creates a HttpRequest object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 HttpRequest 实例。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let HttpRequest: { - new (): HttpRequest; - }; -} -declare namespace egret { - /** - * The HttpResponseType class provides values that specify how downloaded data is received. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HttpResponseType { - /** - * Specifies that downloaded data is received as text. This is the default value of HttpRequest.responseType - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回字符串。HttpRequest.responseType属性的默认值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TEXT: string; - /** - * Specifies that downloaded data is received as raw binary data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回二进制的ArrayBuffer对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ARRAY_BUFFER: string; - } -} -declare namespace egret { - /** - * The Loader class is used to load image (JPG, PNG, or GIF) files. Use the load() method to initiate loading. - * The loaded image data is in the data property of ImageLoader. - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.IOErrorEvent.IO_ERROR Dispatched when the net request is failed. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/net/ImageLoaderExample.ts - * @see http://edn.egret.com/cn/docs/page/590 加载位图文件 - * @language en_US - */ - /** - * ImageLoader 类可用于加载图像(JPG、PNG 或 GIF)文件。使用 load() 方法来启动加载。被加载的图像对象数据将存储在 ImageLoader.data 属性上 。 - * @event egret.Event.COMPLETE 加载完成 - * @event egret.IOErrorEvent.IO_ERROR 加载失败 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/net/ImageLoaderExample.ts - * @see http://edn.egret.com/cn/docs/page/590 加载位图文件 - * @language zh_CN - */ - interface ImageLoader extends EventDispatcher { - /** - * The data received from the load operation. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用 load() 方法加载成功的 BitmapData 图像数据。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: BitmapData; - /** - * Specifies whether or not cross-site Access-Control requests should be made when loading a image from foreign origins.
- * possible values are:"anonymous","use-credentials" or null. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当从其他站点加载一个图片时,指定是否启用跨域资源共享(CORS),默认值为null。
- * 可以设置为"anonymous","use-credentials"或null,设置为其他值将等同于"anonymous"。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - crossOrigin: string; - /** - * start a load operation。
- * Note: Calling this method for an already active request (one for which load() has already been - * called) will abort the last load operation immediately. - * @param url 要加载的图像文件的地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动一次图像加载。
- * 注意:若之前已经调用过加载请求,重新调用 load() 将终止先前的请求,并开始新的加载。 - * @param url 要加载的图像文件的地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string): void; - } - /** - * Creates a ImageLoader object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 ImageLoader 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let ImageLoader: { - /** - * constructor - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - new (): ImageLoader; - /** - * Specifies whether to enable cross-origin resource sharing, If ImageLoader instance has been set crossOrigin property will be used to set the property. - * @version Egret 2.5.7 - * @platform Web,Native - * @language en_US - */ - /** - * 指定是否启用跨域资源共享,如果ImageLoader实例有设置过crossOrigin属性将使用设置的属性 - * @version Egret 2.5.7 - * @platform Web,Native - * @language zh_CN - */ - crossOrigin: string; - }; -} -declare namespace egret.sys { - /** - * @private - * 显示列表 - */ - class DisplayList extends HashObject { - /** - * 创建一个DisplayList对象,若内存不足或无法创建RenderBuffer,将会返回null。 - */ - static create(target: DisplayObject): DisplayList; - /** - * @private - * 创建一个DisplayList对象 - */ - constructor(root: DisplayObject); - private isStage; - /** - * 位图渲染节点 - */ - $renderNode: RenderNode; - /** - * @private - * 获取渲染节点 - */ - $getRenderNode(): sys.RenderNode; - /** - * @private - */ - renderBuffer: RenderBuffer; - /** - * @private - */ - offsetX: number; - /** - * @private - */ - offsetY: number; - /** - * @private - */ - private offsetMatrix; - /** - * @private - * 显示列表根节点 - */ - root: DisplayObject; - /** - * @private - * 设置剪裁边界,不再绘制完整目标对象,画布尺寸由外部决定,超过边界的节点将跳过绘制。 - */ - setClipRect(width: number, height: number): void; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * @private - * 绘制根节点显示对象到目标画布,返回draw的次数。 - */ - drawToSurface(): number; - private bitmapData; - /** - * @private - * 改变画布的尺寸,由于画布尺寸修改会清空原始画布。所以这里将原始画布绘制到一个新画布上,再与原始画布交换。 - */ - changeSurfaceSize(): void; - static $canvasScaleFactor: number; - /** - * @private - */ - static $canvasScaleX: number; - static $canvasScaleY: number; - /** - * @private - */ - static $setCanvasScale(x: number, y: number): void; - } -} -declare namespace egret { - type runEgretOptions = { - renderMode?: string; - audioType?: number; - screenAdapter?: sys.IScreenAdapter; - antialias?: boolean; - canvasScaleFactor?: number; - calculateCanvasScaleFactor?: (context: CanvasRenderingContext2D) => number; - /** - * 以下目前仅供小游戏使用 - * The following are for mini-games only - */ - entryClassName?: string; - scaleMode?: string; - frameRate?: number; - contentWidth?: number; - contentHeight?: number; - orientation?: string; - maxTouches?: number; - showFPS?: boolean; - showLog?: boolean; - fpsStyles?: string; - }; - /** - * egret project entry function - * @param options An object containing the initialization properties for egret engine. - * @language en_US - */ - /** - * egret工程入口函数 - * @param options 一个可选对象,包含初始化Egret引擎需要的参数。 - * @language zh_CN - */ - function runEgret(options?: runEgretOptions): void; - /** - * Refresh the screen display - * @language en_US - */ - /** - * 刷新屏幕显示 - * @language zh_CN - */ - function updateAllScreens(): void; -} -declare namespace egret { - /** - * @private - */ - interface FPSDisplay { - /** - * 更新FPS信息 - */ - update(datas: FPSData): void; - /** - * 插入一条log信息 - */ - updateInfo(info: string): void; - /** - * 插入一条warn信息 - */ - updateWarn(info: string): void; - /** - * 插入一条error信息 - */ - updateError(info: string): void; - } - /** - * @private - */ - let FPSDisplay: { - new (stage: Stage, showFPS: boolean, showLog: boolean, logFilter: string, styles: Object): FPSDisplay; - }; -} -/** - * @private - */ -interface FPSData extends Object { - fps: number; - draw: number; - costTicker: number; - costRender: number; -} -declare namespace egret.sys { - let $TempStage: egret.Stage; - /** - * @private - * Egret播放器 - */ - class Player extends HashObject { - /** - * @private - * 实例化一个播放器对象。 - */ - constructor(buffer: RenderBuffer, stage: Stage, entryClassName: string); - /** - * @private - */ - private createDisplayList(stage, buffer); - /** - * @private - */ - private screenDisplayList; - /** - * @private - * 入口类的完整类名 - */ - private entryClassName; - /** - * @private - * 舞台引用 - */ - stage: Stage; - /** - * @private - * 入口类实例 - */ - private root; - /** - * @private - */ - private isPlaying; - /** - * @private - * 启动播放器 - */ - start(): void; - /** - * @private - */ - private initialize(); - /** - * @private - * 停止播放器,停止后将不能重新启动。 - */ - stop(): void; - /** - * @private - * 暂停播放器,后续可以通过调用start()重新启动播放器。 - */ - pause(): void; - /** - * @private - * 渲染屏幕 - */ - $render(triggerByFrame: boolean, costTicker: number): void; - /** - * @private - * 更新舞台尺寸 - * @param stageWidth 舞台宽度(以像素为单位) - * @param stageHeight 舞台高度(以像素为单位) - */ - updateStageSize(stageWidth: number, stageHeight: number): void; - /** - * @private - * 显示FPS。 - */ - displayFPS(showFPS: boolean, showLog: boolean, logFilter: string, styles: Object): void; - /** - * @private - */ - private showFPS; - /** - * @private - */ - private showLog; - /** - * @private - */ - private stageDisplayList; - } - /** - * @private - */ - let $logToFPS: (info: string) => void; - /** - * @private - */ - let $warnToFPS: (info: string) => void; - /** - * @private - */ - let $errorToFPS: (info: string) => void; -} -/** - * @private - */ -declare module egret { - /** - * @private - */ - var nativeRender: boolean; -} -declare namespace egret { - /** !!!!!!!!inspired by Babylon.js!!!!!!!!!!!!! - * for description see https://www.khronos.org/opengles/sdk/tools/KTX/ - * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ - * Current families are astc, dxt, pvrtc, etc2, & etc1. - * @returns The extension selected. - */ - class KTXContainer { - /** contents of the KTX container file */ arrayBuffer: any; - private static readonly HEADER_LEN; - private static readonly COMPRESSED_2D; - private static readonly COMPRESSED_3D; - private static readonly TEX_2D; - private static readonly TEX_3D; - /** - * Gets the openGL type - */ - glType: number; - /** - * Gets the openGL type size - */ - glTypeSize: number; - /** - * Gets the openGL format - */ - glFormat: number; - /** - * Gets the openGL internal format - */ - glInternalFormat: number; - /** - * Gets the base internal format - */ - glBaseInternalFormat: number; - /** - * Gets image width in pixel - */ - pixelWidth: number; - /** - * Gets image height in pixel - */ - pixelHeight: number; - /** - * Gets image depth in pixels - */ - pixelDepth: number; - /** - * Gets the number of array elements - */ - numberOfArrayElements: number; - /** - * Gets the number of faces - */ - numberOfFaces: number; - /** - * Gets the number of mipmap levels - */ - numberOfMipmapLevels: number; - /** - * Gets the bytes of key value data - */ - bytesOfKeyValueData: number; - /** - * Gets the load type - */ - loadType: number; - /** - * If the container has been made invalid (eg. constructor failed to correctly load array buffer) - */ - isInvalid: boolean; - /** - * Creates a new KhronosTextureContainer - * @param arrayBuffer contents of the KTX container file - * @param facesExpected should be either 1 or 6, based whether a cube texture or or - * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented - * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented - */ - constructor(/** contents of the KTX container file */ arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean); - /** - * Uploads KTX content to a Babylon Texture. - * It is assumed that the texture has already been created & is currently bound - * @hidden - */ - uploadLevels(bitmapData: egret.BitmapData, loadMipmaps: boolean): void; - private _upload2DCompressedLevels(bitmapData, loadMipmaps); - } -} -declare namespace egret.sys { - /** - * @private - * 共享的用于碰撞检测的渲染缓冲 - */ - let customHitTestBuffer: sys.RenderBuffer; - /** - * @private - * 共享的用于canvas碰撞检测的渲染缓冲 - */ - let canvasHitTestBuffer: sys.RenderBuffer; - /** - * @private - * 渲染缓冲 - */ - interface RenderBuffer { - /** - * 呈现最终绘图结果的画布。 - * @readOnly - */ - surface: any; - /** - * 渲染上下文。 - * @readOnly - */ - context: any; - /** - * 渲染缓冲的宽度,以像素为单位。 - * @readOnly - */ - width: number; - /** - * 渲染缓冲的高度,以像素为单位。 - * @readOnly - */ - height: number; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 - */ - resize(width: number, height: number, useMaxSize?: boolean): void; - /** - * 获取指定区域的像素 - */ - getPixels(x: number, y: number, width?: number, height?: number): number[]; - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如: "image/png","image/jpeg" - */ - toDataURL(type?: string, ...args: any[]): string; - /** - * 清空缓冲区数据 - */ - clear(): void; - /** - * 销毁渲染缓冲 - */ - destroy(): void; - } - /** - * @private - */ - let RenderBuffer: { - /** - * 创建一个RenderTarget。 - * 注意:若内存不足或创建缓冲区失败,将会抛出错误异常。 - * @param width 渲染缓冲的初始宽 - * @param height 渲染缓冲的初始高 - * @param root 是否为舞台buffer - */ - new (width?: number, height?: number, root?: boolean): RenderBuffer; - }; - /** - * @private - */ - let CanvasRenderBuffer: { - /** - * 创建一个CanvasRenderBuffer。 - * 注意:若内存不足或创建缓冲区失败,将会抛出错误异常。 - * @param width 渲染缓冲的初始宽 - * @param height 渲染缓冲的初始高 - */ - new (width?: number, height?: number): RenderBuffer; - }; -} -declare namespace egret.sys { - /** - * @private - * 设备屏幕 - */ - interface Screen { - /** - * @private - * 更新屏幕视口尺寸 - */ - updateScreenSize(): any; - /** - * @private - * 更新触摸数量 - */ - updateMaxTouches(): any; - /** - * @private - * 设置分辨率尺寸 - */ - setContentSize(width: number, height: number): any; - } -} -declare namespace egret.sys { - /** - * @private - * 屏幕适配器接口,当播放器视口尺寸改变时,屏幕适配器将被用于计算当前对应的舞台显示尺寸。 - */ - interface IScreenAdapter { - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; - } - /** - * @private - * 舞台显示尺寸数据 - */ - interface StageDisplaySize { - /** - * @private - * 舞台宽度 - */ - stageWidth: number; - /** - * @private - * 舞台高度 - */ - stageHeight: number; - /** - * @private - * 显示宽度,若跟舞台宽度不同,将会产生缩放。 - */ - displayWidth: number; - /** - * @private - * 显示高度,若跟舞台高度不同,将会产生缩放。 - */ - displayHeight: number; - } - /** - * @private - * 屏幕适配器实例,开发者可以通过给这个变量赋值实现了IScreenAdapter接口的实例,从而注入自定义的屏幕适配器。 - */ - let screenAdapter: IScreenAdapter; - /** - * @private - * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。 - */ - class DefaultScreenAdapter extends HashObject implements IScreenAdapter { - /** - * @private - */ - constructor(); - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; - } -} -declare namespace egret { - /** - * StageScaleMode class provides values for the stage zoom mode. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language en_US - */ - /** - * StageScaleMode 类为舞台缩放模式提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language zh_CN - */ - class StageScaleMode { - /** - * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent. - * @language en_US - */ - /** - * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。 - * @language zh_CN - */ - static NO_SCALE: string; - /** - * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static SHOW_ALL: string; - /** - * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static NO_BORDER: string; - /** - * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static EXACT_FIT: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
- * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
- * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。 - * @language zh_CN - */ - static FIXED_WIDTH: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
- * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
- * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。 - * @language zh_CN - */ - static FIXED_HEIGHT: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.
- * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。
- * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - static FIXED_NARROW: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.
- * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。
- * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - static FIXED_WIDE: string; - } -} -declare namespace egret.sys { - /** - * @private - */ - let systemRenderer: SystemRenderer; - /** - * @private - * 用于碰撞检测绘制 - */ - let canvasRenderer: SystemRenderer; - /** - * @private - * 显示渲染器接口 - */ - interface SystemRenderer { - /** - * 渲染一个显示对象 - * @param displayObject 要渲染的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forRenderTexture 绘制目标是RenderTexture的标志 - * @returns drawCall触发绘制的次数 - */ - render(displayObject: DisplayObject, buffer: RenderBuffer, matrix: Matrix, forRenderTexture?: boolean): number; - /** - * 将一个RenderNode对象绘制到渲染缓冲 - * @param node 要绘制的节点 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 - */ - drawNodeToBuffer(node: sys.RenderNode, buffer: RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; - } - /** - * - */ - interface RenderContext { - } - /** - * 创建一个canvas。 - */ - function mainCanvas(width?: number, height?: number): HTMLCanvasElement; - function createCanvas(width?: number, height?: number): HTMLCanvasElement; - /** - * 重新设置主canvas的大小 - */ - function resizeContext(renderContext: RenderContext, width: number, height: number, useMaxSize?: boolean): void; - /** - * 获得系统的渲染运行时 - */ - function getContextWebGL(surface: HTMLCanvasElement): WebGLRenderingContext; - function getContext2d(surface: HTMLCanvasElement): CanvasRenderingContext2D; - /** - * 仅通过bitmapData创建纹理 - */ - function createTexture(renderContext: RenderContext, bitmapData: BitmapData | HTMLCanvasElement): WebGLTexture; - /** - * 通过 width, height, data创建纹理 - */ - function _createTexture(renderContext: RenderContext, width: number, height: number, data: any): WebGLTexture; - /** - * 画texture - **/ - function drawTextureElements(renderContext: RenderContext, data: any, offset: number): number; - /** - * 测量文本的宽度 - * @param context - * @param text - */ - function measureTextWith(context: CanvasRenderingContext2D, text: string): number; - /** - * 为CanvasRenderBuffer创建一个canvas - * @param defaultFunc - * @param width - * @param height - * @param root - */ - function createCanvasRenderBufferSurface(defaultFunc: (width?: number, height?: number) => HTMLCanvasElement, width?: number, height?: number, root?: boolean): HTMLCanvasElement; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param renderContext - * @param width - * @param height - * @param useMaxSize - */ - function resizeCanvasRenderBuffer(renderContext: RenderContext, width: number, height: number, useMaxSize?: boolean): void; -} -declare namespace egret.sys { - /** - * @private - */ - let $START_TIME: number; - /** - * @private - * 是否要广播Event.RENDER事件的标志。 - */ - let $invalidateRenderFlag: boolean; - /** - * @private - * 需要立即刷新屏幕的标志 - */ - let $requestRenderingFlag: boolean; - /** - * Egret心跳计时器 - */ - class SystemTicker { - /** - * @private - */ - constructor(); - /** - * @private - */ - private playerList; - /** - * @private - * 注册一个播放器实例并运行 - */ - $addPlayer(player: Player): void; - /** - * @private - * 停止一个播放器实例的运行。 - */ - $removePlayer(player: Player): void; - /** - * @private - */ - private callBackList; - /** - * @private - */ - private thisObjectList; - /** - * @private - */ - $startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; - /** - * @private - */ - $stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; - /** - * @private - */ - private getTickIndex(callBack, thisObject); - /** - * @private - * - */ - private concatTick(); - /** - * @private - * 全局帧率 - */ - $frameRate: number; - /** - * @private - */ - private frameInterval; - /** - * @private - */ - private frameDeltaTime; - /** - * @private - */ - private lastTimeStamp; - /** - * @private - * 设置全局帧率 - */ - $setFrameRate(value: number): boolean; - /** - * @private - */ - private lastCount; - /** - * @private - * ticker 花销的时间 - */ - private costEnterFrame; - /** - * @private - * 是否被暂停 - */ - private isPaused; - /** - * Pause the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Resume the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 恢复心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - resume(): void; - /** - * @private - * 执行一次刷新 - */ - update(forceUpdate?: boolean): void; - /** - * @private - * 执行一次屏幕渲染 - */ - private render(triggerByFrame, costTicker); - /** - * @private - * 广播EnterFrame事件。 - */ - private broadcastEnterFrame(); - /** - * @private - * 广播Render事件。 - */ - private broadcastRender(); - /** - * @private - */ - private callLaters(); - /** - * @private - */ - private callLaterAsyncs(); - } -} -declare module egret { - namespace lifecycle { - type LifecyclePlugin = (context: LifecycleContext) => void; - /** - * @private - */ - let stage: egret.Stage; - /** - * @private - */ - let contexts: LifecycleContext[]; - class LifecycleContext { - pause(): void; - resume(): void; - onUpdate?: () => void; - } - let onResume: () => void; - let onPause: () => void; - function addLifecycleListener(plugin: LifecyclePlugin): void; - } - /** - * 心跳计时器单例 - */ - let ticker: sys.SystemTicker; -} -/** - * @private - */ -declare let egret_stages: egret.Stage[]; -declare namespace egret.sys { - /** - * @private - * 用户交互操作管理器 - */ - class TouchHandler extends HashObject { - private maxTouches; - private useTouchesCount; - /** - * @private - */ - constructor(stage: Stage); - /** - * @private - * 设置同时触摸数量 - */ - $initMaxTouches(): void; - /** - * @private - */ - private stage; - /** - * @private - */ - private touchDownTarget; - /** - * @private - * 触摸开始(按下) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchBegin(x: number, y: number, touchPointID: number): void; - /** - * @private - */ - private lastTouchX; - /** - * @private - */ - private lastTouchY; - /** - * @private - * 触摸移动 - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchMove(x: number, y: number, touchPointID: number): void; - /** - * @private - * 触摸结束(弹起) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchEnd(x: number, y: number, touchPointID: number): void; - /** - * @private - * 获取舞台坐标下的触摸对象 - */ - private findTarget(stageX, stageY); - } -} -declare namespace egret.sys { - /** - * @private - * 位图渲染节点 - */ - class BitmapNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 使用的混合模式 - */ - blendMode: number; - /** - * 相对透明度 - */ - alpha: number; - /** - * 颜色变换滤镜 - */ - filter: ColorMatrixFilter; - /** - * 翻转 - */ - rotated: boolean; - /** - * 绘制一次位图 - */ - drawImage(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - static $updateTextureData(node: sys.NormalBitmapNode, image: BitmapData, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, destW: number, destH: number, sourceWidth: number, sourceHeight: number, fillMode: string, smoothing: boolean): void; - /** - * @private - * 绘制九宫格位图 - */ - static $updateTextureDataWithScale9Grid(node: sys.NormalBitmapNode, image: BitmapData, scale9Grid: egret.Rectangle, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, destW: number, destH: number, sourceWidth: number, sourceHeight: number, smoothing: boolean): void; - /** - * @private - */ - private static drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX?, startY?); - } -} -declare namespace egret.sys { - /** - * @private - * 矢量渲染节点 - */ - class GraphicsNode extends RenderNode { - constructor(); - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - beginFill(color: number, alpha?: number, beforePath?: Path2D): Path2D; - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - beginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix?: egret.Matrix, beforePath?: Path2D): Path2D; - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - */ - lineStyle(thickness?: number, color?: number, alpha?: number, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): StrokePath; - /** - * 清空所有缓存的绘制数据 - */ - clear(): void; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - */ - cleanBeforeRender(): void; - /** - * 绘制x偏移 - */ - x: number; - /** - * 绘制y偏移 - */ - y: number; - /** - * 绘制宽度 - */ - width: number; - /** - * 绘制高度 - */ - height: number; - /** - * 脏渲染标记 - * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D - */ - dirtyRender: boolean; - $texture: WebGLTexture; - $textureWidth: number; - $textureHeight: number; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * 清除非绘制的缓存数据 - */ - clean(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 组渲染节点,用于组合多个渲染节点 - */ - class GroupNode extends RenderNode { - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - constructor(); - addNode(node: RenderNode): void; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - * 这里只是想清空绘制命令,因此不调用super - */ - cleanBeforeRender(): void; - $getRenderCount(): number; - } -} -declare namespace egret.sys { - /** - * @private - * Mesh 渲染节点 - */ - class MeshNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - /** - * UV 坐标。 - */ - uvs: number[]; - /** - * 顶点坐标。 - */ - vertices: number[]; - /** - * 顶点索引。 - */ - indices: number[]; - /** - * 顶点索引。 - */ - bounds: Rectangle; - /** - * 使用的混合模式 - */ - blendMode: number; - /** - * 相对透明度 - */ - alpha: number; - /** - * 颜色变换滤镜 - */ - filter: ColorMatrixFilter; - /** - * 翻转 - */ - rotated: boolean; - /** - * 绘制一次位图 - */ - drawMesh(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 位图渲染节点 - */ - class NormalBitmapNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 翻转 - */ - rotated: boolean; - sourceX: number; - sourceY: number; - sourceW: number; - sourceH: number; - drawX: number; - drawY: number; - drawW: number; - drawH: number; - /** - * 绘制一次位图 - */ - drawImage(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret { - /** - * @private - */ - class Mesh extends Bitmap { - constructor(value?: Texture); - protected createNativeDisplayObject(): void; - /** - * @private - */ - protected setBitmapDataToWasm(data?: Texture): void; - /** - * @private - */ - $updateRenderNode(): void; - /** - * @private - */ - private _verticesDirty; - private _bounds; - /** - * @private - */ - $updateVertices(): void; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - } -} -declare namespace egret.sys { - /** - * @private - * 文本格式 - */ - interface TextFormat { - /** - * 颜色值 - */ - textColor?: number; - /** - * 描边颜色值 - */ - strokeColor?: number; - /** - * 字号 - */ - size?: number; - /** - * 描边大小 - */ - stroke?: number; - /** - * 是否加粗 - */ - bold?: boolean; - /** - * 是否倾斜 - */ - italic?: boolean; - /** - * 字体名称 - */ - fontFamily?: string; - } -} -declare namespace egret.sys { - /** - * @private - * 文本渲染节点 - */ - class TextNode extends RenderNode { - constructor(); - /** - * 颜色值 - */ - textColor: number; - /** - * 描边颜色值 - */ - strokeColor: number; - /** - * 字号 - */ - size: number; - /** - * 描边大小 - */ - stroke: number; - /** - * 是否加粗 - */ - bold: boolean; - /** - * 是否倾斜 - */ - italic: boolean; - /** - * 字体名称 - */ - fontFamily: string; - /** - * 绘制一行文本 - */ - drawText(x: number, y: number, text: string, format: TextFormat): void; - /** - * 绘制x偏移 - */ - x: number; - /** - * 绘制y偏移 - */ - y: number; - /** - * 绘制宽度 - */ - width: number; - /** - * 绘制高度 - */ - height: number; - /** - * 脏渲染标记 - */ - dirtyRender: boolean; - $texture: WebGLTexture; - $textureWidth: number; - $textureHeight: number; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * 清除非绘制的缓存数据 - */ - clean(): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 填充路径 - */ - class FillPath extends Path2D { - constructor(); - /** - * 填充颜色 - */ - fillColor: number; - /** - * 填充透明度 - */ - fillAlpha: number; - } -} -declare namespace egret.sys { - /** - * @private - * 渐变填充路径 - */ - class GradientFillPath extends Path2D { - constructor(); - gradientType: string; - colors: number[]; - alphas: number[]; - ratios: number[]; - matrix: Matrix; - } -} -declare namespace egret { - /** - * OrientationMode 类为舞台初始旋转模式提供值。 - */ - const OrientationMode: { - AUTO: string; - PORTRAIT: string; - LANDSCAPE: string; - LANDSCAPE_FLIPPED: string; - }; -} -declare namespace egret.sys { - /** - * @private - * 线条路径。 - * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - class StrokePath extends Path2D { - constructor(); - /** - * 线条宽度。 - * 注意:绘制时对1像素和3像素要特殊处理,整体向右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - lineWidth: number; - /** - * 线条颜色 - */ - lineColor: number; - /** - * 线条透明度 - */ - lineAlpha: number; - /** - * 端点样式,"none":无端点,"round":圆头端点,"square":方头端点 - */ - caps: string; - /** - * 联接点样式,"bevel":斜角连接,"miter":尖角连接,"round":圆角连接 - */ - joints: string; - /** - * 用于表示剪切斜接的极限值的数字。 - */ - miterLimit: number; - /** - * 描述交替绘制线段和间距(坐标空间单位)长度的数字。 - */ - lineDash: number[]; - } -} -/** - * @private - */ -interface CanvasRenderingContext2D { - imageSmoothingEnabled: boolean; - $imageSmoothingEnabled: boolean; - $offsetX: number; - $offsetY: number; -} -declare namespace egret { - class CanvasRenderer { - private nestLevel; - render(displayObject: DisplayObject, buffer: sys.RenderBuffer, matrix: Matrix, forRenderTexture?: boolean): number; - /** - * @private - * 绘制一个显示对象 - */ - private drawDisplayObject(displayObject, context, offsetX, offsetY, isStage?); - private drawWithFilter(displayObject, context, offsetX, offsetY); - private drawWithClip(displayObject, context, offsetX, offsetY); - private drawWithScrollRect(displayObject, context, offsetX, offsetY); - drawNodeToBuffer(node: sys.RenderNode, buffer: sys.RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; - /** - * 将一个DisplayObject绘制到渲染缓冲,用于RenderTexture绘制 - * @param displayObject 要绘制的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - */ - drawDisplayToBuffer(displayObject: DisplayObject, buffer: sys.RenderBuffer, matrix: Matrix): number; - private renderNode(node, context, forHitTest?); - private renderNormalBitmap(node, context); - private renderBitmap(node, context); - private renderMesh(node, context); - renderText(node: sys.TextNode, context: CanvasRenderingContext2D): void; - private renderingMask; - /** - * @private - */ - renderGraphics(node: sys.GraphicsNode, context: CanvasRenderingContext2D, forHitTest?: boolean): number; - private renderPath(path, context); - private renderGroup(groupNode, context); - private createRenderBuffer(width, height, useForFilters?); - } - /** - * @private - * 获取字体字符串 - */ - function getFontString(node: sys.TextNode, format: sys.TextFormat): string; - /** - * @private - * 获取RGBA字符串 - */ - function getRGBAString(color: number, alpha: number): string; -} -declare namespace egret { - /** - * Orientation monitor the orientation of the device, send CHANGE event when the orientation is changed - * - * @event egret.Event.CHANGE device's orientation is changed - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/DeviceOrientation.ts - * @see http://edn.egret.com/cn/docs/page/661 获取设备旋转角度 - * @language en_US - */ - /** - * Orientation 监听设备方向的变化,当方向变化时派发 CHANGE 事件 - * @event egret.Event.CHANGE 设备方向改变时派发 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/DeviceOrientation.ts - * @see http://edn.egret.com/cn/docs/page/661 获取设备旋转角度 - * @language zh_CN - */ - interface DeviceOrientation extends EventDispatcher { - /** - * Start to monitor the device's orientation - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备方向变化 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor the device's orientation - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备方向变化 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * @copy egret.Orientation - */ - let DeviceOrientation: { - new (): DeviceOrientation; - }; -} -declare namespace egret { - /** - * The Geolocation able to obtain the position of the device. - * Geolocation will emit CHANGE event when the device's location is changed. - * It will emit IO_ERROR event if the location request is denied - * or there is no location service on the device. - * - * @event egret.Event.CHANGE The device's location is changed - * @event egret.Event.IO_ERROR Error occurred while getting the location - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Geolocation.ts - * @language en_US - */ - /** - * Geolocation 能够从设备的定位服务获取设备的当前位置。 - * 当设备的位置发生改变时 Geolocation 会派发 CHANGE 事件。 - * 当定位请求被拒绝或该设备没有定位服务时 Geolocation 会派发 IO_ERROR 事件。 - * - * @event egret.Event.CHANGE 设备位置发生改变 - * @event egret.Event.IO_ERROR 获取设备位置时发生错误 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Geolocation.ts - * @language zh_CN - */ - interface Geolocation extends EventDispatcher { - /** - * Start to monitor the device's location - * @returns - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备位置信息 - * @returns - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor the device's location - * @returns - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备位置信息 - * @returns - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * @copy egret.Geolocation - */ - let Geolocation: { - /** - * constructor - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 构造函数 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - new (): Geolocation; - }; -} -declare namespace egret { - /** - * @copy egret.Motion - */ - let Motion: { - new (): Motion; - }; - /** - * The Motion class emits events based on activity detected by the device's motion sensor. - * This data represents the device's movement along a 3-dimensional axis. When the device moves, - * the sensor detects this movement and emit the CHANGE event. @see egret.MotionEvent - * - * @event egret.Event.CHANGE device is moved - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Motion.ts - * @language en_US - */ - /** - * Motion 类从用户设备读取运动状态信息并派发 CHANGE 事件。 - * 当设备移动时,传感器会检测到此移动并返回设备加速度,重力和旋转数据。@see egret.MotionEvent - * Motion 类提供了 start 和 stop 方法,来启动和停止运动信息检查 - * - * @event egret.Event.CHANGE 运动状态发生改变 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Motion.ts - * @language zh_CN - */ - interface Motion extends EventDispatcher { - /** - * Start to monitor device movement - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备运动状态 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor device movement - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备运动状态 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * A DeviceRotationRate object provides information about the rate at which - * the device is rotating around all three axes. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * DeviceRotationRate 提供设备围绕三个轴旋转的角速度信息,单位是 角度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - interface DeviceRotationRate { - /** - * The amount of rotation around the Z axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 Z 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - alpha: number; - /** - * The amount of rotation around the X axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 X 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - beta: number; - /** - * The amount of rotation around the Y axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 Y 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - gamma: number; - } - /** - * A DeviceAcceleration object provides information about the amount - * of acceleration the device is experiencing along all three axes. - * Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * DeviceAcceleration 提供设备在三个维度的加速度信息,加速度值的单位是 m/s2 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - interface DeviceAcceleration { - /** - * The amount of acceleration along the X axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * X 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - x: number; - /** - * The amount of acceleration along the Y axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * Y 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - y: number; - /** - * The amount of acceleration along the Z axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * Z 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - z: number; - } -} -declare namespace egret { - /** - * Type of operation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行类型的类型。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace RuntimeType { - /** - * Running on Web - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Web上 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const WEB = "web"; - /** - * Running on NATIVE - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language en_US - */ - /** - * 运行在NATIVE上 - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language zh_CN - */ - const NATIVE = "native"; - /** - * Running on Runtime2.0 - * @version Egret 5.1.5 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Runtime2.0上 - * @version Egret 5.1.5 - * @platform Web,Native - * @language zh_CN - */ - const RUNTIME2 = "runtime2"; - /** - * Running on Alipay - * @version Egret 5.2.33 - * @platform All - * @language en_US - */ - /** - * 运行在支付宝小游戏上 - * @version Egret 5.2.33 - * @platform All - * @language zh_CN - */ - const MYGAME = "mygame"; - /** - * Running on WeChat mini game - * @version Egret 5.1.5 - * @platform All - * @language en_US - */ - /** - * 运行在微信小游戏上 - * @version Egret 5.1.5 - * @platform All - * @language zh_CN - */ - const WXGAME = "wxgame"; - /** - * Running on Baidu mini game - * @version Egret 5.2.13 - * @platform All - * @language en_US - */ - /** - * 运行在百度小游戏上 - * @version Egret 5.2.13 - * @platform All - * @language zh_CN - */ - const BAIDUGAME = "baidugame"; - /** - * Running on Xiaomi quick game - * @version Egret 5.2.14 - * @platform All - * @language en_US - */ - /** - * 运行在小米快游戏上 - * @version Egret 5.2.14 - * @platform All - * @language zh_CN - */ - const QGAME = "qgame"; - /** - * Running on OPPO mini game - * @version Egret 5.2.14 - * @platform All - * @language en_US - */ - /** - * 运行在 Oppo 小游戏上 - * @version Egret 5.2.14 - * @platform All - * @language zh_CN - */ - const OPPOGAME = "oppogame"; - /** - * Running on QQ mini game - * @version Egret 5.2.25 - * @platform All - * @language en_US - */ - /** - * 运行在 QQ 小游戏上 - * @version Egret 5.2.25 - * @platform All - * @language zh_CN - */ - const QQGAME = "qqgame"; - /** - * Running on vivo mini game - * @version Egret 5.2.23 - * @platform All - * @language en_US - */ - /** - * 运行在 vivo 小游戏上 - * @version Egret 5.2.23 - * @platform All - * @language zh_CN - */ - const VIVOGAME = "vivogame"; - } - interface SupportedCompressedTexture { - pvrtc: boolean; - etc1: boolean; - } - /** - * The Capabilities class provides properties that describe the system and runtime that are hosting the application. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language en_US - */ - /** - * Capabilities 类提供一些属性,这些属性描述了承载应用程序的系统和运行时。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language zh_CN - */ - class Capabilities { - /** - * Specifies the language code of the system on which the content is running. The language is specified as a lowercase - * two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code from ISO 3166 - * distinguishes between Simplified and Traditional Chinese.
- * The following table lists the possible values,but not limited to them: - *
    - *
  • Simplified Chinese zh-CN
  • - *
  • Traditional Chinese zh-TW
  • - *
  • English en
  • - *
  • Japanese ja
  • - *
  • Korean ko
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示运行内容的系统的语言代码。语言指定为 ISO 639-1 中的小写双字母语言代码。 - * 对于中文,另外使用 ISO 3166 中的大写双字母国家/地区代码,以区分简体中文和繁体中文。
- * 以下是可能但不限于的语言和值: - *
    - *
  • 简体中文 zh-CN
  • - *
  • 繁体中文 zh-TW
  • - *
  • 英语 en
  • - *
  • 日语 ja
  • - *
  • 韩语 ko
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly language: string; - /** - * Specifies whether the system is running in a mobile device.(such as a mobile phone or tablet) - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示程序内容是否运行在移动设备中(例如移动电话或平板电脑)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly isMobile: boolean; - /** - * Specifies the current operating system. The os property can return the following strings: - *
    - *
  • iPhone "iOS"
  • - *
  • Android Phone "Android"
  • - *
  • Windows Phone "Windows Phone"
  • - *
  • Windows Desktop "Windows PC"
  • - *
  • Mac Desktop "Mac OS"
  • - *
  • Unknown OS "Unknown"
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的操作系统。os 属性返回下列字符串: - *
    - *
  • 苹果手机操作系统 "iOS"
  • - *
  • 安卓手机操作系统 "Android"
  • - *
  • 微软手机操作系统 "Windows Phone"
  • - *
  • 微软桌面操作系统 "Windows PC"
  • - *
  • 苹果桌面操作系统 "Mac OS"
  • - *
  • 未知操作系统 "Unknown"
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly os: string; - /** - * It indicates the current type of operation. runtimeType property returns the following string: - *
    - *
  • Run on Web egret.RuntimeType.WEB
  • - *
  • Run on Runtime2.0 egret.RuntimeType.RUNTIME2
  • - *
  • Run on WeChat mini game egret.RuntimeType.WXGAME
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的运行类型。runtimeType 属性返回下列字符串: - *
    - *
  • 运行在Web上 egret.RuntimeType.WEB
  • - *
  • 运行在Runtime2.0上 egret.RuntimeType.RUNTIME2
  • - *
  • 运行在微信小游戏上 egret.RuntimeType.WXGAME
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly runtimeType: string; - /*** - * version of Egret. - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language en_US - */ - /*** - * Egret 的版本号。 - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language zh_CN - */ - static readonly engineVersion: string; - /*** - * current render mode. - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language en_US - */ - /*** - * 当前渲染模式。 - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language zh_CN - */ - static readonly renderMode: string; - /*** - * Clients border width. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界宽度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - static readonly boundingClientWidth: number; - /*** - * Clients border height. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界高度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - static readonly boundingClientHeight: number; - /*** - * supported compressed texture - * @version Egret 5.2.19 - * @platform Web,Native - * @language en_US - */ - /*** - * supported compressed texture - * @version Egret 5.2.19 - * @platform Web,Native - * @language zh_CN - */ - static supportedCompressedTexture: SupportedCompressedTexture; - } -} -declare namespace egret { - /** - * RenderTexture is a dynamic texture - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language en_US - */ - /** - * RenderTexture 是动态纹理类,他实现了将显示对象及其子对象绘制成为一个纹理的功能 - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language zh_CN - */ - class RenderTexture extends egret.Texture { - constructor(); - $renderBuffer: sys.RenderBuffer; - /** - * The specified display object is drawn as a texture - * @param displayObject {egret.DisplayObject} the display to draw - * @param clipBounds {egret.Rectangle} clip rect - * @param scale {number} scale factor - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定显示对象绘制为一个纹理 - * @param displayObject {egret.DisplayObject} 需要绘制的显示对象 - * @param clipBounds {egret.Rectangle} 绘制矩形区域 - * @param scale {number} 缩放比例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawToTexture(displayObject: egret.DisplayObject, clipBounds?: Rectangle, scale?: number): boolean; - /** - * @inheritDoc - */ - getPixel32(x: number, y: number): number[]; - /** - * @inheritDoc - */ - dispose(): void; - } -} -declare namespace egret { - /** - * Adds an interface-name-to-implementation-class mapping to the registry. - * @param interfaceName the interface name to register. For example:"eui.IAssetAdapter","eui.Theme" - * @param instance the instance to register. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 注册一个接口实现。 - * @param interfaceName 注入的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @param instance 实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function registerImplementation(interfaceName: string, instance: any): void; - /** - * Returns the singleton instance of the implementation class that was registered for the specified interface. - * This method is usually called by egret framework. - * @param interfaceName The interface name to identify. For example:"eui.IAssetAdapter","eui.Theme" - * @returns the singleton instance of the implementation class - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个接口实现。此方法通常由框架内部调用。获取项目注入的自定义实现实例。 - * @param interfaceName 要获取的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @returns 返回实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function getImplementation(interfaceName: string): any; -} -declare namespace egret { - /** - * This class is used to create lightweight shapes using the drawing application program interface (API). The Shape - * class includes a graphics property, which lets you access methods from the Graphics class. - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language en_US - */ - /** - * 此类用于使用绘图应用程序编程接口 (API) 创建简单形状。Shape 类含有 graphics 属性,通过该属性您可以访问各种矢量绘图方法。 - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language zh_CN - */ - class Shape extends DisplayObject { - /** - * Creates a new Shape object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Shape 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $graphics: Graphics; - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly graphics: Graphics; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * Bitmap font, texture set of a font. It is generally used as the value of the BitmapText.font attribute. - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 Text(Containing the specific usage of the bitmap font ) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language en_US - */ - /** - * 位图字体,是一个字体的纹理集,通常作为BitmapText.font属性的值。 - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 文本(含位图字体具体用法) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language zh_CN - */ - class BitmapFont extends SpriteSheet { - /** - * Create an egret.BitmapFont object - * @param texture {egret.Texture} Texture set that use TextureMerger create - * @param config {any} Configure data that use TextureMerger create - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapFont 对象 - * @param texture {egret.Texture} 使用TextureMerger生成的纹理集 - * @param config {any} 使用TextureMerger生成的配置数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(texture: Texture, config: any); - /** - * @private - */ - private charList; - /** - * Obtain corresponding texture through the name attribute - * @param name {string} name Attribute - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过 name 属性获取对应纹理 - * @param name {string} name属性 - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTexture(name: string): Texture; - /** - * @private - */ - getConfig(name: string, key: string): number; - /** - * @private - */ - private firstCharHeight; - /** - * @private - * - * @returns - */ - _getFirstCharHeight(): number; - /** - * @private - * - * @param fntText - * @returns - */ - private parseConfig(fntText); - /** - * @private - * - * @param configText - * @param key - * @returns - */ - private getConfigByKey(configText, key); - } -} -declare namespace egret { - /** - * Bitmap font adopts the Bitmap+SpriteSheet mode to render text. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language en_US - */ - /** - * 位图字体采用了Bitmap+SpriteSheet的方式来渲染文字。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language zh_CN - */ - class BitmapText extends DisplayObject { - /** - * Create an egret.BitmapText object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapText 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - private $smoothing; - /** - * Whether or not is smoothed when scaled. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - smoothing: boolean; - private $text; - /** - * A string to display in the text field. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要显示的文本内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * @private - */ - $setText(value: string): boolean; - protected $textFieldWidth: number; - /** - * @private - */ - $getWidth(): number; - /** - * @private - */ - $setWidth(value: number): boolean; - private $textLinesChanged; - /** - * @private - */ - $invalidateContentBounds(): void; - protected $textFieldHeight: number; - /** - * @private - */ - $getHeight(): number; - /** - * @private - */ - $setHeight(value: number): boolean; - protected $font: BitmapFont; - protected $fontStringChanged: boolean; - /** - * The name of the font to use, or a comma-separated list of font names, the type of value must be BitmapFont. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表,类型必须是 BitmapFont。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - font: Object; - $setFont(value: any): boolean; - private $lineSpacing; - /** - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineSpacing: number; - $setLineSpacing(value: number): boolean; - private $letterSpacing; - /** - * An integer representing the amount of distance between characters. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示字符之间的距离。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - letterSpacing: number; - $setLetterSpacing(value: number): boolean; - private $textAlign; - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - textAlign: string; - $setTextAlign(value: string): boolean; - private $verticalAlign; - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - verticalAlign: string; - $setVerticalAlign(value: string): boolean; - /** - * A ratio of the width of the space character. This value is multiplied by the height of the first character is the space character width. - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个空格字符的宽度比例。这个数值乘以第一个字符的高度即为空格字符的宽。 - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static EMPTY_FACTOR: number; - /** - * @private - */ - $updateRenderNode(): void; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - private $textWidth; - /** - * Get the BitmapText measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textWidth: number; - private $textHeight; - /** - * Get Text BitmapText height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textHeight: number; - /** - * @private - */ - private $textOffsetX; - /** - * @private - */ - private $textOffsetY; - /** - * @private - */ - private $textStartX; - /** - * @private - */ - private $textStartY; - /** - * @private - */ - private textLines; - /** - * @private 每一行文字的宽度 - */ - private $textLinesWidth; - /** - * @private - */ - $lineHeights: number[]; - /** - * @private - * - * @returns - */ - $getTextLines(): string[]; - } -} -declare namespace egret { - /** - * The HorizontalAlign class defines the possible values for the horizontal alignment. - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HorizontalAlign 类为水平对齐方式定义可能的值。 - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HorizontalAlign { - /** - * Horizontally align content to the left of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的左侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LEFT: string; - /** - * Horizontally align content to the right of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的右侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RIGHT: string; - /** - * Horizontally align content in the center of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的水平中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CENTER: string; - /** - * Horizontal alignment with both edges. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 水平两端对齐。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY: string; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Width \" of the container \". - * The Content Width \" of the container \" is the size of the max. child item. If the size of all child items are less than the width of the container, they will be adjusted to the width of the container. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容宽度"。 - * 容器的"内容宽度"是最大子项的大小,如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CONTENT_JUSTIFY: string; - } -} -declare namespace egret { - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language zh_CN - */ - class HtmlTextParser { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - private replaceArr; - private initReplaceArr(); - /** - * @private - * - * @param value - * @returns - */ - private replaceSpecial(value); - /** - * @private - */ - private resutlArr; - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @param htmltext {string} Text in html - * @returns {Array} 可赋值给 egret.TextField#textFlow Object that can be assigned to the egret.TextField#textFlow property - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @param htmltext {string} html文本 - * @returns {Array} 可赋值给 egret.TextField#textFlow 属性的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - parse(htmltext: string): egret.ITextElement[]; - parser(htmltext: string): Array; - /** - * @private - * - * @param value - */ - private addToResultArr(value); - private changeStringToObject(str); - /** - * @private - * - * @returns - */ - private getHeadReg(); - /** - * @private - * - * @param info - * @param head - * @param value - */ - private addProperty(info, head, value); - /** - * @private - */ - private stackArray; - /** - * @private - * - * @param infoStr - */ - private addToArray(infoStr); - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface IHitTextElement { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - lineIndex: number; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - textElementIndex: number; - } - /** - * Text Style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本样式 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface ITextStyle { - /** - * text color - * @version Egret 2.4 - * @platform Web,Native - * @see http://edn.egret.com/cn/docs/page/146 多种样式混合文本的基本结构 - * @language en_US - */ - /** - * 颜色值 - * @version Egret 2.4 - * @platform Web,Native - * @see http://edn.egret.com/cn/docs/page/146 多种样式混合文本的基本结构 - * @language zh_CN - */ - textColor?: number; - /** - * stroke color - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 描边颜色值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - strokeColor?: number; - /** - * size - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - size?: number; - /** - * stroke width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 描边大小 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stroke?: number; - /** - * whether bold - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否加粗 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bold?: boolean; - /** - * whether italic - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否倾斜 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - italic?: boolean; - /** - * fontFamily - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字体名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fontFamily?: string; - /** - * Link events or address - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 链接事件或者地址 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - href?: string; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - target?: string; - /** - * Is underlined - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否加下划线 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - underline?: boolean; - } - /** - * Used to build the basic structure of text with a variety of mixed styles, mainly for setting textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于建立多种样式混合文本的基本结构,主要用于设置 textFlow 属性 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface ITextElement { - /** - * String Content - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字符串内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * Text Style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本样式 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - style?: ITextStyle; - } - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface IWTextElement extends ITextElement { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - width: number; - } - /** - * 文本最终解析的一行数据格式 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface ILineElement { - /** - * 文本占用宽度 - * @version Egret 2.4 - * @platform Web,Native - */ - width: number; - /** - * 文本占用高度 - * @version Egret 2.4 - * @platform Web,Native - */ - height: number; - /** - * 当前文本字符总数量(包括换行符) - * @version Egret 2.4 - * @platform Web,Native - */ - charNum: number; - /** - * 是否含有换行符 - * @version Egret 2.4 - * @platform Web,Native - */ - hasNextLine: boolean; - /** - * 本行文本内容 - * @version Egret 2.4 - * @platform Web,Native - */ - elements: Array; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class InputController extends HashObject { - /** - * @private - */ - stageText: egret.StageText; - /** - * @private - */ - private stageTextAdded; - /** - * @private - */ - private _text; - /** - * @private - */ - private _isFocus; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - init(text: TextField): void; - /** - * @private - * - */ - _addStageText(): void; - /** - * @private - * - */ - _removeStageText(): void; - /** - * @private - * - * @returns - */ - _getText(): string; - /** - * @private - * - * @param value - */ - _setText(value: string): void; - /** - * @private - */ - _setColor(value: number): void; - /** - * @private - * - * @param event - */ - private focusHandler(event); - /** - * @private - * - * @param event - */ - private blurHandler(event); - private tempStage; - private onMouseDownHandler(event); - $onFocus(): void; - private onStageDownHandler(event); - /** - * @private - * - * @param event - */ - private updateTextHandler(event); - /** - * @private - * - */ - private resetText(); - /** - * @private - * - */ - _hideInput(): void; - /** - * @private - * - */ - private updateInput(); - /** - * @private - * - */ - _updateProperties(): void; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface StageText extends EventDispatcher { - /** - * @private - */ - $textfield: egret.TextField; - /** - * @private - * - * @param textfield - */ - $setTextField(textfield: egret.TextField): boolean; - /** - * @private - * - */ - $resetStageText(): void; - /** - * @private - * - * @returns - */ - $getText(): string; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * @private - * - * @param value - */ - $setColor(value: number): boolean; - /** - * @private - * - */ - $show(): void; - /** - * @private - * - */ - $hide(): void; - /** - * @private - * - */ - $addToStage(): void; - /** - * @private - * - */ - $removeFromStage(): void; - /** - * @private - * - */ - $onBlur(): void; - } - /** - * @version Egret 2.4 - * @platform Web,Native - */ - let StageText: { - new (): StageText; - }; -} -declare namespace egret.sys { - /** - * @private - */ - const enum TextKeys { - /** - * @private - */ - fontSize = 0, - /** - * @private - */ - lineSpacing = 1, - /** - * @private - */ - textColor = 2, - /** - * @private - */ - textFieldWidth = 3, - /** - * @private - */ - textFieldHeight = 4, - /** - * @private - */ - textWidth = 5, - /** - * @private - */ - textHeight = 6, - /** - * @private - */ - textDrawWidth = 7, - /** - * @private - */ - fontFamily = 8, - /** - * @private - */ - textAlign = 9, - /** - * @private - */ - verticalAlign = 10, - /** - * @private - */ - textColorString = 11, - /** - * @private - */ - fontString = 12, - /** - * @private - */ - text = 13, - /** - * @private - */ - measuredWidths = 14, - /** - * @private - */ - bold = 15, - /** - * @private - */ - italic = 16, - /** - * @private - */ - fontStringChanged = 17, - /** - * @private - */ - textLinesChanged = 18, - /** - * @private - */ - wordWrap = 19, - /** - * @private - */ - displayAsPassword = 20, - /** - * @private - */ - maxChars = 21, - /** - * @private - */ - selectionActivePosition = 22, - /** - * @private - */ - selectionAnchorPosition = 23, - /** - * @private - */ - type = 24, - /** - * @private - */ - strokeColor = 25, - /** - * @private - */ - strokeColorString = 26, - /** - * @private - */ - stroke = 27, - /** - * @private - */ - scrollV = 28, - /** - * @private - */ - numLines = 29, - /** - * @private - */ - multiline = 30, - /** - * @private - */ - border = 31, - /** - * @private - */ - borderColor = 32, - /** - * @private - */ - background = 33, - /** - * @private - */ - backgroundColor = 34, - /** - * @private - */ - restrictAnd = 35, - /** - * @private - */ - restrictNot = 36, - /** - * @private - */ - inputType = 37, - /** - * @private - */ - textLinesChangedForNativeRender = 38, - } -} -declare namespace egret { - /** - * TextField is the text rendering class of egret. It conducts rendering by using the browser / device API. Due to different ways of font rendering in different browsers / devices, there may be differences in the rendering - * If developers expect no differences among all platforms, please use BitmapText - * @see http://edn.egret.com/cn/docs/page/141 Create Text - * - * @event egret.Event.CHANGE Dispatched when entering text user input。 - * @event egret.FocusEvent.FOCUS_IN Dispatched after the focus to enter text. - * @event egret.FocusEvent.FOCUS_OUT Enter the text loses focus after dispatch. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language en_US - */ - /** - * TextField是egret的文本渲染类,采用浏览器/设备的API进行渲染,在不同的浏览器/设备中由于字体渲染方式不一,可能会有渲染差异 - * 如果开发者希望所有平台完全无差异,请使用BitmapText - * @see http://edn.egret.com/cn/docs/page/141 创建文本 - * - * @event egret.Event.CHANGE 输入文本有用户输入时调度。 - * @event egret.FocusEvent.FOCUS_IN 聚焦输入文本后调度。 - * @event egret.FocusEvent.FOCUS_OUT 输入文本失去焦点后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language zh_CN - */ - class TextField extends DisplayObject { - /** - * default fontFamily - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字体 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static default_fontFamily: string; - /** - * default size in pixels of text - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字号大小 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - static default_size: number; - /** - * default color of the text. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本颜色 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - static default_textColor: number; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $TextField: Object; - /** - * @private - */ - private isInput(); - $inputEnabled: boolean; - $setTouchEnabled(value: boolean): void; - /** - * The name of the font to use, or a comma-separated list of font names. - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表。 - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fontFamily: string; - $setFontFamily(value: string): boolean; - /** - * The size in pixels of text - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的字号大小。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - size: number; - $setSize(value: number): boolean; - /** - * Specifies whether the text is boldface. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为粗体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bold: boolean; - $setBold(value: boolean): boolean; - /** - * Determines whether the text is italic font. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为斜体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - italic: boolean; - $setItalic(value: boolean): boolean; - /** - * @private - * - */ - private invalidateFontString(); - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - textAlign: string; - $setTextAlign(value: string): boolean; - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - verticalAlign: string; - $setVerticalAlign(value: string): boolean; - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineSpacing: number; - $setLineSpacing(value: number): boolean; - /** - * Color of the text. - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本颜色 - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - textColor: number; - $setTextColor(value: number): boolean; - /** - * A Boolean value that indicates whether the text field word wrap. If the value is true, then the text field by word wrap; - * if the value is false, the text field by newline characters. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个布尔值,表示文本字段是否按单词换行。如果值为 true,则该文本字段按单词换行; - * 如果值为 false,则该文本字段按字符换行。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - wordWrap: boolean; - $setWordWrap(value: boolean): void; - protected inputUtils: InputController; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Type of the text field. - * Any one of the following TextFieldType constants: TextFieldType.DYNAMIC (specifies the dynamic text field that users can not edit), or TextFieldType.INPUT (specifies the dynamic text field that users can edit). - * @default egret.TextFieldType.DYNAMIC - * @language en_US - */ - /** - * 文本字段的类型。 - * 以下 TextFieldType 常量中的任一个:TextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 TextFieldType.INPUT(指定用户可以编辑的输入文本字段)。 - * @default egret.TextFieldType.DYNAMIC - * @language zh_CN - */ - type: string; - /** - * @private - * - * @param value - */ - $setType(value: string): boolean; - /** - * @version Egret 3.1.2 - * @platform Web,Native - */ - /** - * Pop-up keyboard type. - * Any of a TextFieldInputType constants. - * @language en_US - */ - /** - * 弹出键盘的类型。 - * TextFieldInputType 常量中的任一个。 - * @language zh_CN - */ - inputType: string; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Serve as a string of the current text field in the text - * @language en_US - */ - /** - * 作为文本字段中当前文本的字符串 - * @language zh_CN - */ - text: string; - /** - * @private - * - * @returns - */ - $getText(): string; - /** - * @private - * - * @param value - */ - $setBaseText(value: string): boolean; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * Specify whether the text field is a password text field. - * If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否是密码文本字段。 - * 如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。 - * @default false - * @language zh_CN - */ - displayAsPassword: boolean; - /** - * @private - * - * @param value - */ - $setDisplayAsPassword(value: boolean): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Represent the stroke color of the text. - * Contain three 8-bit numbers with RGB color components; for example, 0xFF0000 is red, 0x00FF00 is green. - * @default 0x000000 - * @language en_US - */ - /** - * 表示文本的描边颜色。 - * 包含三个 8 位 RGB 颜色成分的数字;例如,0xFF0000 为红色,0x00FF00 为绿色。 - * @default 0x000000 - * @language zh_CN - */ - strokeColor: number; - /** - * @private - * - * @param value - */ - $setStrokeColor(value: number): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Indicate the stroke width. - * 0 means no stroke. - * @default 0 - * @language en_US - */ - /** - * 表示描边宽度。 - * 0为没有描边。 - * @default 0 - * @language zh_CN - */ - stroke: number; - /** - * @private - * - * @param value - */ - $setStroke(value: number): boolean; - /** - * The maximum number of characters that the text field can contain, as entered by a user. \n A script can insert more text than maxChars allows; the maxChars property indicates only how much text a user can enter. If the value of this property is 0, a user can enter an unlimited amount of text. - * The default value is 0. - * @default 0 - * @language en_US - */ - /** - * 文本字段中最多可包含的字符数(即用户输入的字符数)。 - * 脚本可以插入比 maxChars 允许的字符数更多的文本;maxChars 属性仅表示用户可以输入多少文本。如果此属性的值为 0,则用户可以输入无限数量的文本。 - * @default 0 - * @language zh_CN - */ - maxChars: number; - /** - * @private - * - * @param value - */ - $setMaxChars(value: number): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Vertical position of text in a text field. scrollV property helps users locate specific passages in a long article, and create scrolling text fields. - * Vertically scrolling units are lines, and horizontal scrolling unit is pixels. - * If the first displayed line is the first line in the text field, scrollV is set to 1 (instead of 0). - * @language en_US - */ - /** - * 文本在文本字段中的垂直位置。scrollV 属性可帮助用户定位到长篇文章的特定段落,还可用于创建滚动文本字段。 - * 垂直滚动的单位是行,而水平滚动的单位是像素。 - * 如果显示的第一行是文本字段中的第一行,则 scrollV 设置为 1(而非 0)。 - * @language zh_CN - */ - scrollV: number; - /** - * The maximum value of scrollV - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * scrollV 的最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly maxScrollV: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly selectionBeginIndex: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly selectionEndIndex: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly caretIndex: number; - /** - * @private - * - * @param beginIndex - * @param endIndex - */ - $setSelection(beginIndex: number, endIndex: number): boolean; - /** - * @private - * - * @returns - */ - $getLineHeight(): number; - /** - * Number of lines of text. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本行数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly numLines: number; - /** - * Indicate whether field is a multiline text field. Note that this property is valid only when the type is TextFieldType.INPUT. - * If the value is true, the text field is multiline; if the value is false, the text field is a single-line text field. In a field of type TextFieldType.INPUT, the multiline value determines whether the Enter key creates a new line (a value of false, and the Enter key is ignored). - * @default false - * @language en_US - */ - /** - * 表示字段是否为多行文本字段。注意,此属性仅在type为TextFieldType.INPUT时才有效。 - * 如果值为 true,则文本字段为多行文本字段;如果值为 false,则文本字段为单行文本字段。在类型为 TextFieldType.INPUT 的字段中,multiline 值将确定 Enter 键是否创建新行(如果值为 false,则将忽略 Enter 键)。 - * @default false - * @language zh_CN - */ - multiline: boolean; - /** - * @private - * - * @param value - */ - $setMultiline(value: boolean): boolean; - /** - * Indicates a user can enter into the text field character set. If you restrict property is null, you can enter any character. If you restrict property is an empty string, you can not enter any character. If you restrict property is a string of characters, you can enter only characters in the string in the text field. The string is scanned from left to right. You can use a hyphen (-) to specify a range. Only restricts user interaction; a script may put any text into the text field.
- * If the string of characters caret (^) at the beginning, all characters are initially accepted, then the string are excluded from receiving ^ character. If the string does not begin with a caret (^) to, any characters are initially accepted and then a string of characters included in the set of accepted characters.
- * The following example allows only uppercase characters, spaces, and numbers in the text field:
- * My_txt.restrict = "A-Z 0-9";
- * The following example includes all characters except lowercase letters:
- * My_txt.restrict = "^ a-z";
- * If you need to enter characters \ ^, use two backslash "\\ -" "\\ ^":
- * Can be used anywhere in the string ^ to rule out including characters and switch between characters, but can only be used to exclude a ^. The following code includes only uppercase letters except uppercase Q:
- * My_txt.restrict = "A-Z ^ Q";
- * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language en_US - */ - /** - * 表示用户可输入到文本字段中的字符集。如果 restrict 属性的值为 null,则可以输入任何字符。如果 restrict 属性的值为空字符串,则不能输入任何字符。如果 restrict 属性的值为一串字符,则只能在文本字段中输入该字符串中的字符。从左向右扫描该字符串。可以使用连字符 (-) 指定一个范围。只限制用户交互;脚本可将任何文本放入文本字段中。
- * 如果字符串以尖号 (^) 开头,则先接受所有字符,然后从接受字符集中排除字符串中 ^ 之后的字符。如果字符串不以尖号 (^) 开头,则最初不接受任何字符,然后将字符串中的字符包括在接受字符集中。
- * 下例仅允许在文本字段中输入大写字符、空格和数字:
- * my_txt.restrict = "A-Z 0-9";
- * 下例包含除小写字母之外的所有字符:
- * my_txt.restrict = "^a-z";
- * 如果需要输入字符 \ ^,请使用2个反斜杠 "\\-" "\\^" :
- * 可在字符串中的任何位置使用 ^,以在包含字符与排除字符之间进行切换,但是最多只能有一个 ^ 用来排除。下面的代码只包含除大写字母 Q 之外的大写字母:
- * my_txt.restrict = "A-Z^Q";
- * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language zh_CN - */ - restrict: string; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - /** - * @private - * 获取显示宽度 - */ - $getHeight(): number; - /** - * @private - */ - private textNode; - /** - * @private - */ - $graphicsNode: sys.GraphicsNode; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Specifies whether the text field has a border. - * If true, the text field has a border. If false, the text field has no border. - * Use borderColor property to set the border color. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有边框。 - * 如果为 true,则文本字段具有边框。如果为 false,则文本字段没有边框。 - * 使用 borderColor 属性来设置边框颜色。 - * @default false - * @language zh_CN - */ - border: boolean; - /** - * @private - */ - $setBorder(value: boolean): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * The color of the text field border. - * Even currently is no border can be retrieved or set this property, but only if the text field has the border property is set to true, the color is visible. - * @default 0x000000 - * @language en_US - */ - /** - * 文本字段边框的颜色。 - * 即使当前没有边框,也可检索或设置此属性,但只有当文本字段已将 border 属性设置为 true 时,才可以看到颜色。 - * @default 0x000000 - * @language zh_CN - */ - borderColor: number; - /** - * @private - */ - $setBorderColor(value: number): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Specifies whether the text field has a background fill. - * If true, the text field has a background fill. If false, the text field has no background fill. - * Use the backgroundColor property to set the background color of the text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有背景填充。 - * 如果为 true,则文本字段具有背景填充。如果为 false,则文本字段没有背景填充。 - * 使用 backgroundColor 属性来设置文本字段的背景颜色。 - * @default false - * @language zh_CN - */ - background: boolean; - /** - * @private - */ - $setBackground(value: boolean): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Color of the text field background. - * Even currently is no background, can be retrieved or set this property, but only if the text field has the background property set to true, the color is visible. - * @default 0xFFFFFF - * @language en_US - */ - /** - * 文本字段背景的颜色。 - * 即使当前没有背景,也可检索或设置此属性,但只有当文本字段已将 background 属性设置为 true 时,才可以看到颜色。 - * @default 0xFFFFFF - * @language zh_CN - */ - backgroundColor: number; - /** - * @private - */ - $setBackgroundColor(value: number): void; - /** - * @private - * - */ - private fillBackground(lines?); - /** - * Enter the text automatically entered into the input state, the input type is text only and may only be invoked in the user interaction. - * @version Egret 3.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 输入文本自动进入到输入状态,仅在类型是输入文本并且是在用户交互下才可以调用。 - * @version Egret 3.0.8 - * @platform Web,Native - * @language zh_CN - */ - setFocus(): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - * - * @param stage - * @param nestLevel - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - $invalidateTextField(): void; - $getRenderBounds(): Rectangle; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - $updateRenderNode(): void; - /** - * @private - */ - private isFlow; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Set rich text - * @language en_US - */ - /** - * 设置富文本 - * @see http://edn.egret.com/cn/index.php/article/index/id/146 - * @language zh_CN - */ - textFlow: Array; - /** - * @private - * - * @param text - * @returns - */ - private changeToPassText(text); - /** - * @private - */ - private textArr; - /** - * @private - * - * @param textArr - */ - private setMiddleStyle(textArr); - /** - * Get the text measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textWidth: number; - /** - * Get Text measuring height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textHeight: number; - /** - * @private - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - appendText(text: string): void; - /** - * @private - * @param element - * @version Egret 2.4 - * @platform Web,Native - */ - appendElement(element: egret.ITextElement): void; - /** - * @private - */ - private linesArr; - $getLinesArr(): Array; - /** - * @private - * - * @returns - */ - $getLinesArr2(): Array; - /** - * @private - */ - $isTyping: boolean; - /** - * @private - */ - $setIsTyping(value: boolean): void; - /** - * @private - * 返回要绘制的下划线列表 - */ - private drawText(); - private addEvent(); - private removeEvent(); - private onTapHandler(e); - } - interface TextField { - addEventListener(type: "link", listener: (this: Z, e: TextEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: "focusIn" | "focusOut", listener: (this: Z, e: FocusEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } -} -declare namespace egret { - /** - * TextFieldInputType class is an enumeration of constant value used in setting the inputType property of the TextField class. - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldInputType 类是在设置 TextField 类的 inputType 属性时使用的常数值的枚举。 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - class TextFieldInputType { - /** - * The default - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 默认 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static TEXT: string; - /** - * Telephone Number Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 电话号码 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static TEL: string; - /** - * Password Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * password 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static PASSWORD: string; - } -} -declare namespace egret { - /** - * TextFieldType class is an enumeration of constant value used in setting the type property of the TextField class. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldType 类是在设置 TextField 类的 type 属性时使用的常数值的枚举。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class TextFieldType { - /** - * Used to specify dynamic text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定动态文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static DYNAMIC: string; - /** - * Used to specify the input text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定输入文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static INPUT: string; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class TextFieldUtils { - /** - * 获取第一个绘制的行数 - * @param textfield 文本 - * @returns {number} 行数,从0开始 - * @private - */ - static $getStartLine(textfield: egret.TextField): number; - /** - * 获取水平比例 - * @param textfield 文本 - * @returns {number} 水平比例 - * @private - */ - static $getHalign(textfield: egret.TextField): number; - /** - * @private - * - * @param textfield - * @returns - */ - static $getTextHeight(textfield: egret.TextField): number; - /** - * 获取垂直比例 - * @param textfield 文本 - * @returns {number} 垂直比例 - * @private - */ - static $getValign(textfield: egret.TextField): number; - /** - * 根据x、y获取文本项 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本单项 - * @private - */ - static $getTextElement(textfield: egret.TextField, x: number, y: number): ITextElement; - /** - * 获取文本点击块 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本点击块 - * @private - */ - static $getHit(textfield: egret.TextField, x: number, y: number): IHitTextElement; - /** - * 获取当前显示多少行 - * @param textfield 文本 - * @returns {number} 显示的行数 - * @private - */ - static $getScrollNum(textfield: egret.TextField): number; - } -} -/** - * @private - */ -declare namespace egret.sys { - /** - * 测量文本在指定样式下的宽度。 - * @param text 要测量的文本内容。 - * @param fontFamily 字体名称 - * @param fontSize 字体大小 - * @param bold 是否粗体 - * @param italic 是否斜体 - */ - let measureText: (text: string, fontFamily: string, fontSize: number, bold: boolean, italic: boolean) => number; -} -declare namespace egret { - /** - * The VerticalAlign class defines the possible values for the vertical alignment. - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * VerticalAlign 类为垂直对齐方式定义可能的值。 - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class VerticalAlign { - /** - * Vertically align content to the top of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的顶部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOP: string; - /** - * Vertically align content to the bottom of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的底部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static BOTTOM: string; - /** - * Vertically align content in the middle of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的垂直中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static MIDDLE: string; - /** - * Vertical alignment with both edges - * Note: TextFiled does not support this alignment method." - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直两端对齐 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY: string; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Height \" of the container \". - * The Content Height \" of the container \" is the size of the max. child item. If the size of all child items are less than the height of the container, they will be adjusted to the height of the container. - * Note: TextFiled does not support this alignment method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容高度"。 - * 容器的"内容高度"是最大子项的大小,如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CONTENT_JUSTIFY: string; - } -} -declare namespace egret { - /** - * @language en_US - * The Base64Util class provides methods for encoding and decoding base64. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - /** - * @language zh_CN - * Base64Util 类提供用于编解码base64的方法。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - class Base64Util { - /** - * @language en_US - * encode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 编码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - static encode(arraybuffer: ArrayBuffer): string; - /** - * @language en_US - * decode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 解码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - static decode(base64: string): ArrayBuffer; - } -} -/** - * @private - */ -declare let chars: string; -/** - * @private - */ -declare let lookup: Uint8Array; -declare namespace egret { - /** - * The Endian class contains values that denote the byte order used to represent multibyte numbers. - * The byte order is either bigEndian (most significant byte first) or littleEndian (least significant byte first). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Endian 类中包含一些值,它们表示用于表示多字节数字的字节顺序。 - * 字节顺序为 bigEndian(最高有效字节位于最前)或 littleEndian(最低有效字节位于最前)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Endian { - /** - * Indicates the least significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最低有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LITTLE_ENDIAN: string; - /** - * Indicates the most significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最高有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static BIG_ENDIAN: string; - } - const enum EndianConst { - LITTLE_ENDIAN = 0, - BIG_ENDIAN = 1, - } - /** - * The ByteArray class provides methods and attributes for optimized reading and writing as well as dealing with binary data. - * Note: The ByteArray class is applied to the advanced developers who need to access data at the byte layer. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language en_US - */ - /** - * ByteArray 类提供用于优化读取、写入以及处理二进制数据的方法和属性。 - * 注意:ByteArray 类适用于需要在字节层访问数据的高级开发人员。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language zh_CN - */ - class ByteArray { - /** - * @private - */ - protected bufferExtSize: number; - protected data: DataView; - protected _bytes: Uint8Array; - /** - * @private - */ - protected _position: number; - /** - * - * 已经使用的字节偏移量 - * @protected - * @type {number} - * @memberOf ByteArray - */ - protected write_position: number; - /** - * Changes or reads the byte order; egret.EndianConst.BIG_ENDIAN or egret.EndianConst.LITTLE_EndianConst. - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改或读取数据的字节顺序;egret.EndianConst.BIG_ENDIAN 或 egret.EndianConst.LITTLE_ENDIAN。 - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - endian: string; - protected $endian: EndianConst; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(buffer?: ArrayBuffer | Uint8Array, bufferExtSize?: number); - /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native - */ - setArrayBuffer(buffer: ArrayBuffer): void; - /** - * 可读的剩余字节数 - * - * @returns - * - * @memberOf ByteArray - */ - readonly readAvailable: number; - /** - * @private - */ - buffer: ArrayBuffer; - readonly rawBuffer: ArrayBuffer; - readonly bytes: Uint8Array; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @private - */ - dataView: DataView; - /** - * @private - */ - readonly bufferOffset: number; - /** - * The current position of the file pointer (in bytes) to move or return to the ByteArray object. The next time you start reading reading method call in this position, or will start writing in this position next time call a write method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将文件指针的当前位置(以字节为单位)移动或返回到 ByteArray 对象中。下一次调用读取方法时将在此位置开始读取,或者下一次调用写入方法时将在此位置开始写入。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - position: number; - /** - * The length of the ByteArray object (in bytes). - * If the length is set to be larger than the current length, the right-side zero padding byte array. - * If the length is set smaller than the current length, the byte array is truncated. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * ByteArray 对象的长度(以字节为单位)。 - * 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧。 - * 如果将长度设置为小于当前长度的值,将会截断该字节数组。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - length: number; - protected _validateBuffer(value: number): void; - /** - * The number of bytes that can be read from the current position of the byte array to the end of the array data. - * When you access a ByteArray object, the bytesAvailable property in conjunction with the read methods each use to make sure you are reading valid data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 可从字节数组的当前位置到数组末尾读取的数据的字节数。 - * 每次访问 ByteArray 对象时,将 bytesAvailable 属性与读取方法结合使用,以确保读取有效的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly bytesAvailable: number; - /** - * Clears the contents of the byte array and resets the length and position properties to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除字节数组的内容,并将 length 和 position 属性重置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clear(): void; - /** - * Read a Boolean value from the byte stream. Read a simple byte. If the byte is non-zero, it returns true; otherwise, it returns false. - * @return If the byte is non-zero, it returns true; otherwise, it returns false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取布尔值。读取单个字节,如果字节非零,则返回 true,否则返回 false - * @return 如果字节不为零,则返回 true,否则返回 false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readBoolean(): boolean; - /** - * Read signed bytes from the byte stream. - * @return An integer ranging from -128 to 127 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取带符号的字节 - * @return 介于 -128 和 127 之间的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readByte(): number; - /** - * Read data byte number specified by the length parameter from the byte stream. Starting from the position specified by offset, read bytes into the ByteArray object specified by the bytes parameter, and write bytes into the target ByteArray - * @param bytes ByteArray object that data is read into - * @param offset Offset (position) in bytes. Read data should be written from this position - * @param length Byte number to be read Default value 0 indicates reading all available data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取 length 参数指定的数据字节数。从 offset 指定的位置开始,将字节读入 bytes 参数指定的 ByteArray 对象中,并将字节写入目标 ByteArray 中 - * @param bytes 要将数据读入的 ByteArray 对象 - * @param offset bytes 中的偏移(位置),应从该位置写入读取的数据 - * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readBytes(bytes: ByteArray, offset?: number, length?: number): void; - /** - * Read an IEEE 754 double-precision (64 bit) floating point number from the byte stream - * @return Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 双精度(64 位)浮点数 - * @return 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readDouble(): number; - /** - * Read an IEEE 754 single-precision (32 bit) floating point number from the byte stream - * @return Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 单精度(32 位)浮点数 - * @return 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readFloat(): number; - /** - * Read a 32-bit signed integer from the byte stream. - * @return A 32-bit signed integer ranging from -2147483648 to 2147483647 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 32 位整数 - * @return 介于 -2147483648 和 2147483647 之间的 32 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readInt(): number; - /** - * Read a 16-bit signed integer from the byte stream. - * @return A 16-bit signed integer ranging from -32768 to 32767 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 16 位整数 - * @return 介于 -32768 和 32767 之间的 16 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readShort(): number; - /** - * Read unsigned bytes from the byte stream. - * @return A unsigned integer ranging from 0 to 255 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取无符号的字节 - * @return 介于 0 和 255 之间的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedByte(): number; - /** - * Read a 32-bit unsigned integer from the byte stream. - * @return A 32-bit unsigned integer ranging from 0 to 4294967295 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 32 位整数 - * @return 介于 0 和 4294967295 之间的 32 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedInt(): number; - /** - * Read a 16-bit unsigned integer from the byte stream. - * @return A 16-bit unsigned integer ranging from 0 to 65535 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 16 位整数 - * @return 介于 0 和 65535 之间的 16 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedShort(): number; - /** - * Read a UTF-8 character string from the byte stream Assume that the prefix of the character string is a short unsigned integer (use byte to express length) - * @return UTF-8 character string - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 UTF-8 字符串。假定字符串的前缀是无符号的短整型(以字节表示长度) - * @return UTF-8 编码的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUTF(): string; - /** - * Read a UTF-8 byte sequence specified by the length parameter from the byte stream, and then return a character string - * @param Specify a short unsigned integer of the UTF-8 byte length - * @return A character string consists of UTF-8 bytes of the specified length - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个由 length 参数指定的 UTF-8 字节序列,并返回一个字符串 - * @param length 指明 UTF-8 字节长度的无符号短整型数 - * @return 由指定长度的 UTF-8 字节组成的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUTFBytes(length: number): string; - /** - * Write a Boolean value. A single byte is written according to the value parameter. If the value is true, write 1; if the value is false, write 0. - * @param value A Boolean value determining which byte is written. If the value is true, write 1; if the value is false, write 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 写入布尔值。根据 value 参数写入单个字节。如果为 true,则写入 1,如果为 false,则写入 0 - * @param value 确定写入哪个字节的布尔值。如果该参数为 true,则该方法写入 1;如果该参数为 false,则该方法写入 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeBoolean(value: boolean): void; - /** - * Write a byte into the byte stream - * The low 8 bits of the parameter are used. The high 24 bits are ignored. - * @param value A 32-bit integer. The low 8 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个字节 - * 使用参数的低 8 位。忽略高 24 位 - * @param value 一个 32 位整数。低 8 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeByte(value: number): void; - /** - * Write the byte sequence that includes length bytes in the specified byte array, bytes, (starting at the byte specified by offset, using a zero-based index), into the byte stream - * If the length parameter is omitted, the default length value 0 is used and the entire buffer starting at offset is written. If the offset parameter is also omitted, the entire buffer is written - * If the offset or length parameter is out of range, they are clamped to the beginning and end of the bytes array. - * @param bytes ByteArray Object - * @param offset A zero-based index specifying the position into the array to begin writing - * @param length An unsigned integer specifying how far into the buffer to write - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定字节数组 bytes(起始偏移量为 offset,从零开始的索引)中包含 length 个字节的字节序列写入字节流 - * 如果省略 length 参数,则使用默认长度 0;该方法将从 offset 开始写入整个缓冲区。如果还省略了 offset 参数,则写入整个缓冲区 - * 如果 offset 或 length 超出范围,它们将被锁定到 bytes 数组的开头和结尾 - * @param bytes ByteArray 对象 - * @param offset 从 0 开始的索引,表示在数组中开始写入的位置 - * @param length 一个无符号整数,表示在缓冲区中的写入范围 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeBytes(bytes: ByteArray, offset?: number, length?: number): void; - /** - * Write an IEEE 754 double-precision (64 bit) floating point number into the byte stream - * @param value Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 双精度(64 位)浮点数 - * @param value 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeDouble(value: number): void; - /** - * Write an IEEE 754 single-precision (32 bit) floating point number into the byte stream - * @param value Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 单精度(32 位)浮点数 - * @param value 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeFloat(value: number): void; - /** - * Write a 32-bit signed integer into the byte stream - * @param value An integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个带符号的 32 位整数 - * @param value 要写入字节流的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeInt(value: number): void; - /** - * Write a 16-bit integer into the byte stream. The low 16 bits of the parameter are used. The high 16 bits are ignored. - * @param value A 32-bit integer. Its low 16 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 16 位整数。使用参数的低 16 位。忽略高 16 位 - * @param value 32 位整数,该整数的低 16 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeShort(value: number): void; - /** - * Write a 32-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 32 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUnsignedInt(value: number): void; - /** - * Write a 16-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 16 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - writeUnsignedShort(value: number): void; - /** - * Write a UTF-8 string into the byte stream. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。先写入以字节表示的 UTF-8 字符串长度(作为 16 位整数),然后写入表示字符串字符的字节 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUTF(value: string): void; - /** - * Write a UTF-8 string into the byte stream. Similar to the writeUTF() method, but the writeUTFBytes() method does not prefix the string with a 16-bit length word - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。类似于 writeUTF() 方法,但 writeUTFBytes() 不使用 16 位长度的词为字符串添加前缀 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUTFBytes(value: string): void; - /** - * - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - toString(): string; - /** - * @private - * 将 Uint8Array 写入字节流 - * @param bytes 要写入的Uint8Array - * @param validateBuffer - */ - _writeUint8Array(bytes: Uint8Array | ArrayLike, validateBuffer?: boolean): void; - /** - * @param len - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - validate(len: number): boolean; - /**********************/ - /**********************/ - /** - * @private - * @param len - * @param needReplace - */ - protected validateBuffer(len: number): void; - /** - * @private - * UTF-8 Encoding/Decoding - */ - private encodeUTF8(str); - /** - * @private - * - * @param data - * @returns - */ - private decodeUTF8(data); - /** - * @private - * - * @param code_point - */ - private encoderError(code_point); - /** - * @private - * - * @param fatal - * @param opt_code_point - * @returns - */ - private decoderError(fatal, opt_code_point?); - /** - * @private - */ - private EOF_byte; - /** - * @private - */ - private EOF_code_point; - /** - * @private - * - * @param a - * @param min - * @param max - */ - private inRange(a, min, max); - /** - * @private - * - * @param n - * @param d - */ - private div(n, d); - /** - * @private - * - * @param string - */ - private stringToCodePoints(string); - } -} -declare namespace egret { - /** - * The Sprite class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language en_US - */ - /** - * Sprite 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language zh_CN - */ - class Sprite extends DisplayObjectContainer { - /** - * Creates a new Sprite instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $graphics: Graphics; - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly graphics: Graphics; - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * Registers the runtime class information for a class.This method adds some strings which represent the class name or - * some interface names to the class definition. After the registration,you can use egret.is() method to do the type checking - * for the instance of this class.
- * Note:If you use the TypeScript programming language, the egret command line tool will automatically generate the registration code line. - * You don't need to manually call this method. - * - * @example the following code shows how to register the runtime class information for the EventDispatcher class and do the type checking: - *
-     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
-     *      let dispatcher = new egret.EventDispatcher();
-     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
-     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
-     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
-     * 
- * @param classDefinition the class definition to be registered. - * @param className a unique identification string of the specific class - * @param interfaceNames a list of unique identification string of the specific interfaces. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为一个类定义注册运行时类信息,用此方法往类定义上注册它自身以及所有接口对应的字符串。 - * 在运行时,这个类的实例将可以使用 egret.is() 方法传入一个字符串来判断实例类型。 - * @example 以下代码演示了如何为EventDispatcher类注册运行时类信息并判断类型: - *
-     *      //为egret.EventDispatcher类注册运行时类信息,由于它实现了IEventDispatcher接口,这里应同时传入接口名对应的字符串。
-     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
-     *      let dispatcher = new egret.EventDispatcher();
-     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
-     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
-     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
-     * 
- * 注意:若您使用 TypeScript 来编写程序,egret 命令行会自动帮您生成类信息注册代码行到最终的 Javascript 文件中。因此您不需要手动调用此方法。 - * - * @param classDefinition 要注册的类定义。 - * @param className 要注册的类名。 - * @param interfaceNames 要注册的类所实现的接口名列表。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function registerClass(classDefinition: any, className: string, interfaceNames?: string[]): void; -} -declare namespace egret { - /** - * The BitmapFillMode class defines the image fill mode of Bitmap. - * The BitmapFillMode class defines a pattern enumeration for adjusting size. These patterns determine how Bitmap fill the size designated by the layout system. - * @see http://edn.egret.com/cn/docs/page/134 Texture filling way - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language en_US - */ - /** - * BitmapFillMode 类定义Bitmap的图像填充方式。 - * BitmapFillMode 类定义了调整大小模式的一个枚举,这些模式确定 Bitmap 如何填充由布局系统指定的尺寸。 - * @see http://edn.egret.com/cn/docs/page/134 纹理的填充方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language zh_CN - */ - const BitmapFillMode: { - REPEAT: string; - SCALE: string; - CLIP: string; - }; -} -declare namespace egret { - /** - * Logger is an entrance for the log processing namespace of the engine - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Logger是引擎的日志处理模块入口 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Logger { - /** - * open all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全开 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ALL: string; - /** - * level: DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static DEBUG: string; - /** - * level: INFO - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 INFO - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static INFO: string; - /** - * level: WARN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 WARN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static WARN: string; - /** - * level: ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ERROR: string; - /** - * close all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全关 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static OFF: string; - /** - * Set the current need to open the log level. Grade level are: ALL - * This feature is only in DEBUG mode to take effect.
- *