melonjs 14.4.0 → 14.5.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.
Files changed (207) hide show
  1. package/README.md +11 -55
  2. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  5. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  6. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  7. package/dist/melonjs.mjs/_virtual/index2.js +1 -1
  8. package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
  9. package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
  10. package/dist/melonjs.mjs/application/application.js +1 -1
  11. package/dist/melonjs.mjs/application/header.js +1 -1
  12. package/dist/melonjs.mjs/application/resize.js +1 -1
  13. package/dist/melonjs.mjs/application/settings.js +1 -1
  14. package/dist/melonjs.mjs/audio/audio.js +4 -4
  15. package/dist/melonjs.mjs/camera/camera2d.js +1 -1
  16. package/dist/melonjs.mjs/const.js +1 -1
  17. package/dist/melonjs.mjs/entity/entity.js +43 -9
  18. package/dist/melonjs.mjs/geometries/ellipse.js +2 -3
  19. package/dist/melonjs.mjs/geometries/line.js +1 -1
  20. package/dist/melonjs.mjs/geometries/path2d.js +18 -42
  21. package/dist/melonjs.mjs/geometries/point.js +1 -6
  22. package/dist/melonjs.mjs/geometries/poly.js +2 -5
  23. package/dist/melonjs.mjs/geometries/rectangle.js +13 -9
  24. package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
  25. package/dist/melonjs.mjs/index.js +8 -6
  26. package/dist/melonjs.mjs/input/gamepad.js +10 -16
  27. package/dist/melonjs.mjs/input/input.js +1 -1
  28. package/dist/melonjs.mjs/input/keyboard.js +1 -1
  29. package/dist/melonjs.mjs/input/pointer.js +1 -1
  30. package/dist/melonjs.mjs/input/pointerevent.js +2 -16
  31. package/dist/melonjs.mjs/lang/console.js +1 -1
  32. package/dist/melonjs.mjs/lang/deprecated.js +1 -1
  33. package/dist/melonjs.mjs/level/level.js +3 -3
  34. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  35. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -8
  36. package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
  37. package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
  38. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +8 -4
  39. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +5 -5
  40. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
  41. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +1 -1
  42. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  43. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  44. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  45. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  46. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
  47. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  48. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  49. package/dist/melonjs.mjs/loader/cache.js +24 -0
  50. package/dist/melonjs.mjs/loader/loader.js +331 -716
  51. package/dist/melonjs.mjs/loader/loadingscreen.js +4 -4
  52. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  53. package/dist/melonjs.mjs/loader/parser.js +281 -0
  54. package/dist/melonjs.mjs/loader/settings.js +91 -0
  55. package/dist/melonjs.mjs/math/color.js +1 -1
  56. package/dist/melonjs.mjs/math/math.js +1 -1
  57. package/dist/melonjs.mjs/math/matrix2.js +7 -9
  58. package/dist/melonjs.mjs/math/matrix3.js +18 -21
  59. package/dist/melonjs.mjs/math/observable_vector2.js +3 -3
  60. package/dist/melonjs.mjs/math/observable_vector3.js +3 -4
  61. package/dist/melonjs.mjs/math/vector2.js +3 -3
  62. package/dist/melonjs.mjs/math/vector3.js +3 -4
  63. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
  64. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
  65. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
  66. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
  67. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  68. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  69. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  70. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  71. package/dist/melonjs.mjs/particles/emitter.js +3 -3
  72. package/dist/melonjs.mjs/particles/particle.js +1 -1
  73. package/dist/melonjs.mjs/particles/settings.js +1 -1
  74. package/dist/melonjs.mjs/physics/body.js +18 -14
  75. package/dist/melonjs.mjs/physics/bounds.js +18 -70
  76. package/dist/melonjs.mjs/physics/collision.js +1 -1
  77. package/dist/melonjs.mjs/physics/detector.js +1 -1
  78. package/dist/melonjs.mjs/physics/quadtree.js +1 -1
  79. package/dist/melonjs.mjs/physics/response.js +1 -1
  80. package/dist/melonjs.mjs/physics/sat.js +1 -1
  81. package/dist/melonjs.mjs/physics/world.js +1 -1
  82. package/dist/melonjs.mjs/plugin/plugin.js +3 -3
  83. package/dist/melonjs.mjs/renderable/collectable.js +1 -1
  84. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  85. package/dist/melonjs.mjs/renderable/container.js +25 -19
  86. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  87. package/dist/melonjs.mjs/renderable/imagelayer.js +7 -1
  88. package/dist/melonjs.mjs/renderable/light2d.js +1 -1
  89. package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
  90. package/dist/melonjs.mjs/renderable/renderable.js +126 -105
  91. package/dist/melonjs.mjs/renderable/sprite.js +33 -54
  92. package/dist/melonjs.mjs/renderable/trigger.js +1 -1
  93. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
  94. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
  95. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
  96. package/dist/melonjs.mjs/state/stage.js +1 -1
  97. package/dist/melonjs.mjs/state/state.js +2 -2
  98. package/dist/melonjs.mjs/system/device.js +1 -1
  99. package/dist/melonjs.mjs/system/dom.js +1 -1
  100. package/dist/melonjs.mjs/system/event.js +1 -1
  101. package/dist/melonjs.mjs/system/platform.js +1 -1
  102. package/dist/melonjs.mjs/system/pooling.js +8 -18
  103. package/dist/melonjs.mjs/system/save.js +1 -1
  104. package/dist/melonjs.mjs/system/timer.js +1 -1
  105. package/dist/melonjs.mjs/text/bitmaptext.js +66 -8
  106. package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
  107. package/dist/melonjs.mjs/text/glyph.js +1 -1
  108. package/dist/melonjs.mjs/text/text.js +1 -1
  109. package/dist/melonjs.mjs/text/textmetrics.js +1 -1
  110. package/dist/melonjs.mjs/text/textstyle.js +1 -1
  111. package/dist/melonjs.mjs/tweens/easing.js +1 -1
  112. package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
  113. package/dist/melonjs.mjs/tweens/tween.js +1 -1
  114. package/dist/melonjs.mjs/utils/agent.js +1 -1
  115. package/dist/melonjs.mjs/utils/array.js +1 -1
  116. package/dist/melonjs.mjs/utils/file.js +1 -1
  117. package/dist/melonjs.mjs/utils/function.js +1 -1
  118. package/dist/melonjs.mjs/utils/string.js +2 -2
  119. package/dist/melonjs.mjs/utils/utils.js +2 -4
  120. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +1 -1
  121. package/dist/melonjs.mjs/video/renderer.js +1 -1
  122. package/dist/melonjs.mjs/video/texture/atlas.js +10 -9
  123. package/dist/melonjs.mjs/video/texture/cache.js +3 -3
  124. package/dist/melonjs.mjs/video/texture/canvas_texture.js +1 -1
  125. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  126. package/dist/melonjs.mjs/video/video.js +2 -2
  127. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
  128. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +235 -0
  129. package/{src/video/webgl → dist/melonjs.mjs/video/webgl/compositors}/webgl_compositor.js +28 -205
  130. package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
  131. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  132. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  133. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  134. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  135. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  136. package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
  137. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  138. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  139. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  140. package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +2 -2
  141. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +2 -2
  142. package/dist/melonjs.module.js +17844 -17809
  143. package/dist/types/entity/entity.d.ts +2 -2
  144. package/dist/types/geometries/path2d.d.ts +5 -31
  145. package/dist/types/geometries/point.d.ts +2 -7
  146. package/dist/types/geometries/poly.d.ts +0 -1
  147. package/dist/types/index.d.ts +2 -2
  148. package/dist/types/loader/cache.d.ts +7 -0
  149. package/dist/types/loader/loader.d.ts +166 -181
  150. package/dist/types/loader/parser.d.ts +41 -0
  151. package/dist/types/loader/settings.d.ts +57 -0
  152. package/dist/types/particles/emitter.d.ts +4 -4
  153. package/dist/types/physics/bounds.d.ts +29 -84
  154. package/dist/types/renderable/container.d.ts +0 -11
  155. package/dist/types/renderable/renderable.d.ts +37 -31
  156. package/dist/types/renderable/sprite.d.ts +3 -3
  157. package/dist/types/state/state.d.ts +1 -1
  158. package/dist/types/system/pooling.d.ts +2 -2
  159. package/dist/types/video/renderer.d.ts +1 -1
  160. package/dist/types/video/webgl/compositors/compositor.d.ts +101 -0
  161. package/dist/types/video/webgl/compositors/webgl_compositor.d.ts +86 -0
  162. package/dist/types/video/webgl/webgl_compositor.d.ts +2 -3
  163. package/dist/types/video/webgl/webgl_renderer.d.ts +1 -1
  164. package/package.json +16 -15
  165. package/src/audio/audio.js +3 -3
  166. package/src/entity/entity.js +42 -8
  167. package/src/geometries/ellipse.js +1 -2
  168. package/src/geometries/path2d.js +17 -41
  169. package/src/geometries/point.js +0 -5
  170. package/src/geometries/poly.js +1 -4
  171. package/src/geometries/rectangle.js +12 -8
  172. package/src/index.js +2 -2
  173. package/src/input/gamepad.js +9 -15
  174. package/src/input/pointerevent.js +1 -15
  175. package/src/level/level.js +2 -2
  176. package/src/level/tiled/TMXLayer.js +0 -7
  177. package/src/level/tiled/TMXTileMap.js +7 -3
  178. package/src/level/tiled/TMXTileset.js +4 -4
  179. package/src/loader/cache.js +16 -0
  180. package/src/loader/loader.js +339 -711
  181. package/src/loader/loadingscreen.js +3 -3
  182. package/src/loader/parser.js +279 -0
  183. package/src/loader/settings.js +85 -0
  184. package/src/math/matrix2.js +6 -8
  185. package/src/math/matrix3.js +17 -20
  186. package/src/math/observable_vector2.js +2 -2
  187. package/src/math/observable_vector3.js +2 -3
  188. package/src/math/vector2.js +2 -2
  189. package/src/math/vector3.js +2 -3
  190. package/src/particles/emitter.js +2 -2
  191. package/src/physics/body.js +17 -13
  192. package/src/physics/bounds.js +17 -69
  193. package/src/renderable/container.js +24 -18
  194. package/src/renderable/imagelayer.js +6 -0
  195. package/src/renderable/renderable.js +125 -104
  196. package/src/renderable/sprite.js +32 -53
  197. package/src/state/state.js +1 -1
  198. package/src/system/pooling.js +7 -17
  199. package/src/text/bitmaptext.js +65 -7
  200. package/src/utils/string.js +1 -1
  201. package/src/utils/utils.js +1 -3
  202. package/src/video/texture/atlas.js +9 -8
  203. package/src/video/texture/cache.js +2 -2
  204. package/src/video/video.js +1 -1
  205. package/src/video/webgl/compositors/compositor.js +227 -0
  206. package/src/video/webgl/compositors/webgl_compositor.js +300 -0
  207. package/src/video/webgl/webgl_renderer.js +1 -1
