melonjs 10.4.0 → 10.5.2

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.
@@ -142,6 +142,10 @@ export class BitmapText extends Renderable {
142
142
  * @returns {TextMetrics} a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
143
143
  */
144
144
  measureText(text?: string, ret?: Rect): TextMetrics;
145
+ /**
146
+ * @ignore
147
+ */
148
+ update(): boolean;
145
149
  /**
146
150
  * draw the bitmap font
147
151
  * @name draw
@@ -266,7 +270,8 @@ export class Body {
266
270
  public mass: number;
267
271
  maxVel: Vector2d;
268
272
  /**
269
- * either this body is a static body or not
273
+ * Either this body is a static body or not.
274
+ * A static body is completely fixed and can never change position or angle.
270
275
  * @readonly
271
276
  * @public
272
277
  * @type {boolean}
@@ -2064,17 +2069,6 @@ export class Container extends Renderable {
2064
2069
  * @ignore
2065
2070
  */
2066
2071
  _sortY(a: any, b: any): number;
2067
- /**
2068
- * container update function. <br>
2069
- * automatically called by the game manager {@link game}
2070
- * @name update
2071
- * @memberof Container.prototype
2072
- * @function
2073
- * @protected
2074
- * @param {number} dt time since the last update in milliseconds.
2075
- * @returns {boolean} true if the Container is dirty
2076
- */
2077
- protected update(dt: number): boolean;
2078
2072
  /**
2079
2073
  * draw the container. <br>
2080
2074
  * automatically called by the game manager {@link game}
@@ -2089,21 +2083,14 @@ export class Container extends Renderable {
2089
2083
  }
2090
2084
  /**
2091
2085
  * @classdesc
2092
- * Used to make a game entity draggable
2093
- * @augments Entity
2086
+ * A Draggable base object
2087
+ * @see DropTarget
2088
+ * @augments Renderable
2094
2089
  */
2095
- export class DraggableEntity extends Entity {
2096
- /**
2097
- * @param {number} x the x coordinates of the entity object
2098
- * @param {number} y the y coordinates of the entity object
2099
- * @param {object} settings Entity properties (see {@link Entity})
2100
- */
2101
- constructor(x: number, y: number, settings: object);
2090
+ export class Draggable extends Renderable {
2102
2091
  dragging: boolean;
2103
2092
  dragId: any;
2104
2093
  grabOffset: Vector2d;
2105
- onPointerEvent: typeof registerPointerEvent;
2106
- removePointerEvent: typeof releasePointerEvent;
2107
2094
  /**
2108
2095
  * Initializes the events the modules needs to listen to
2109
2096
  * It translates the pointer events to me.events
@@ -2111,31 +2098,15 @@ export class DraggableEntity extends Entity {
2111
2098
  * this module testable. Then we subscribe this module to the
2112
2099
  * transformed events.
2113
2100
  * @name initEvents
2114
- * @memberof DraggableEntity
2101
+ * @memberof Draggable
2115
2102
  * @function
2103
+ * @private
2116
2104
  */
2117
- initEvents(): void;
2118
- /**
2119
- * @ignore
2120
- */
2121
- mouseDown: (e: any) => void;
2122
- /**
2123
- * @ignore
2124
- */
2125
- mouseUp: (e: any) => void;
2126
- /**
2127
- * Translates a pointer event to a me.event
2128
- * @name translatePointerEvent
2129
- * @memberof DraggableEntity
2130
- * @function
2131
- * @param {object} e the pointer event you want to translate
2132
- * @param {string} translation the me.event you want to translate the event to
2133
- */
2134
- translatePointerEvent(e: object, translation: string): void;
2105
+ private initEvents;
2135
2106
  /**
2136
2107
  * Gets called when the user starts dragging the entity
2137
2108
  * @name dragStart
2138
- * @memberof DraggableEntity
2109
+ * @memberof Draggable
2139
2110
  * @function
2140
2111
  * @param {object} e the pointer event
2141
2112
  * @returns {boolean} false if the object is being dragged
@@ -2144,7 +2115,7 @@ export class DraggableEntity extends Entity {
2144
2115
  /**
2145
2116
  * Gets called when the user drags this entity around
2146
2117
  * @name dragMove
2147
- * @memberof DraggableEntity
2118
+ * @memberof Draggable
2148
2119
  * @function
2149
2120
  * @param {object} e the pointer event
2150
2121
  */
@@ -2152,7 +2123,7 @@ export class DraggableEntity extends Entity {
2152
2123
  /**
2153
2124
  * Gets called when the user stops dragging the entity
2154
2125
  * @name dragEnd
2155
- * @memberof DraggableEntity
2126
+ * @memberof Draggable
2156
2127
  * @function
2157
2128
  * @returns {boolean} false if the object stopped being dragged
2158
2129
  */
@@ -2160,30 +2131,41 @@ export class DraggableEntity extends Entity {
2160
2131
  /**
2161
2132
  * Destructor
2162
2133
  * @name destroy
2163
- * @memberof DraggableEntity
2134
+ * @memberof Draggable
2164
2135
  * @function
2136
+ * @ignore
2165
2137
  */
2166
2138
  destroy(): void;
2167
2139
  }
2168
2140
  /**
2169
2141
  * @classdesc
2170
- * Used to make a game entity a droptarget
2142
+ * Used to make a game entity draggable
2171
2143
  * @augments Entity
2144
+ * @deprecated since 10.5.0
2145
+ * @see Draggable
2172
2146
  */
2173
- export class DroptargetEntity extends Entity {
2147
+ export class DraggableEntity extends Entity {
2174
2148
  /**
2175
- * @param {number} x the x coordinates of the entity object
2176
- * @param {number} y the y coordinates of the entity object
2149
+ * @param {number} x the x coordinates of the draggable object
2150
+ * @param {number} y the y coordinates of the draggable object
2177
2151
  * @param {object} settings Entity properties (see {@link Entity})
2178
2152
  */
2179
2153
  constructor(x: number, y: number, settings: object);
2154
+ }
2155
+ /**
2156
+ * @classdesc
2157
+ * a base drop target object
2158
+ * @see Draggable
2159
+ * @augments Renderable
2160
+ */
2161
+ export class DropTarget extends Renderable {
2180
2162
  /**
2181
2163
  * constant for the overlaps method
2182
2164
  * @public
2183
2165
  * @constant
2184
2166
  * @type {string}
2185
2167
  * @name CHECKMETHOD_OVERLAP
2186
- * @memberof DroptargetEntity
2168
+ * @memberof DropTarget
2187
2169
  */
2188
2170
  public CHECKMETHOD_OVERLAP: string;
2189
2171
  /**
@@ -2192,7 +2174,7 @@ export class DroptargetEntity extends Entity {
2192
2174
  * @constant
2193
2175
  * @type {string}
2194
2176
  * @name CHECKMETHOD_CONTAINS
2195
- * @memberof DroptargetEntity
2177
+ * @memberof DropTarget
2196
2178
  */
2197
2179
  public CHECKMETHOD_CONTAINS: string;
2198
2180
  /**
@@ -2201,13 +2183,14 @@ export class DroptargetEntity extends Entity {
2201
2183
  * @constant
2202
2184
  * @type {string}
2203
2185
  * @name checkMethod
2204
- * @memberof DroptargetEntity
2186
+ * @default "overlaps"
2187
+ * @memberof DropTarget
2205
2188
  */
2206
2189
  public checkMethod: string;
2207
2190
  /**
2208
2191
  * Sets the collision method which is going to be used to check a valid drop
2209
2192
  * @name setCheckMethod
2210
- * @memberof DroptargetEntity
2193
+ * @memberof DropTarget
2211
2194
  * @function
2212
2195
  * @param {string} checkMethod the checkmethod (defaults to CHECKMETHOD_OVERLAP)
2213
2196
  */
@@ -2215,28 +2198,44 @@ export class DroptargetEntity extends Entity {
2215
2198
  /**
2216
2199
  * Checks if a dropped entity is dropped on the current entity
2217
2200
  * @name checkOnMe
2218
- * @memberof DroptargetEntity
2201
+ * @memberof DropTarget
2219
2202
  * @function
2220
2203
  * @param {object} e the triggering event
2221
- * @param {object} draggableEntity the draggable entity that is dropped
2204
+ * @param {Draggable} draggable the draggable object that is dropped
2222
2205
  */
2223
- checkOnMe(e: object, draggableEntity: object): void;
2206
+ checkOnMe(e: object, draggable: Draggable): void;
2224
2207
  /**
2225
2208
  * Gets called when a draggable entity is dropped on the current entity
2226
2209
  * @name drop
2227
- * @memberof DroptargetEntity
2210
+ * @memberof DropTarget
2228
2211
  * @function
2229
- * @param {object} draggableEntity the draggable entity that is dropped
2212
+ * @param {Draggable} draggable the draggable object that is dropped
2230
2213
  */
2231
2214
  drop(): void;
2232
2215
  /**
2233
2216
  * Destructor
2234
2217
  * @name destroy
2235
- * @memberof DroptargetEntity
2218
+ * @memberof DropTarget
2236
2219
  * @function
2220
+ * @ignore
2237
2221
  */
2238
2222
  destroy(): void;
2239
2223
  }
2224
+ /**
2225
+ * @classdesc
2226
+ * Used to make a game entity a droptarget
2227
+ * @augments Entity
2228
+ * @deprecated since 10.5.0
2229
+ * @see DropTarget
2230
+ */
2231
+ export class DroptargetEntity extends Entity {
2232
+ /**
2233
+ * @param {number} x the x coordinates of the draggable object
2234
+ * @param {number} y the y coordinates of the draggable object
2235
+ * @param {object} settings Entity properties (see {@link Entity})
2236
+ */
2237
+ constructor(x: number, y: number, settings: object);
2238
+ }
2240
2239
  /**
2241
2240
  * @classdesc
2242
2241
  * an ellipse Object
@@ -2873,16 +2872,6 @@ export class ImageLayer extends Renderable {
2873
2872
  * @ignore
2874
2873
  */
2875
2874
  preDraw(renderer: any): void;
2876
- /**
2877
- * draw the ImageLayer. <br>
2878
- * automatically called by the game manager {@link game}
2879
- * @name draw
2880
- * @memberof ImageLayer.prototype
2881
- * @function
2882
- * @protected
2883
- * @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
2884
- */
2885
- protected draw(renderer: CanvasRenderer | WebGLRenderer): void;
2886
2875
  onDeactivateEvent(): void;
2887
2876
  /**
2888
2877
  * Destroy function<br>
@@ -4093,16 +4082,6 @@ export class Particle extends Renderable {
4093
4082
  onlyInViewport: any;
4094
4083
  _deltaInv: number;
4095
4084
  angle: number;
4096
- /**
4097
- * Update the Particle <br>
4098
- * This is automatically called by the game manager {@link game}
4099
- * @name update
4100
- * @memberof Particle
4101
- * @function
4102
- * @ignore
4103
- * @param {number} dt time since the last update in milliseconds
4104
- */
4105
- update(dt: number): boolean;
4106
4085
  /**
4107
4086
  * @ignore
4108
4087
  */
@@ -5459,7 +5438,7 @@ export class Renderable extends Rect {
5459
5438
  * @param {number} dt time since the last update in milliseconds.
5460
5439
  * @returns {boolean} true if the renderable is dirty
5461
5440
  */
5462
- protected update(): boolean;
5441
+ protected update(dt: number): boolean;
5463
5442
  /**
5464
5443
  * update the renderable's bounding rect (private)
5465
5444
  * @ignore
@@ -5507,7 +5486,7 @@ export class Renderable extends Rect {
5507
5486
  * @protected
5508
5487
  * @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
5509
5488
  */
5510
- protected draw(): void;
5489
+ protected draw(renderer: CanvasRenderer | WebGLRenderer): void;
5511
5490
  /**
5512
5491
  * restore the rendering context after drawing. <br>
5513
5492
  * automatically called by the game manager {@link game}
@@ -6097,32 +6076,11 @@ export class Sprite extends Renderable {
6097
6076
  * @returns {number} if using number indices. Returns {object} containing frame data if using texture atlas
6098
6077
  */
6099
6078
  getAnimationFrameObjectByIndex(id: number): number;
6100
- /**
6101
- * update function. <br>
6102
- * automatically called by the game manager {@link game}
6103
- * @name update
6104
- * @memberof Sprite.prototype
6105
- * @function
6106
- * @protected
6107
- * @param {number} dt time since the last update in milliseconds.
6108
- * @returns {boolean} true if the Sprite is dirty
6109
- */
6110
- protected update(dt: number): boolean;
6111
6079
  /**
6112
6080
  * Destroy function<br>
6113
6081
  * @ignore
6114
6082
  */
6115
6083
  destroy(): void;
6116
- /**
6117
- * sprite draw. <br>
6118
- * automatically called by the game manager {@link game}
6119
- * @name draw
6120
- * @memberof Sprite.prototype
6121
- * @function
6122
- * @protected
6123
- * @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
6124
- */
6125
- protected draw(renderer: CanvasRenderer | WebGLRenderer): void;
6126
6084
  }
6127
6085
  /**
6128
6086
  * @classdesc
@@ -7090,6 +7048,10 @@ export class Text extends Renderable {
7090
7048
  * @returns {TextMetrics} a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
7091
7049
  */
7092
7050
  measureText(renderer?: CanvasRenderer | WebGLRenderer, text?: string, ret?: Rect | Bounds): TextMetrics;
7051
+ /**
7052
+ * @ignore
7053
+ */
7054
+ update(): boolean;
7093
7055
  /**
7094
7056
  * draw a text at the specified coord
7095
7057
  * @name draw
@@ -8510,6 +8472,14 @@ export class WebGLCompositor {
8510
8472
  * @ignore
8511
8473
  */
8512
8474
  uploadTexture(texture: any, w: any, h: any, b: any, force?: boolean): any;
8475
+ /**
8476
+ * set/change the current projection matrix
8477
+ * @name setProjection
8478
+ * @memberof WebGLCompositor
8479
+ * @function
8480
+ * @param {Matrix3d} matrix
8481
+ */
8482
+ setProjection(matrix: Matrix3d): void;
8513
8483
  /**
8514
8484
  * Select the shader to use for compositing
8515
8485
  * @name useShader
@@ -9187,10 +9157,6 @@ export function boot(): void;
9187
9157
  * @namespace collision
9188
9158
  */
9189
9159
  export var collision: any;
9190
- export var deprecated: Readonly<{
9191
- __proto__: any;
9192
- warning: typeof warning;
9193
- }>;
9194
9160
  declare namespace device$1 {
9195
9161
  namespace turnOnPointerLock { }
9196
9162
  namespace turnOffPointerLock { }
@@ -10969,6 +10935,17 @@ export var video: Readonly<{
10969
10935
  getParent: typeof getParent;
10970
10936
  scale: typeof scale;
10971
10937
  }>;
10938
+ /**
10939
+ * placeholder for all deprecated classes and corresponding alias for backward compatibility
10940
+ */
10941
+ /**
10942
+ * display a deprecation warning in the console
10943
+ * @ignore
10944
+ * @param {string} deprecated deprecated class,function or property name
10945
+ * @param {string} replacement the replacement class, function, or property name
10946
+ * @param {string} version the version since when the lass,function or property is deprecated
10947
+ */
10948
+ export function warning(deprecated: string, replacement: string, version: string): void;
10972
10949
  /**
10973
10950
  * @classdesc
10974
10951
  * a bound object contains methods for creating and manipulating axis-aligned bounding boxes (AABB).
@@ -11241,7 +11218,7 @@ declare class TextureCache {
11241
11218
  * @ignore
11242
11219
  */
11243
11220
  constructor(max_size: any);
11244
- cache: Map<any, any>;
11221
+ cache: any;
11245
11222
  tinted: Map<any, any>;
11246
11223
  units: Map<any, any>;
11247
11224
  max_size: any;
@@ -11269,67 +11246,12 @@ declare class TextureCache {
11269
11246
  /**
11270
11247
  * @ignore
11271
11248
  */
11272
- set(image: any, texture: any): void;
11249
+ set(image: any, texture: any): any;
11273
11250
  /**
11274
11251
  * @ignore
11275
11252
  */
11276
11253
  getUnit(texture: any): any;
11277
11254
  }
11278
- /**
11279
- * allows registration of event listeners on the object target. <br>
11280
- * melonJS will pass a me.Pointer object to the defined callback.
11281
- * @see Pointer
11282
- * @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list}
11283
- * @name registerPointerEvent
11284
- * @memberof input
11285
- * @public
11286
- * @function
11287
- * @param {string} eventType The event type for which the object is registering <br>
11288
- * melonJS currently supports: <br>
11289
- * <ul>
11290
- * <li><code>"pointermove"</code></li>
11291
- * <li><code>"pointerdown"</code></li>
11292
- * <li><code>"pointerup"</code></li>
11293
- * <li><code>"pointerenter"</code></li>
11294
- * <li><code>"pointerover"</code></li>
11295
- * <li><code>"pointerleave"</code></li>
11296
- * <li><code>"pointercancel"</code></li>
11297
- * <li><code>"wheel"</code></li>
11298
- * </ul>
11299
- * @param {Rect|Polygon|Line|Ellipse} region a shape representing the region to register on
11300
- * @param {Function} callback methods to be called when the event occurs.
11301
- * Returning `false` from the defined callback will prevent the event to be propagated to other objects
11302
- * @example
11303
- * // onActivate function
11304
- * onActivateEvent: function () {
11305
- * // register on the 'pointerdown' event
11306
- * me.input.registerPointerEvent('pointerdown', this, this.pointerDown.bind(this));
11307
- * },
11308
- *
11309
- * // pointerDown event callback
11310
- * pointerDown: function (pointer) {
11311
- * // do something
11312
- * ....
11313
- * // don"t propagate the event to other objects
11314
- * return false;
11315
- * },
11316
- */
11317
- declare function registerPointerEvent(eventType: string, region: Rect | Polygon | Line | Ellipse, callback: Function): void;
11318
- /**
11319
- * allows the removal of event listeners from the object target.
11320
- * @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list}
11321
- * @name releasePointerEvent
11322
- * @memberof input
11323
- * @public
11324
- * @function
11325
- * @param {string} eventType The event type for which the object was registered. See {@link input.registerPointerEvent}
11326
- * @param {Rect|Polygon|Line|Ellipse} region the registered region to release for this event
11327
- * @param {Function} [callback="all"] if specified unregister the event only for the specific callback
11328
- * @example
11329
- * // release the registered region on the 'pointerdown' event
11330
- * me.input.releasePointerEvent('pointerdown', this);
11331
- */
11332
- declare function releasePointerEvent(eventType: string, region: Rect | Polygon | Line | Ellipse, callback?: Function): void;
11333
11255
  /**
11334
11256
  * returns true if the given value is a power of two
11335
11257
  * @public
@@ -11799,17 +11721,6 @@ declare function unload(sound_name: string): boolean;
11799
11721
  * me.audio.unloadAll();
11800
11722
  */
11801
11723
  declare function unloadAll(): void;
11802
- /**
11803
- * placeholder for all deprecated classes and corresponding alias for backward compatibility
11804
- */
11805
- /**
11806
- * display a deprecation warning in the console
11807
- * @ignore
11808
- * @param {string} deprecated deprecated class,function or property name
11809
- * @param {string} replacement the replacement class, function, or property name
11810
- * @param {string} version the version since when the lass,function or property is deprecated
11811
- */
11812
- declare function warning(deprecated: string, replacement: string, version: string): void;
11813
11724
  /**
11814
11725
  * calls each of the listeners registered for a given event.
11815
11726
  * @function event.emit
@@ -11966,6 +11877,61 @@ declare function bindPointer(...args: any[]): void;
11966
11877
  * me.input.unbindPointer(me.input.pointer.LEFT);
11967
11878
  */
11968
11879
  declare function unbindPointer(button?: number): void;
11880
+ /**
11881
+ * allows registration of event listeners on the object target. <br>
11882
+ * melonJS will pass a me.Pointer object to the defined callback.
11883
+ * @see Pointer
11884
+ * @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list}
11885
+ * @name registerPointerEvent
11886
+ * @memberof input
11887
+ * @public
11888
+ * @function
11889
+ * @param {string} eventType The event type for which the object is registering <br>
11890
+ * melonJS currently supports: <br>
11891
+ * <ul>
11892
+ * <li><code>"pointermove"</code></li>
11893
+ * <li><code>"pointerdown"</code></li>
11894
+ * <li><code>"pointerup"</code></li>
11895
+ * <li><code>"pointerenter"</code></li>
11896
+ * <li><code>"pointerover"</code></li>
11897
+ * <li><code>"pointerleave"</code></li>
11898
+ * <li><code>"pointercancel"</code></li>
11899
+ * <li><code>"wheel"</code></li>
11900
+ * </ul>
11901
+ * @param {Rect|Polygon|Line|Ellipse} region a shape representing the region to register on
11902
+ * @param {Function} callback methods to be called when the event occurs.
11903
+ * Returning `false` from the defined callback will prevent the event to be propagated to other objects
11904
+ * @example
11905
+ * // onActivate function
11906
+ * onActivateEvent: function () {
11907
+ * // register on the 'pointerdown' event
11908
+ * me.input.registerPointerEvent('pointerdown', this, this.pointerDown.bind(this));
11909
+ * },
11910
+ *
11911
+ * // pointerDown event callback
11912
+ * pointerDown: function (pointer) {
11913
+ * // do something
11914
+ * ....
11915
+ * // don"t propagate the event to other objects
11916
+ * return false;
11917
+ * },
11918
+ */
11919
+ declare function registerPointerEvent(eventType: string, region: Rect | Polygon | Line | Ellipse, callback: Function): void;
11920
+ /**
11921
+ * allows the removal of event listeners from the object target.
11922
+ * @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list}
11923
+ * @name releasePointerEvent
11924
+ * @memberof input
11925
+ * @public
11926
+ * @function
11927
+ * @param {string} eventType The event type for which the object was registered. See {@link input.registerPointerEvent}
11928
+ * @param {Rect|Polygon|Line|Ellipse} region the registered region to release for this event
11929
+ * @param {Function} [callback="all"] if specified unregister the event only for the specific callback
11930
+ * @example
11931
+ * // release the registered region on the 'pointerdown' event
11932
+ * me.input.releasePointerEvent('pointerdown', this);
11933
+ */
11934
+ declare function releasePointerEvent(eventType: string, region: Rect | Polygon | Line | Ellipse, callback?: Function): void;
11969
11935
  /**
11970
11936
  * allows the removal of all registered event listeners from the object target.
11971
11937
  * @name releaseAllPointerEvents