@vpmedia/phaser 1.15.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/package.json +6 -5
- package/src/index.js +15 -18
- package/src/phaser/core/animation.js +114 -6
- package/src/phaser/core/animation_manager.js +102 -10
- package/src/phaser/core/animation_parser.js +6 -19
- package/src/phaser/core/array_set.js +59 -5
- package/src/phaser/core/cache.js +307 -6
- package/src/phaser/core/const.js +107 -4
- package/src/phaser/core/device.js +3 -6
- package/src/phaser/core/device_util.js +3 -16
- package/src/phaser/core/dom.js +127 -29
- package/src/phaser/core/event_manager.js +128 -6
- package/src/phaser/core/factory.js +69 -34
- package/src/phaser/core/frame.js +43 -6
- package/src/phaser/core/frame_data.js +55 -5
- package/src/phaser/core/frame_util.js +7 -12
- package/src/phaser/core/game.js +35 -7
- package/src/phaser/core/input.js +133 -17
- package/src/phaser/core/input_handler.js +243 -43
- package/src/phaser/core/input_mouse.js +70 -5
- package/src/phaser/core/input_mspointer.js +40 -9
- package/src/phaser/core/input_pointer.js +88 -17
- package/src/phaser/core/input_touch.js +42 -5
- package/src/phaser/core/loader.js +303 -101
- package/src/phaser/core/loader_parser.js +2 -10
- package/src/phaser/core/raf.js +16 -5
- package/src/phaser/core/scale_manager.js +204 -39
- package/src/phaser/core/scene.js +24 -5
- package/src/phaser/core/scene_manager.js +81 -11
- package/src/phaser/core/signal.js +88 -11
- package/src/phaser/core/signal_binding.js +35 -15
- package/src/phaser/core/sound.js +99 -10
- package/src/phaser/core/sound_manager.js +89 -13
- package/src/phaser/core/sound_sprite.js +20 -5
- package/src/phaser/core/stage.js +43 -7
- package/src/phaser/core/time.js +67 -5
- package/src/phaser/core/timer.js +107 -30
- package/src/phaser/core/timer_event.js +11 -6
- package/src/phaser/core/tween.js +124 -30
- package/src/phaser/core/tween_data.js +42 -18
- package/src/phaser/core/tween_easing.js +1 -8
- package/src/phaser/core/tween_manager.js +47 -5
- package/src/phaser/core/world.js +9 -6
- package/src/phaser/display/bitmap_text.js +91 -10
- package/src/phaser/display/button.js +63 -12
- package/src/phaser/display/canvas/buffer.js +16 -6
- package/src/phaser/display/canvas/graphics.js +1 -13
- package/src/phaser/display/canvas/masker.js +0 -6
- package/src/phaser/display/canvas/pool.js +0 -7
- package/src/phaser/display/canvas/renderer.js +28 -8
- package/src/phaser/display/canvas/tinter.js +4 -43
- package/src/phaser/display/canvas/util.js +0 -6
- package/src/phaser/display/display_object.js +192 -20
- package/src/phaser/display/graphics.js +161 -26
- package/src/phaser/display/graphics_data.js +14 -6
- package/src/phaser/display/graphics_data_util.js +2 -8
- package/src/phaser/display/group.js +82 -9
- package/src/phaser/display/image.js +87 -9
- package/src/phaser/display/sprite_batch.js +3 -8
- package/src/phaser/display/sprite_util.js +3 -23
- package/src/phaser/display/text.js +331 -31
- package/src/phaser/display/webgl/abstract_filter.js +8 -7
- package/src/phaser/display/webgl/base_texture.js +20 -12
- package/src/phaser/display/webgl/blend_manager.js +14 -7
- package/src/phaser/display/webgl/earcut.js +4 -23
- package/src/phaser/display/webgl/earcut_node.js +6 -7
- package/src/phaser/display/webgl/fast_sprite_batch.js +34 -11
- package/src/phaser/display/webgl/filter_manager.js +25 -7
- package/src/phaser/display/webgl/filter_texture.js +21 -22
- package/src/phaser/display/webgl/graphics.js +5 -28
- package/src/phaser/display/webgl/graphics_data.js +10 -7
- package/src/phaser/display/webgl/mask_manager.js +0 -6
- package/src/phaser/display/webgl/render_texture.js +33 -21
- package/src/phaser/display/webgl/renderer.js +38 -11
- package/src/phaser/display/webgl/shader/complex.js +10 -6
- package/src/phaser/display/webgl/shader/fast.js +10 -6
- package/src/phaser/display/webgl/shader/normal.js +23 -32
- package/src/phaser/display/webgl/shader/primitive.js +10 -6
- package/src/phaser/display/webgl/shader/strip.js +10 -6
- package/src/phaser/display/webgl/shader_manager.js +18 -6
- package/src/phaser/display/webgl/sprite_batch.js +41 -8
- package/src/phaser/display/webgl/stencil_manager.js +28 -6
- package/src/phaser/display/webgl/texture.js +28 -15
- package/src/phaser/display/webgl/texture_util.js +0 -6
- package/src/phaser/display/webgl/util.js +0 -7
- package/src/phaser/geom/circle.js +123 -18
- package/src/phaser/geom/ellipse.js +39 -18
- package/src/phaser/geom/line.js +148 -16
- package/src/phaser/geom/matrix.js +73 -6
- package/src/phaser/geom/point.js +152 -6
- package/src/phaser/geom/polygon.js +42 -14
- package/src/phaser/geom/rectangle.js +233 -6
- package/src/phaser/geom/rounded_rectangle.js +10 -6
- package/src/phaser/geom/util/circle.js +3 -9
- package/src/phaser/geom/util/ellipse.js +0 -7
- package/src/phaser/geom/util/line.js +5 -14
- package/src/phaser/geom/util/matrix.js +1 -7
- package/src/phaser/geom/util/point.js +0 -6
- package/src/phaser/geom/util/polygon.js +1 -7
- package/src/phaser/geom/util/rectangle.js +1 -7
- package/src/phaser/geom/util/rounded_rectangle.js +1 -7
- package/src/phaser/util/math.js +3 -21
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/phaser/core/animation.d.ts +126 -13
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +121 -19
- package/types/phaser/core/animation_manager.d.ts.map +1 -1
- package/types/phaser/core/animation_parser.d.ts +6 -5
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/array_set.d.ts +67 -13
- package/types/phaser/core/array_set.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +365 -69
- package/types/phaser/core/cache.d.ts.map +1 -1
- package/types/phaser/core/const.d.ts +143 -40
- package/types/phaser/core/const.d.ts.map +1 -1
- package/types/phaser/core/device.d.ts +0 -5
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/device_util.d.ts +1 -1
- package/types/phaser/core/device_util.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +119 -0
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +127 -0
- package/types/phaser/core/event_manager.d.ts.map +1 -1
- package/types/phaser/core/factory.d.ts +75 -8
- package/types/phaser/core/factory.d.ts.map +1 -1
- package/types/phaser/core/frame.d.ts +64 -21
- package/types/phaser/core/frame.d.ts.map +1 -1
- package/types/phaser/core/frame_data.d.ts +61 -9
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/frame_util.d.ts +10 -8
- package/types/phaser/core/frame_util.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +40 -6
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input.d.ts +143 -15
- package/types/phaser/core/input.d.ts.map +1 -1
- package/types/phaser/core/input_handler.d.ts +258 -25
- package/types/phaser/core/input_handler.d.ts.map +1 -1
- package/types/phaser/core/input_mouse.d.ts +62 -14
- package/types/phaser/core/input_mouse.d.ts.map +1 -1
- package/types/phaser/core/input_mspointer.d.ts +51 -17
- package/types/phaser/core/input_mspointer.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +99 -14
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/input_touch.d.ts +53 -16
- package/types/phaser/core/input_touch.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +299 -28
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +19 -9
- package/types/phaser/core/raf.d.ts.map +1 -1
- package/types/phaser/core/scale_manager.d.ts +208 -13
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +21 -5
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +90 -10
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +93 -9
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/signal_binding.d.ts +34 -5
- package/types/phaser/core/signal_binding.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +111 -14
- package/types/phaser/core/sound.d.ts.map +1 -1
- package/types/phaser/core/sound_manager.d.ts +97 -11
- package/types/phaser/core/sound_manager.d.ts.map +1 -1
- package/types/phaser/core/sound_sprite.d.ts +22 -8
- package/types/phaser/core/sound_sprite.d.ts.map +1 -1
- package/types/phaser/core/stage.d.ts +32 -3
- package/types/phaser/core/stage.d.ts.map +1 -1
- package/types/phaser/core/time.d.ts +73 -6
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +108 -7
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +13 -7
- package/types/phaser/core/timer_event.d.ts.map +1 -1
- package/types/phaser/core/tween.d.ts +124 -4
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +41 -2
- package/types/phaser/core/tween_data.d.ts.map +1 -1
- package/types/phaser/core/tween_easing.d.ts +0 -5
- package/types/phaser/core/tween_easing.d.ts.map +1 -1
- package/types/phaser/core/tween_manager.d.ts +49 -2
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +9 -1
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +84 -7
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +65 -8
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +20 -4
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/masker.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +0 -6
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +29 -2
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +195 -8
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +132 -6
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +15 -1
- package/types/phaser/display/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/graphics_data_util.d.ts +3 -2
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/types/phaser/display/group.d.ts +80 -10
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +72 -6
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/sprite_batch.d.ts +4 -3
- package/types/phaser/display/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/sprite_util.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +366 -46
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/types/phaser/display/webgl/base_texture.d.ts +20 -1
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/webgl/filter_manager.d.ts +22 -6
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +10 -6
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/render_texture.d.ts +30 -3
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/renderer.d.ts +41 -4
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +10 -0
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/fast.d.ts +10 -0
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/normal.d.ts +20 -0
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/primitive.d.ts +10 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/strip.d.ts +10 -0
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader_manager.d.ts +15 -0
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/sprite_batch.d.ts +37 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture.d.ts +21 -0
- package/types/phaser/display/webgl/texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/display/webgl/util.d.ts +0 -6
- package/types/phaser/display/webgl/util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +131 -9
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +43 -5
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +159 -13
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +85 -11
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +170 -18
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +45 -5
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +253 -20
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +11 -1
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/circle.d.ts +3 -3
- package/types/phaser/geom/util/circle.d.ts.map +1 -1
- package/types/phaser/geom/util/ellipse.d.ts +0 -6
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/util/line.d.ts +5 -5
- package/types/phaser/geom/util/line.d.ts.map +1 -1
- package/types/phaser/geom/util/matrix.d.ts.map +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/types/phaser/geom/util/polygon.d.ts.map +1 -1
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/util/math.d.ts +0 -5
- package/types/phaser/util/math.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
@vpmedia/phaser
|
|
2
|
-
===============
|
|
1
|
+
# @vpmedia/phaser
|
|
3
2
|
|
|
4
|
-
[](https://badge.fury.io/js/@vpmedia%2Fphaser)
|
|
5
4
|
[](https://github.com/vpmedia/phaser/actions/workflows/node.js.yml)
|
|
6
5
|
|
|
7
6
|
@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2.
|
|
@@ -17,6 +16,7 @@ https://github.com/vpmedia/phaser-example
|
|
|
17
16
|
### Comments
|
|
18
17
|
|
|
19
18
|
Some features has not been ported compared to the original version:
|
|
19
|
+
|
|
20
20
|
- Creature, RetroFont, Rope, SpriteBatch and Video display objects
|
|
21
21
|
- Particle System
|
|
22
22
|
- Physics System
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2",
|
|
5
5
|
"author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"eslint-config-prettier": "^8.8.0",
|
|
27
27
|
"eslint-plugin-import": "^2.27.5",
|
|
28
28
|
"eslint-plugin-jest": "^27.2.1",
|
|
29
|
-
"eslint-plugin-jsdoc": "^43.0.
|
|
29
|
+
"eslint-plugin-jsdoc": "^43.0.6",
|
|
30
30
|
"eslint-plugin-prettier": "^4.2.1",
|
|
31
31
|
"husky": "^8.0.3",
|
|
32
32
|
"jest": "^29.5.0",
|
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
|
|
39
|
-
"lint": "eslint \"**/*.js\"",
|
|
40
|
-
"lint-fix": "eslint \"**/*.js\"
|
|
39
|
+
"lint": "eslint \"**/*.{js,jsx}\"",
|
|
40
|
+
"lint-fix": "eslint --fix \"**/*.{js,jsx}\"",
|
|
41
41
|
"typecheck": "tsc",
|
|
42
|
-
"format": "prettier --write \"**/*.{js,json}\"",
|
|
42
|
+
"format": "prettier --write \"**/*.{css,js,jsx,json,md}\"",
|
|
43
|
+
"prepare": "husky install",
|
|
43
44
|
"lint-staged": "lint-staged"
|
|
44
45
|
},
|
|
45
46
|
"engines": {
|
package/src/index.js
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
*/
|
|
6
1
|
// core
|
|
7
2
|
import * as Const from './phaser/core/const';
|
|
8
3
|
import { Game } from './phaser/core/game';
|
|
9
|
-
import { Signal } from
|
|
4
|
+
import { Signal } from './phaser/core/signal';
|
|
10
5
|
import * as MathUtils from './phaser/util/math';
|
|
11
6
|
// texture
|
|
12
7
|
import { BaseTexture } from './phaser/display/webgl/base_texture';
|
|
13
8
|
import { Texture } from './phaser/display/webgl/texture';
|
|
14
9
|
// geom
|
|
15
|
-
import { Circle } from
|
|
16
|
-
import { Ellipse } from
|
|
17
|
-
import { Line } from
|
|
18
|
-
import { Matrix } from
|
|
10
|
+
import { Circle } from './phaser/geom/circle';
|
|
11
|
+
import { Ellipse } from './phaser/geom/ellipse';
|
|
12
|
+
import { Line } from './phaser/geom/line';
|
|
13
|
+
import { Matrix } from './phaser/geom/matrix';
|
|
19
14
|
import { Point } from './phaser/geom/point';
|
|
20
|
-
import { Polygon } from
|
|
21
|
-
import { Rectangle } from
|
|
22
|
-
import { RoundedRectangle } from
|
|
15
|
+
import { Polygon } from './phaser/geom/polygon';
|
|
16
|
+
import { Rectangle } from './phaser/geom/rectangle';
|
|
17
|
+
import { RoundedRectangle } from './phaser/geom/rounded_rectangle';
|
|
23
18
|
// display
|
|
24
|
-
import { BitmapText } from
|
|
25
|
-
import { DisplayObject } from
|
|
26
|
-
import { Button } from
|
|
19
|
+
import { BitmapText } from './phaser/display/bitmap_text';
|
|
20
|
+
import { DisplayObject } from './phaser/display/display_object';
|
|
21
|
+
import { Button } from './phaser/display/button';
|
|
27
22
|
import { Image } from './phaser/display/image';
|
|
28
|
-
import { Group } from
|
|
29
|
-
import { Text } from
|
|
23
|
+
import { Group } from './phaser/display/group';
|
|
24
|
+
import { Text } from './phaser/display/text';
|
|
25
|
+
import { Graphics } from './phaser/display/graphics';
|
|
30
26
|
// exports
|
|
31
27
|
export {
|
|
32
28
|
Const,
|
|
@@ -49,4 +45,5 @@ export {
|
|
|
49
45
|
Image,
|
|
50
46
|
Group,
|
|
51
47
|
Text,
|
|
48
|
+
Graphics,
|
|
52
49
|
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
*/
|
|
6
|
-
import { Signal } from './signal';
|
|
1
|
+
import { Game } from './game';
|
|
2
|
+
import { Signal } from './signal';
|
|
3
|
+
import { FrameData } from './frame_data';
|
|
7
4
|
|
|
8
5
|
export class Animation {
|
|
6
|
+
/**
|
|
7
|
+
* TBD.
|
|
8
|
+
* @param {Game} game - TBD.
|
|
9
|
+
* @param parent - TBD.
|
|
10
|
+
* @param {string} name - TBD.
|
|
11
|
+
* @param {FrameData} frameData - TBD.
|
|
12
|
+
* @param frames - TBD.
|
|
13
|
+
* @param {number} frameRate - TBD.
|
|
14
|
+
* @param {boolean} loop - TBD.
|
|
15
|
+
*/
|
|
9
16
|
constructor(game, parent, name, frameData, frames, frameRate, loop = false) {
|
|
10
17
|
this.game = game;
|
|
11
18
|
this._parent = parent;
|
|
@@ -35,6 +42,13 @@ export class Animation {
|
|
|
35
42
|
this.game.onResume.add(this.onResume, this);
|
|
36
43
|
}
|
|
37
44
|
|
|
45
|
+
/**
|
|
46
|
+
* TBD.
|
|
47
|
+
* @param {number} frameRate - TBD.
|
|
48
|
+
* @param {boolean} loop - TBD.
|
|
49
|
+
* @param {boolean} killOnComplete - TBD.
|
|
50
|
+
* @returns {Animation} TBD.
|
|
51
|
+
*/
|
|
38
52
|
play(frameRate, loop, killOnComplete) {
|
|
39
53
|
if (typeof frameRate === 'number') {
|
|
40
54
|
// If they set a new frame rate then use it, otherwise use the one set on creation
|
|
@@ -63,6 +77,9 @@ export class Animation {
|
|
|
63
77
|
return this;
|
|
64
78
|
}
|
|
65
79
|
|
|
80
|
+
/**
|
|
81
|
+
* TBD.
|
|
82
|
+
*/
|
|
66
83
|
restart() {
|
|
67
84
|
this.isPlaying = true;
|
|
68
85
|
this.isFinished = false;
|
|
@@ -78,16 +95,29 @@ export class Animation {
|
|
|
78
95
|
this.onStart.dispatch(this._parent, this);
|
|
79
96
|
}
|
|
80
97
|
|
|
98
|
+
/**
|
|
99
|
+
* TBD.
|
|
100
|
+
* @returns {Animation} TBD.
|
|
101
|
+
*/
|
|
81
102
|
reverse() {
|
|
82
103
|
this.reversed = !this.reversed;
|
|
83
104
|
return this;
|
|
84
105
|
}
|
|
85
106
|
|
|
107
|
+
/**
|
|
108
|
+
* TBD.
|
|
109
|
+
* @returns {Animation} TBD.
|
|
110
|
+
*/
|
|
86
111
|
reverseOnce() {
|
|
87
112
|
this.onComplete.addOnce(this.reverse, this);
|
|
88
113
|
return this.reverse();
|
|
89
114
|
}
|
|
90
115
|
|
|
116
|
+
/**
|
|
117
|
+
* TBD.
|
|
118
|
+
* @param {number|string} frameId - TBD.
|
|
119
|
+
* @param {boolean} useLocalFrameIndex - TBD.
|
|
120
|
+
*/
|
|
91
121
|
setFrame(frameId, useLocalFrameIndex = false) {
|
|
92
122
|
let frameIndex;
|
|
93
123
|
// Find the index to the desired frame.
|
|
@@ -117,6 +147,11 @@ export class Animation {
|
|
|
117
147
|
}
|
|
118
148
|
}
|
|
119
149
|
|
|
150
|
+
/**
|
|
151
|
+
* TBD.
|
|
152
|
+
* @param {boolean} resetFrame - TBD.
|
|
153
|
+
* @param {boolean} dispatchComplete - TBD.
|
|
154
|
+
*/
|
|
120
155
|
stop(resetFrame = false, dispatchComplete = false) {
|
|
121
156
|
this.isPlaying = false;
|
|
122
157
|
this.isFinished = true;
|
|
@@ -133,18 +168,28 @@ export class Animation {
|
|
|
133
168
|
}
|
|
134
169
|
}
|
|
135
170
|
|
|
171
|
+
/**
|
|
172
|
+
* TBD.
|
|
173
|
+
*/
|
|
136
174
|
onPause() {
|
|
137
175
|
if (this.isPlaying) {
|
|
138
176
|
this._frameDiff = this._timeNextFrame - this.game.time.time;
|
|
139
177
|
}
|
|
140
178
|
}
|
|
141
179
|
|
|
180
|
+
/**
|
|
181
|
+
* TBD.
|
|
182
|
+
*/
|
|
142
183
|
onResume() {
|
|
143
184
|
if (this.isPlaying) {
|
|
144
185
|
this._timeNextFrame = this.game.time.time + this._frameDiff;
|
|
145
186
|
}
|
|
146
187
|
}
|
|
147
188
|
|
|
189
|
+
/**
|
|
190
|
+
* TBD.
|
|
191
|
+
* @returns {boolean} TBD.
|
|
192
|
+
*/
|
|
148
193
|
update() {
|
|
149
194
|
if (this.isPaused) {
|
|
150
195
|
return false;
|
|
@@ -200,6 +245,12 @@ export class Animation {
|
|
|
200
245
|
return false;
|
|
201
246
|
}
|
|
202
247
|
|
|
248
|
+
/**
|
|
249
|
+
* TBD.
|
|
250
|
+
* @param {boolean} signalUpdate - TBD.
|
|
251
|
+
* @param {boolean} fromPlay - TBD.
|
|
252
|
+
* @returns {boolean} TBD.
|
|
253
|
+
*/
|
|
203
254
|
updateCurrentFrame(signalUpdate, fromPlay = false) {
|
|
204
255
|
if (!this._frameData || !this.currentFrame) {
|
|
205
256
|
// The animation is already destroyed, probably from a callback
|
|
@@ -219,6 +270,10 @@ export class Animation {
|
|
|
219
270
|
return true;
|
|
220
271
|
}
|
|
221
272
|
|
|
273
|
+
/**
|
|
274
|
+
* TBD.
|
|
275
|
+
* @param {number} quantity - TBD.
|
|
276
|
+
*/
|
|
222
277
|
next(quantity = 1) {
|
|
223
278
|
let frame = this._frameIndex + quantity;
|
|
224
279
|
if (frame >= this._frames.length) {
|
|
@@ -234,6 +289,10 @@ export class Animation {
|
|
|
234
289
|
}
|
|
235
290
|
}
|
|
236
291
|
|
|
292
|
+
/**
|
|
293
|
+
* TBD.
|
|
294
|
+
* @param {number} quantity - TBD.
|
|
295
|
+
*/
|
|
237
296
|
previous(quantity = 1) {
|
|
238
297
|
let frame = this._frameIndex - quantity;
|
|
239
298
|
if (frame < 0) {
|
|
@@ -249,6 +308,10 @@ export class Animation {
|
|
|
249
308
|
}
|
|
250
309
|
}
|
|
251
310
|
|
|
311
|
+
/**
|
|
312
|
+
* TBD.
|
|
313
|
+
* @param {FrameData} frameData - TBD.
|
|
314
|
+
*/
|
|
252
315
|
updateFrameData(frameData) {
|
|
253
316
|
this._frameData = frameData;
|
|
254
317
|
this.currentFrame = this._frameData
|
|
@@ -256,6 +319,9 @@ export class Animation {
|
|
|
256
319
|
: null;
|
|
257
320
|
}
|
|
258
321
|
|
|
322
|
+
/**
|
|
323
|
+
* TBD.
|
|
324
|
+
*/
|
|
259
325
|
destroy() {
|
|
260
326
|
if (!this._frameData) {
|
|
261
327
|
// Already destroyed
|
|
@@ -277,6 +343,9 @@ export class Animation {
|
|
|
277
343
|
}
|
|
278
344
|
}
|
|
279
345
|
|
|
346
|
+
/**
|
|
347
|
+
* TBD.
|
|
348
|
+
*/
|
|
280
349
|
complete() {
|
|
281
350
|
this._frameIndex = this._frames.length - 1;
|
|
282
351
|
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
|
@@ -290,10 +359,17 @@ export class Animation {
|
|
|
290
359
|
}
|
|
291
360
|
}
|
|
292
361
|
|
|
362
|
+
/**
|
|
363
|
+
* TBD.
|
|
364
|
+
* @returns {boolean} TBD.
|
|
365
|
+
*/
|
|
293
366
|
get paused() {
|
|
294
367
|
return this.isPaused;
|
|
295
368
|
}
|
|
296
369
|
|
|
370
|
+
/**
|
|
371
|
+
* TBD.
|
|
372
|
+
*/
|
|
297
373
|
set paused(value) {
|
|
298
374
|
this.isPaused = value;
|
|
299
375
|
if (value) {
|
|
@@ -303,18 +379,33 @@ export class Animation {
|
|
|
303
379
|
}
|
|
304
380
|
}
|
|
305
381
|
|
|
382
|
+
/**
|
|
383
|
+
* TBD.
|
|
384
|
+
* @returns {boolean} TBD.
|
|
385
|
+
*/
|
|
306
386
|
get reversed() {
|
|
307
387
|
return this.isReversed;
|
|
308
388
|
}
|
|
309
389
|
|
|
390
|
+
/**
|
|
391
|
+
* TBD.
|
|
392
|
+
*/
|
|
310
393
|
set reversed(value) {
|
|
311
394
|
this.isReversed = value;
|
|
312
395
|
}
|
|
313
396
|
|
|
397
|
+
/**
|
|
398
|
+
* TBD.
|
|
399
|
+
* @returns {number} TBD.
|
|
400
|
+
*/
|
|
314
401
|
get frameTotal() {
|
|
315
402
|
return this._frames.length;
|
|
316
403
|
}
|
|
317
404
|
|
|
405
|
+
/**
|
|
406
|
+
* TBD.
|
|
407
|
+
* @returns {number} TBD.
|
|
408
|
+
*/
|
|
318
409
|
get frame() {
|
|
319
410
|
if (this.currentFrame !== null) {
|
|
320
411
|
return this.currentFrame.index;
|
|
@@ -322,6 +413,9 @@ export class Animation {
|
|
|
322
413
|
return this._frameIndex;
|
|
323
414
|
}
|
|
324
415
|
|
|
416
|
+
/**
|
|
417
|
+
* TBD.
|
|
418
|
+
*/
|
|
325
419
|
set frame(value) {
|
|
326
420
|
this.currentFrame = this._frameData.getFrame(this._frames[value]);
|
|
327
421
|
if (this.currentFrame !== null) {
|
|
@@ -333,20 +427,34 @@ export class Animation {
|
|
|
333
427
|
}
|
|
334
428
|
}
|
|
335
429
|
|
|
430
|
+
/**
|
|
431
|
+
* TBD.
|
|
432
|
+
* @returns {number} TBD.
|
|
433
|
+
*/
|
|
336
434
|
get speed() {
|
|
337
435
|
return 1000 / this.delay;
|
|
338
436
|
}
|
|
339
437
|
|
|
438
|
+
/**
|
|
439
|
+
* TBD.
|
|
440
|
+
*/
|
|
340
441
|
set speed(value) {
|
|
341
442
|
if (value > 0) {
|
|
342
443
|
this.delay = 1000 / value;
|
|
343
444
|
}
|
|
344
445
|
}
|
|
345
446
|
|
|
447
|
+
/**
|
|
448
|
+
* TBD.
|
|
449
|
+
* @returns {boolean} TBD.
|
|
450
|
+
*/
|
|
346
451
|
get enableUpdate() {
|
|
347
452
|
return this.onUpdate !== null;
|
|
348
453
|
}
|
|
349
454
|
|
|
455
|
+
/**
|
|
456
|
+
* TBD.
|
|
457
|
+
*/
|
|
350
458
|
set enableUpdate(value) {
|
|
351
459
|
if (value && this.onUpdate === null) {
|
|
352
460
|
this.onUpdate = new Signal();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
*/
|
|
6
1
|
import { Animation } from './animation';
|
|
2
|
+
import { FrameData } from './frame_data';
|
|
7
3
|
|
|
8
4
|
export class AnimationManager {
|
|
5
|
+
/**
|
|
6
|
+
* TBD.
|
|
7
|
+
* @param sprite - TBD.
|
|
8
|
+
*/
|
|
9
9
|
constructor(sprite) {
|
|
10
10
|
this.sprite = sprite;
|
|
11
11
|
this.game = sprite.game;
|
|
@@ -18,6 +18,9 @@ export class AnimationManager {
|
|
|
18
18
|
this._outputFrames = [];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* TBD.
|
|
23
|
+
*/
|
|
21
24
|
destroy() {
|
|
22
25
|
const keys = Object.keys(this._anims);
|
|
23
26
|
for (let i = 0; i < keys.length; i += 1) {
|
|
@@ -32,6 +35,12 @@ export class AnimationManager {
|
|
|
32
35
|
this.game = null;
|
|
33
36
|
}
|
|
34
37
|
|
|
38
|
+
/**
|
|
39
|
+
* TBD.
|
|
40
|
+
* @param {FrameData} frameData - TBD.
|
|
41
|
+
* @param {number|string} frame - TBD.
|
|
42
|
+
* @returns {boolean} TBD.
|
|
43
|
+
*/
|
|
35
44
|
loadFrameData(frameData, frame) {
|
|
36
45
|
if (!frameData) {
|
|
37
46
|
return false;
|
|
@@ -56,6 +65,12 @@ export class AnimationManager {
|
|
|
56
65
|
return true;
|
|
57
66
|
}
|
|
58
67
|
|
|
68
|
+
/**
|
|
69
|
+
* TBD.
|
|
70
|
+
* @param {FrameData} frameData - TBD.
|
|
71
|
+
* @param {number|string} frame - TBD.
|
|
72
|
+
* @returns {boolean} TBD.
|
|
73
|
+
*/
|
|
59
74
|
copyFrameData(frameData, frame) {
|
|
60
75
|
this._frameData = frameData.clone();
|
|
61
76
|
if (this.isLoaded) {
|
|
@@ -77,6 +92,15 @@ export class AnimationManager {
|
|
|
77
92
|
return true;
|
|
78
93
|
}
|
|
79
94
|
|
|
95
|
+
/**
|
|
96
|
+
* TBD.
|
|
97
|
+
* @param {string} name - TBD.
|
|
98
|
+
* @param {number[]|string[]} frameList - TBD.
|
|
99
|
+
* @param {number} frameRate - TBD.
|
|
100
|
+
* @param {boolean} loop - TBD.
|
|
101
|
+
* @param {boolean} useNumericIndex - TBD.
|
|
102
|
+
* @returns {Animation} TBD.
|
|
103
|
+
*/
|
|
80
104
|
add(name, frameList, frameRate = 60, loop = false, useNumericIndex = undefined) {
|
|
81
105
|
const frames = frameList || [];
|
|
82
106
|
// If they didn't set the useNumericIndex then let's at least try and guess it
|
|
@@ -105,6 +129,12 @@ export class AnimationManager {
|
|
|
105
129
|
return this._anims[name];
|
|
106
130
|
}
|
|
107
131
|
|
|
132
|
+
/**
|
|
133
|
+
* TBD.
|
|
134
|
+
* @param {number[]} frames - TBD.
|
|
135
|
+
* @param {boolean} useNumericIndex - TBD.
|
|
136
|
+
* @returns {boolean} TBD.
|
|
137
|
+
*/
|
|
108
138
|
validateFrames(frames, useNumericIndex = false) {
|
|
109
139
|
for (let i = 0; i < frames.length; i += 1) {
|
|
110
140
|
if (useNumericIndex === true) {
|
|
@@ -118,6 +148,14 @@ export class AnimationManager {
|
|
|
118
148
|
return true;
|
|
119
149
|
}
|
|
120
150
|
|
|
151
|
+
/**
|
|
152
|
+
* TBD.
|
|
153
|
+
* @param {string} name - TBD.
|
|
154
|
+
* @param {number} frameRate - TBD.
|
|
155
|
+
* @param {boolean} loop - TBD.
|
|
156
|
+
* @param {boolean} killOnComplete - TBD.
|
|
157
|
+
* @returns {Animation} TBD.
|
|
158
|
+
*/
|
|
121
159
|
play(name, frameRate, loop, killOnComplete) {
|
|
122
160
|
if (this._anims[name]) {
|
|
123
161
|
if (this.currentAnim === this._anims[name]) {
|
|
@@ -138,12 +176,21 @@ export class AnimationManager {
|
|
|
138
176
|
return null;
|
|
139
177
|
}
|
|
140
178
|
|
|
179
|
+
/**
|
|
180
|
+
* TBD.
|
|
181
|
+
* @param {string} name - TBD.
|
|
182
|
+
* @param {boolean} resetFrame - TBD.
|
|
183
|
+
*/
|
|
141
184
|
stop(name, resetFrame = false) {
|
|
142
185
|
if (this.currentAnim && (typeof name !== 'string' || name === this.currentAnim.name)) {
|
|
143
186
|
this.currentAnim.stop(resetFrame);
|
|
144
187
|
}
|
|
145
188
|
}
|
|
146
189
|
|
|
190
|
+
/**
|
|
191
|
+
* TBD.
|
|
192
|
+
* @returns {boolean} TBD.
|
|
193
|
+
*/
|
|
147
194
|
update() {
|
|
148
195
|
if (this.updateIfVisible && !this.sprite.visible) {
|
|
149
196
|
return false;
|
|
@@ -155,6 +202,10 @@ export class AnimationManager {
|
|
|
155
202
|
return false;
|
|
156
203
|
}
|
|
157
204
|
|
|
205
|
+
/**
|
|
206
|
+
* TBD.
|
|
207
|
+
* @param {number} quantity - TBD.
|
|
208
|
+
*/
|
|
158
209
|
next(quantity) {
|
|
159
210
|
if (this.currentAnim) {
|
|
160
211
|
this.currentAnim.next(quantity);
|
|
@@ -162,6 +213,10 @@ export class AnimationManager {
|
|
|
162
213
|
}
|
|
163
214
|
}
|
|
164
215
|
|
|
216
|
+
/**
|
|
217
|
+
* TBD.
|
|
218
|
+
* @param {number} quantity - TBD.
|
|
219
|
+
*/
|
|
165
220
|
previous(quantity) {
|
|
166
221
|
if (this.currentAnim) {
|
|
167
222
|
this.currentAnim.previous(quantity);
|
|
@@ -169,6 +224,11 @@ export class AnimationManager {
|
|
|
169
224
|
}
|
|
170
225
|
}
|
|
171
226
|
|
|
227
|
+
/**
|
|
228
|
+
* TBD.
|
|
229
|
+
* @param {string} name - TBD.
|
|
230
|
+
* @returns {Animation} TBD.
|
|
231
|
+
*/
|
|
172
232
|
getAnimation(name) {
|
|
173
233
|
if (name && this._anims[name]) {
|
|
174
234
|
return this._anims[name];
|
|
@@ -176,28 +236,50 @@ export class AnimationManager {
|
|
|
176
236
|
return null;
|
|
177
237
|
}
|
|
178
238
|
|
|
239
|
+
/**
|
|
240
|
+
* TBD.
|
|
241
|
+
*/
|
|
179
242
|
refreshFrame() {
|
|
180
243
|
// TODO
|
|
181
244
|
console.warn('animation_manager.refreshFrame() is not implemented');
|
|
182
245
|
// this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
|
183
246
|
}
|
|
184
247
|
|
|
248
|
+
/**
|
|
249
|
+
* TBD.
|
|
250
|
+
* @returns {FrameData} TBD.
|
|
251
|
+
*/
|
|
185
252
|
get frameData() {
|
|
186
253
|
return this._frameData;
|
|
187
254
|
}
|
|
188
255
|
|
|
256
|
+
/**
|
|
257
|
+
* TBD.
|
|
258
|
+
* @returns {number} TBD.
|
|
259
|
+
*/
|
|
189
260
|
get frameTotal() {
|
|
190
261
|
return this._frameData.total;
|
|
191
262
|
}
|
|
192
263
|
|
|
264
|
+
/**
|
|
265
|
+
* TBD.
|
|
266
|
+
* @returns {boolean} TBD.
|
|
267
|
+
*/
|
|
193
268
|
get paused() {
|
|
194
269
|
return this.currentAnim.isPaused;
|
|
195
270
|
}
|
|
196
271
|
|
|
272
|
+
/**
|
|
273
|
+
* TBD.
|
|
274
|
+
*/
|
|
197
275
|
set paused(value) {
|
|
198
276
|
this.currentAnim.paused = value;
|
|
199
277
|
}
|
|
200
278
|
|
|
279
|
+
/**
|
|
280
|
+
* TBD.
|
|
281
|
+
* @returns {string} TBD.
|
|
282
|
+
*/
|
|
201
283
|
get name() {
|
|
202
284
|
if (this.currentAnim) {
|
|
203
285
|
return this.currentAnim.name;
|
|
@@ -205,6 +287,10 @@ export class AnimationManager {
|
|
|
205
287
|
return null;
|
|
206
288
|
}
|
|
207
289
|
|
|
290
|
+
/**
|
|
291
|
+
* TBD.
|
|
292
|
+
* @returns {number} TBD.
|
|
293
|
+
*/
|
|
208
294
|
get frame() {
|
|
209
295
|
if (this.currentFrame) {
|
|
210
296
|
return this.currentFrame.index;
|
|
@@ -212,6 +298,9 @@ export class AnimationManager {
|
|
|
212
298
|
return 0;
|
|
213
299
|
}
|
|
214
300
|
|
|
301
|
+
/**
|
|
302
|
+
* TBD.
|
|
303
|
+
*/
|
|
215
304
|
set frame(value) {
|
|
216
305
|
if (typeof value === 'number' && this._frameData && this._frameData.getFrame(value) !== null) {
|
|
217
306
|
this.currentFrame = this._frameData.getFrame(value);
|
|
@@ -223,6 +312,10 @@ export class AnimationManager {
|
|
|
223
312
|
}
|
|
224
313
|
}
|
|
225
314
|
|
|
315
|
+
/**
|
|
316
|
+
* TBD.
|
|
317
|
+
* @returns {string} TBD.
|
|
318
|
+
*/
|
|
226
319
|
get frameName() {
|
|
227
320
|
if (this.currentFrame) {
|
|
228
321
|
return this.currentFrame.name;
|
|
@@ -230,12 +323,11 @@ export class AnimationManager {
|
|
|
230
323
|
return null;
|
|
231
324
|
}
|
|
232
325
|
|
|
326
|
+
/**
|
|
327
|
+
* TBD.
|
|
328
|
+
*/
|
|
233
329
|
set frameName(value) {
|
|
234
|
-
if (
|
|
235
|
-
typeof value === 'string' &&
|
|
236
|
-
this._frameData &&
|
|
237
|
-
this._frameData.getFrameByName(value) !== null
|
|
238
|
-
) {
|
|
330
|
+
if (typeof value === 'string' && this._frameData && this._frameData.getFrameByName(value) !== null) {
|
|
239
331
|
this.currentFrame = this._frameData.getFrameByName(value);
|
|
240
332
|
if (this.currentFrame) {
|
|
241
333
|
this._frameIndex = this.currentFrame.index;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
*/
|
|
6
1
|
import { Frame } from './frame';
|
|
7
2
|
import { FrameData } from './frame_data';
|
|
3
|
+
import { Game } from './game';
|
|
8
4
|
|
|
9
5
|
/**
|
|
10
6
|
* TBD.
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
7
|
+
* @param {Game} game - TBD.
|
|
8
|
+
* @param {string} key - TBD.
|
|
13
9
|
* @param {number} frameWidth - TBD.
|
|
14
10
|
* @param {number} frameHeight - TBD.
|
|
15
11
|
* @param {number} frameMax - TBD.
|
|
@@ -42,9 +38,7 @@ export function spriteSheet(game, key, frameWidth, frameHeight, frameMax, margin
|
|
|
42
38
|
// Zero or smaller than frame sizes?
|
|
43
39
|
if (width === 0 || height === 0 || width < frameWidth || height < frameHeight || total === 0) {
|
|
44
40
|
console.warn(
|
|
45
|
-
"AnimationParser.spriteSheet: '" +
|
|
46
|
-
key +
|
|
47
|
-
"'s width/height zero or width/height < given frameWidth/frameHeight"
|
|
41
|
+
"AnimationParser.spriteSheet: '" + key + "'s width/height zero or width/height < given frameWidth/frameHeight"
|
|
48
42
|
);
|
|
49
43
|
return null;
|
|
50
44
|
}
|
|
@@ -65,7 +59,7 @@ export function spriteSheet(game, key, frameWidth, frameHeight, frameMax, margin
|
|
|
65
59
|
|
|
66
60
|
/**
|
|
67
61
|
* TBD.
|
|
68
|
-
* @param {
|
|
62
|
+
* @param {Game} game - TBD.
|
|
69
63
|
* @param {object} json - TBD.
|
|
70
64
|
* @returns {object} TBD.
|
|
71
65
|
*/
|
|
@@ -84,14 +78,7 @@ export function JSONDataHash(game, json) {
|
|
|
84
78
|
for (let k = 0; k < keys.length; k += 1) {
|
|
85
79
|
const key = keys[k];
|
|
86
80
|
newFrame = data.addFrame(
|
|
87
|
-
new Frame(
|
|
88
|
-
i,
|
|
89
|
-
frames[key].frame.x,
|
|
90
|
-
frames[key].frame.y,
|
|
91
|
-
frames[key].frame.w,
|
|
92
|
-
frames[key].frame.h,
|
|
93
|
-
key
|
|
94
|
-
)
|
|
81
|
+
new Frame(i, frames[key].frame.x, frames[key].frame.y, frames[key].frame.w, frames[key].frame.h, key)
|
|
95
82
|
);
|
|
96
83
|
if (frames[key].trimmed) {
|
|
97
84
|
newFrame.setTrim(
|