@@ -78,13 +78,13 @@ export default class Entity extends Renderable {
78
78
  /** @ignore */
79
79
  update(dt: any): boolean;
80
80
  /**
81
- * update the bounds position when the body is modified
81
+ * update the bounds when the body is modified
82
82
  * @ignore
83
83
  * @name onBodyUpdate
84
84
  * @memberof Entity
85
85
  * @param {Body} body - the body whose bounds to update
86
86
  */
87
- onBodyUpdate(body: Body): void;
87
+ onBodyUpdate(): void;
88
88
  preDraw(renderer: any): void;
89
89
  /**
90
90
  * onDeactivateEvent Notification function<br>
@@ -5,55 +5,39 @@
5
5
  export default class Path2D {
6
6
  /**
7
7
  * the points defining the current path
8
- * @public
9
- * @type {Vector2d[]}
10
- * @name points
11
- * @memberof Path2D#
8
+ * @type {Point[]}
12
9
  */
13
- public points: Vector2d[];
10
+ points: Point[];
14
11
  /**
15
12
  * space between interpolated points for quadratic and bezier curve approx. in pixels.
16
- * @public
17
13
  * @type {number}
18
- * @name arcResolution
19
14
  * @default 5
20
- * @memberof Path2D#
21
15
  */
22
- public arcResolution: number;
16
+ arcResolution: number;
23
17
  vertices: any[];
24
18
  /**
25
19
  * begin a new path
26
- * @name beginPath
27
- * @memberof Path2D
28
20
  */
29
21
  beginPath(): void;
30
22
  /**
31
23
  * causes the point of the pen to move back to the start of the current path.
32
24
  * It tries to draw a straight line from the current point to the start.
33
25
  * If the shape has already been closed or has only one point, this function does nothing.
34
- * @name closePath
35
- * @memberof Path2D
36
26
  */
37
27
  closePath(): void;
38
28
  /**
39
29
  * triangulate the shape defined by this path into an array of triangles
40
- * @name triangulatePath
41
- * @memberof Path2D
42
- * @returns {Vector2d[]}
30
+ * @returns {Point[]}
43
31
  */
44
- triangulatePath(): Vector2d[];
32
+ triangulatePath(): Point[];
45
33
  /**
46
34
  * moves the starting point of the current path to the (x, y) coordinates.
47
- * @name moveTo
48
- * @memberof Path2D
49
35
  * @param {number} x - the x-axis (horizontal) coordinate of the point.
50
36
  * @param {number} y - the y-axis (vertical) coordinate of the point.
51
37
  */
52
38
  moveTo(x: number, y: number): void;
53
39
  /**
54
40
  * connects the last point in the current patch to the (x, y) coordinates with a straight line.
55
- * @name lineTo
56
- * @memberof Path2D
57
41
  * @param {number} x - the x-axis coordinate of the line's end point.
58
42
  * @param {number} y - the y-axis coordinate of the line's end point.
59
43
  */
@@ -61,8 +45,6 @@ export default class Path2D {
61
45
  /**
62
46
  * adds an arc to the current path which is centered at (x, y) position with the given radius,
63
47
  * starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to clockwise).
64
- * @name arc
65
- * @memberof Path2D
66
48
  * @param {number} x - the horizontal coordinate of the arc's center.
67
49
  * @param {number} y - the vertical coordinate of the arc's center.
68
50
  * @param {number} radius - the arc's radius. Must be positive.
@@ -73,8 +55,6 @@ export default class Path2D {
73
55
  arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined): void;
74
56
  /**
75
57
  * adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
76
- * @name arcTo
77
- * @memberof Path2D
78
58
  * @param {number} x1 - the x-axis coordinate of the first control point.
79
59
  * @param {number} y1 - the y-axis coordinate of the first control point.
80
60
  * @param {number} x2 - the x-axis coordinate of the second control point.
@@ -85,8 +65,6 @@ export default class Path2D {
85
65
  /**
86
66
  * adds an elliptical arc to the path which is centered at (x, y) position with the radii radiusX and radiusY
87
67
  * starting at startAngle and ending at endAngle going in the given direction by counterclockwise.
88
- * @name ellipse
89
- * @memberof Path2D
90
68
  * @param {number} x - the x-axis (horizontal) coordinate of the ellipse's center.
91
69
  * @param {number} y - the y-axis (vertical) coordinate of the ellipse's center.
92
70
  * @param {number} radiusX - the ellipse's major-axis radius. Must be non-negative.
@@ -99,8 +77,6 @@ export default class Path2D {
99
77
  ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined): void;
100
78
  /**
101
79
  * creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
102
- * @name rect
103
- * @memberof Path2D
104
80
  * @param {number} x - the x-axis coordinate of the rectangle's starting point.
105
81
  * @param {number} y - the y-axis coordinate of the rectangle's starting point.
106
82
  * @param {number} width - the rectangle's width. Positive values are to the right, and negative to the left.
@@ -109,8 +85,6 @@ export default class Path2D {
109
85
  rect(x: number, y: number, width: number, height: number): void;
110
86
  /**
111
87
  * adds an rounded rectangle to the current path.
112
- * @name roundRect
113
- * @memberof Path2D
114
88
  * @param {number} x - the x-axis coordinate of the rectangle's starting point.
115
89
  * @param {number} y - the y-axis coordinate of the rectangle's starting point.
116
90
  * @param {number} width - the rectangle's width. Positive values are to the right, and negative to the left.
@@ -6,18 +6,16 @@ export default class Point {
6
6
  constructor(x?: number, y?: number);
7
7
  /**
8
8
  * the position of the point on the horizontal axis
9
- * @public
10
9
  * @type {Number}
11
10
  * @default 0
12
11
  */
13
- public x: number;
12
+ x: number;
14
13
  /**
15
14
  * the position of the point on the vertical axis
16
- * @public
17
15
  * @type {Number}
18
16
  * @default 0
19
17
  */
20
- public y: number;
18
+ y: number;
21
19
  /** @ignore */
22
20
  onResetEvent(x?: number, y?: number): void;
23
21
  /**
@@ -37,8 +35,6 @@ export default class Point {
37
35
  */
38
36
  /**
39
37
  * return true if this point is equal to the given values
40
- * @name equals
41
- * @memberof Point
42
38
  * @param {number} x
43
39
  * @param {number} y
44
40
  * @returns {boolean}
@@ -46,7 +42,6 @@ export default class Point {
46
42
  equals(...args: any[]): boolean;
47
43
  /**
48
44
  * clone this Point
49
- * @name clone
50
45
  * @returns {Point} new Point
51
46
  */
52
47
  clone(): Point;
@@ -205,7 +205,6 @@ export default class Polygon {
205
205
  _bounds: object | undefined;
206
206
  /**
207
207
  * update the bounding box for this shape.
208
- * @ignore
209
208
  * @name updateBounds
210
209
  * @memberof Polygon
211
210
  * @returns {Bounds} this shape bounding box Rectangle object
@@ -36,7 +36,7 @@ import * as audio from "./audio/audio.js";
36
36
  import collision from "./physics/collision.js";
37
37
  import * as device from "./system/device.js";
38
38
  import * as event from "./system/event.js";
39
- import loader from "./loader/loader.js";
39
+ import * as loader from "./loader/loader.js";
40
40
  import level from "./level/level.js";
41
41
  import * as input from "./input/input.js";
42
42
  import * as Math from "./math/math.js";
@@ -64,7 +64,7 @@ import RoundRect from "./geometries/roundrect.js";
64
64
  import Tween from "./tweens/tween.js";
65
65
  import QuadTree from "./physics/quadtree.js";
66
66
  import GLShader from "./video/webgl/glshader.js";
67
- import WebGLCompositor from "./video/webgl/webgl_compositor.js";
67
+ import WebGLCompositor from "./video/webgl/compositors/webgl_compositor.js";
68
68
  import Renderer from "./video/renderer.js";
69
69
  import WebGLRenderer from "./video/webgl/webgl_renderer.js";
70
70
  import CanvasRenderer from "./video/canvas/canvas_renderer.js";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * where all preloaded content is cached
3
+ */
4
+ export let imgList: {};
5
+ export let tmxList: {};
6
+ export let binList: {};
7
+ export let jsonList: {};
@@ -1,181 +1,166 @@
1
- export default loader;
2
- declare namespace loader {
3
- const nocache: string;
4
- const onload: undefined;
5
- const onProgress: undefined;
6
- const crossOrigin: string;
7
- const withCredentials: boolean;
8
- /**
9
- * just increment the number of already loaded resources
10
- * @ignore
11
- */
12
- function onResourceLoaded(res: any): void;
13
- /**
14
- * on error callback for image loading
15
- * @ignore
16
- */
17
- function onLoadingError(res: any): never;
18
- /**
19
- * enable the nocache mechanism
20
- * @ignore
21
- */
22
- function setNocache(enable: any): void;
23
- /**
24
- * change the default baseURL for the given asset type.<br>
25
- * (this will prepend the asset URL and must finish with a '/')
26
- * @name setBaseURL
27
- * @memberof loader
28
- * @public
29
- * @param {string} type - "*", "audio", binary", "image", "json", "js", "tmx", "tsx"
30
- * @param {string} [url="./"] - default base URL
31
- * @example
32
- * // change the base URL relative address for audio assets
33
- * me.loader.setBaseURL("audio", "data/audio/");
34
- * // change the base URL absolute address for all object types
35
- * me.loader.setBaseURL("*", "http://myurl.com/")
36
- */
37
- function setBaseURL(type: string, url?: string | undefined): void;
38
- /**
39
- * set all the specified game resources to be preloaded.
40
- * @name preload
41
- * @memberof loader
42
- * @public
43
- * @param {object[]} res
44
- * @param {string} res.name - internal name of the resource
45
- * @param {string} res.type - "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
46
- * @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
47
- * @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
48
- * @param {Function} [onload=loader.onload] - function to be called when all resources are loaded
49
- * @param {boolean} [switchToLoadState=true] - automatically switch to the loading screen
50
- * @example
51
- * game_resources = [
52
- * // PNG tileset
53
- * {name: "tileset-platformer", type: "image", src: "data/map/tileset.png"},
54
- * // PNG packed texture
55
- * {name: "texture", type:"image", src: "data/gfx/texture.png"}
56
- * // PNG base64 encoded image
57
- * {name: "texture", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."}
58
- * // TSX file
59
- * {name: "meta_tiles", type: "tsx", src: "data/map/meta_tiles.tsx"},
60
- * // TMX level (XML & JSON)
61
- * {name: "map1", type: "tmx", src: "data/map/map1.json"},
62
- * {name: "map2", type: "tmx", src: "data/map/map2.tmx"},
63
- * {name: "map3", type: "tmx", format: "json", data: {"height":15,"layers":[...],"tilewidth":32,"version":1,"width":20}},
64
- * {name: "map4", type: "tmx", format: "xml", data: {xml representation of tmx}},
65
- * // audio resources
66
- * {name: "bgmusic", type: "audio", src: "data/audio/"},
67
- * {name: "cling", type: "audio", src: "data/audio/"},
68
- * // base64 encoded audio resources
69
- * {name: "band", type: "audio", src: "data:audio/wav;base64,..."},
70
- * // binary file
71
- * {name: "ymTrack", type: "binary", src: "data/audio/main.ym"},
72
- * // JSON file (used for texturePacker)
73
- * {name: "texture", type: "json", src: "data/gfx/texture.json"},
74
- * // JavaScript file
75
- * {name: "plugin", type: "js", src: "data/js/plugin.js"},
76
- * // Font Face
77
- * { name: "'kenpixel'", type: "fontface", src: "url('data/font/kenvector_future.woff2')" }
78
- * ];
79
- * ...
80
- * // set all resources to be loaded
81
- * me.loader.preload(game.resources, this.loaded.bind(this));
82
- */
83
- function preload(res: {
84
- name: string;
85
- type: string;
86
- src: string;
87
- stream?: boolean | undefined;
88
- }[], onload?: Function | undefined, switchToLoadState?: boolean | undefined): void;
89
- /**
90
- * Load a single resource (to be used if you need to load additional resource during the game)
91
- * @name load
92
- * @memberof loader
93
- * @public
94
- * @param {object} res
95
- * @param {string} res.name - internal name of the resource
96
- * @param {string} res.type - "audio", binary", "image", "json", "tmx", "tsx"
97
- * @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
98
- * @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
99
- * @param {Function} [onload] - function to be called when the resource is loaded
100
- * @param {Function} [onerror] - function to be called in case of error
101
- * @returns {number} the amount of corresponding resource to be preloaded
102
- * @example
103
- * // load an image asset
104
- * me.loader.load({name: "avatar", type:"image", src: "data/avatar.png"}, this.onload.bind(this), this.onerror.bind(this));
105
- * // load a base64 image asset
106
- * me.loader.load({name: "avatar", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."};
107
- * // start loading music
108
- * me.loader.load({
109
- * name : "bgmusic",
110
- * type : "audio",
111
- * src : "data/audio/"
112
- * }, function () {
113
- * me.audio.play("bgmusic");
114
- * });
115
- */
116
- function load(res: {
117
- name: string;
118
- type: string;
119
- src: string;
120
- stream?: boolean | undefined;
121
- }, onload?: Function | undefined, onerror?: Function | undefined): number;
122
- /**
123
- * unload specified resource to free memory
124
- * @name unload
125
- * @memberof loader
126
- * @public
127
- * @param {object} res
128
- * @param {string} res.name - internal name of the resource
129
- * @param {string} res.type - "audio", binary", "image", "json", "tmx", "tsx"
130
- * @returns {boolean} true if unloaded
131
- * @example me.loader.unload({name: "avatar", type:"image"});
132
- */
133
- function unload(res: {
134
- name: string;
135
- type: string;
136
- }): boolean;
137
- /**
138
- * unload all resources to free memory
139
- * @name unloadAll
140
- * @memberof loader
141
- * @public
142
- * @example me.loader.unloadAll();
143
- */
144
- function unloadAll(): void;
145
- /**
146
- * return the specified TMX/TSX object
147
- * @name getTMX
148
- * @memberof loader
149
- * @public
150
- * @param {string} elt - name of the tmx/tsx element ("map1");
151
- * @returns {object} requested element or null if not found
152
- */
153
- function getTMX(elt: string): object;
154
- /**
155
- * return the specified Binary object
156
- * @name getBinary
157
- * @memberof loader
158
- * @public
159
- * @param {string} elt - name of the binary object ("ymTrack");
160
- * @returns {object} requested element or null if not found
161
- */
162
- function getBinary(elt: string): object;
163
- /**
164
- * return the specified Image Object
165
- * @name getImage
166
- * @memberof loader
167
- * @public
168
- * @param {string} image - name of the Image element ("tileset-platformer");
169
- * @returns {HTMLImageElement} requested element or null if not found
170
- */
171
- function getImage(image: string): HTMLImageElement;
172
- /**
173
- * return the specified JSON Object
174
- * @name getJSON
175
- * @memberof loader
176
- * @public
177
- * @param {string} elt - name of the json file to load
178
- * @returns {object}
179
- */
180
- function getJSON(elt: string): object;
181
- }
1
+ /**
2
+ * set all the specified game resources to be preloaded.
3
+ * @name preload
4
+ * @memberof loader
5
+ * @public
6
+ * @param {object[]} res
7
+ * @param {string} res.name - internal name of the resource
8
+ * @param {string} res.type - "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
9
+ * @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
10
+ * @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
11
+ * @param {Function} [onload=loader.onload] - function to be called when all resources are loaded
12
+ * @param {boolean} [switchToLoadState=true] - automatically switch to the loading screen
13
+ * @example
14
+ * game_resources = [
15
+ * // PNG tileset
16
+ * {name: "tileset-platformer", type: "image", src: "data/map/tileset.png"},
17
+ * // PNG packed texture
18
+ * {name: "texture", type:"image", src: "data/gfx/texture.png"}
19
+ * // PNG base64 encoded image
20
+ * {name: "texture", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."}
21
+ * // TSX file
22
+ * {name: "meta_tiles", type: "tsx", src: "data/map/meta_tiles.tsx"},
23
+ * // TMX level (XML & JSON)
24
+ * {name: "map1", type: "tmx", src: "data/map/map1.json"},
25
+ * {name: "map2", type: "tmx", src: "data/map/map2.tmx"},
26
+ * {name: "map3", type: "tmx", format: "json", data: {"height":15,"layers":[...],"tilewidth":32,"version":1,"width":20}},
27
+ * {name: "map4", type: "tmx", format: "xml", data: {xml representation of tmx}},
28
+ * // audio resources
29
+ * {name: "bgmusic", type: "audio", src: "data/audio/"},
30
+ * {name: "cling", type: "audio", src: "data/audio/"},
31
+ * // base64 encoded audio resources
32
+ * {name: "band", type: "audio", src: "data:audio/wav;base64,..."},
33
+ * // binary file
34
+ * {name: "ymTrack", type: "binary", src: "data/audio/main.ym"},
35
+ * // JSON file (used for texturePacker)
36
+ * {name: "texture", type: "json", src: "data/gfx/texture.json"},
37
+ * // JavaScript file
38
+ * {name: "plugin", type: "js", src: "data/js/plugin.js"},
39
+ * // Font Face
40
+ * { name: "'kenpixel'", type: "fontface", src: "url('data/font/kenvector_future.woff2')" }
41
+ * ];
42
+ * ...
43
+ * // set all resources to be loaded
44
+ * me.loader.preload(game.resources, this.loaded.bind(this));
45
+ */
46
+ export function preload(res: {
47
+ name: string;
48
+ type: string;
49
+ src: string;
50
+ stream?: boolean;
51
+ }, onloadcb: any, switchToLoadState?: boolean | undefined): void;
52
+ /**
53
+ * Load a single resource (to be used if you need to load additional resource during the game)
54
+ * @name load
55
+ * @memberof loader
56
+ * @public
57
+ * @param {object} res
58
+ * @param {string} res.name - internal name of the resource
59
+ * @param {string} res.type - "audio", binary", "image", "json", "tmx", "tsx"
60
+ * @param {string} res.src - path and/or file name of the resource (for audio assets only the path is required)
61
+ * @param {boolean} [res.stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
62
+ * @param {Function} [onload] - function to be called when the resource is loaded
63
+ * @param {Function} [onerror] - function to be called in case of error
64
+ * @returns {number} the amount of corresponding resource to be preloaded
65
+ * @example
66
+ * // load an image asset
67
+ * me.loader.load({name: "avatar", type:"image", src: "data/avatar.png"}, this.onload.bind(this), this.onerror.bind(this));
68
+ * // load a base64 image asset
69
+ * me.loader.load({name: "avatar", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."};
70
+ * // start loading music
71
+ * me.loader.load({
72
+ * name : "bgmusic",
73
+ * type : "audio",
74
+ * src : "data/audio/"
75
+ * }, function () {
76
+ * me.audio.play("bgmusic");
77
+ * });
78
+ */
79
+ export function load(res: {
80
+ name: string;
81
+ type: string;
82
+ src: string;
83
+ stream?: boolean | undefined;
84
+ }, onload?: Function | undefined, onerror?: Function | undefined): number;
85
+ /**
86
+ * unload specified resource to free memory
87
+ * @name unload
88
+ * @memberof loader
89
+ * @public
90
+ * @param {object} res
91
+ * @param {string} res.name - internal name of the resource
92
+ * @param {string} res.type - "audio", binary", "image", "json", "tmx", "tsx"
93
+ * @returns {boolean} true if unloaded
94
+ * @example me.loader.unload({name: "avatar", type:"image"});
95
+ */
96
+ export function unload(res: {
97
+ name: string;
98
+ type: string;
99
+ }): boolean;
100
+ /**
101
+ * unload all resources to free memory
102
+ * @name unloadAll
103
+ * @memberof loader
104
+ * @public
105
+ * @example me.loader.unloadAll();
106
+ */
107
+ export function unloadAll(): void;
108
+ /**
109
+ * return the specified TMX/TSX object
110
+ * @name getTMX
111
+ * @memberof loader
112
+ * @public
113
+ * @param {string} elt - name of the tmx/tsx element ("map1");
114
+ * @returns {object} requested element or null if not found
115
+ */
116
+ export function getTMX(elt: string): object;
117
+ /**
118
+ * return the specified Binary object
119
+ * @name getBinary
120
+ * @memberof loader
121
+ * @public
122
+ * @param {string} elt - name of the binary object ("ymTrack");
123
+ * @returns {object} requested element or null if not found
124
+ */
125
+ export function getBinary(elt: string): object;
126
+ /**
127
+ * return the specified Image Object
128
+ * @name getImage
129
+ * @memberof loader
130
+ * @public
131
+ * @param {string} image - name of the Image element ("tileset-platformer");
132
+ * @returns {HTMLImageElement} requested element or null if not found
133
+ */
134
+ export function getImage(image: string): HTMLImageElement;
135
+ /**
136
+ * return the specified JSON Object
137
+ * @name getJSON
138
+ * @memberof loader
139
+ * @public
140
+ * @param {string} elt - name of the json file to load
141
+ * @returns {object}
142
+ */
143
+ export function getJSON(elt: string): object;
144
+ export * from "./settings.js";
145
+ /**
146
+ * onload callback
147
+ * @name onload
148
+ * @default undefined
149
+ * @memberof loader
150
+ * @example
151
+ * // set a callback when everything is loaded
152
+ * me.loader.onload = this.loaded.bind(this);
153
+ */
154
+ export let onload: any;
155
+ /**
156
+ * onProgress callback<br>
157
+ * each time a resource is loaded, the loader will fire the specified function,
158
+ * giving the actual progress [0 ... 1], as argument, and an object describing the resource loaded
159
+ * @name onProgress
160
+ * @default undefined
161
+ * @memberof loader
162
+ * @example
163
+ * // set a callback for progress notification
164
+ * me.loader.onProgress = this.updateProgress.bind(this);
165
+ */
166
+ export let onProgress: any;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * load Images
3
+ * @example
4
+ * preloadImages([
5
+ * { name : 'image1', src : 'images/image1.png'},
6
+ * { name : 'image2', src : 'images/image2.png'},
7
+ * { name : 'image3', src : 'images/image3.png'},
8
+ * { name : 'image4', src : 'images/image4.png'}
9
+ * ]);
10
+ * @ignore
11
+ */
12
+ export function preloadImage(img: any, onload: any, onerror: any): void;
13
+ /**
14
+ * load a font face
15
+ * @example
16
+ * preloadFontFace(
17
+ * name: "'kenpixel'", type: "fontface", src: "url('data/font/kenvector_future.woff2')"
18
+ * ]);
19
+ * @ignore
20
+ */
21
+ export function preloadFontFace(data: any, onload: any, onerror: any): void;
22
+ /**
23
+ * preload TMX files
24
+ * @ignore
25
+ */
26
+ export function preloadTMX(tmxData: any, onload: any, onerror: any): void;
27
+ /**
28
+ * preload JSON files
29
+ * @ignore
30
+ */
31
+ export function preloadJSON(data: any, onload: any, onerror: any): void;
32
+ /**
33
+ * preload Binary files
34
+ * @ignore
35
+ */
36
+ export function preloadBinary(data: any, onload: any, onerror: any): void;
37
+ /**
38
+ * preload Binary files
39
+ * @ignore
40
+ */
41
+ export function preloadJavascript(data: any, onload: any, onerror: any): void;