melonjs 10.4.0 → 10.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.
@@ -266,7 +266,8 @@ export class Body {
266
266
  public mass: number;
267
267
  maxVel: Vector2d;
268
268
  /**
269
- * either this body is a static body or not
269
+ * Either this body is a static body or not.
270
+ * A static body is completely fixed and can never change position or angle.
270
271
  * @readonly
271
272
  * @public
272
273
  * @type {boolean}
@@ -2089,21 +2090,14 @@ export class Container extends Renderable {
2089
2090
  }
2090
2091
  /**
2091
2092
  * @classdesc
2092
- * Used to make a game entity draggable
2093
- * @augments Entity
2093
+ * A Draggable base object
2094
+ * @see DropTarget
2095
+ * @augments Renderable
2094
2096
  */
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);
2097
+ export class Draggable extends Renderable {
2102
2098
  dragging: boolean;
2103
2099
  dragId: any;
2104
2100
  grabOffset: Vector2d;
2105
- onPointerEvent: typeof registerPointerEvent;
2106
- removePointerEvent: typeof releasePointerEvent;
2107
2101
  /**
2108
2102
  * Initializes the events the modules needs to listen to
2109
2103
  * It translates the pointer events to me.events
@@ -2111,31 +2105,15 @@ export class DraggableEntity extends Entity {
2111
2105
  * this module testable. Then we subscribe this module to the
2112
2106
  * transformed events.
2113
2107
  * @name initEvents
2114
- * @memberof DraggableEntity
2108
+ * @memberof Draggable
2115
2109
  * @function
2110
+ * @private
2116
2111
  */
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;
2112
+ private initEvents;
2135
2113
  /**
2136
2114
  * Gets called when the user starts dragging the entity
2137
2115
  * @name dragStart
2138
- * @memberof DraggableEntity
2116
+ * @memberof Draggable
2139
2117
  * @function
2140
2118
  * @param {object} e the pointer event
2141
2119
  * @returns {boolean} false if the object is being dragged
@@ -2144,7 +2122,7 @@ export class DraggableEntity extends Entity {
2144
2122
  /**
2145
2123
  * Gets called when the user drags this entity around
2146
2124
  * @name dragMove
2147
- * @memberof DraggableEntity
2125
+ * @memberof Draggable
2148
2126
  * @function
2149
2127
  * @param {object} e the pointer event
2150
2128
  */
@@ -2152,7 +2130,7 @@ export class DraggableEntity extends Entity {
2152
2130
  /**
2153
2131
  * Gets called when the user stops dragging the entity
2154
2132
  * @name dragEnd
2155
- * @memberof DraggableEntity
2133
+ * @memberof Draggable
2156
2134
  * @function
2157
2135
  * @returns {boolean} false if the object stopped being dragged
2158
2136
  */
@@ -2160,30 +2138,41 @@ export class DraggableEntity extends Entity {
2160
2138
  /**
2161
2139
  * Destructor
2162
2140
  * @name destroy
2163
- * @memberof DraggableEntity
2141
+ * @memberof Draggable
2164
2142
  * @function
2143
+ * @private
2165
2144
  */
2166
- destroy(): void;
2145
+ private destroy;
2167
2146
  }
2168
2147
  /**
2169
2148
  * @classdesc
2170
- * Used to make a game entity a droptarget
2149
+ * Used to make a game entity draggable
2171
2150
  * @augments Entity
2151
+ * @deprecated since 10.5.0
2152
+ * @see Draggable
2172
2153
  */
2173
- export class DroptargetEntity extends Entity {
2154
+ export class DraggableEntity extends Entity {
2174
2155
  /**
2175
- * @param {number} x the x coordinates of the entity object
2176
- * @param {number} y the y coordinates of the entity object
2156
+ * @param {number} x the x coordinates of the draggable object
2157
+ * @param {number} y the y coordinates of the draggable object
2177
2158
  * @param {object} settings Entity properties (see {@link Entity})
2178
2159
  */
2179
2160
  constructor(x: number, y: number, settings: object);
2161
+ }
2162
+ /**
2163
+ * @classdesc
2164
+ * a base drop target object
2165
+ * @see Draggable
2166
+ * @augments Renderable
2167
+ */
2168
+ export class DropTarget extends Renderable {
2180
2169
  /**
2181
2170
  * constant for the overlaps method
2182
2171
  * @public
2183
2172
  * @constant
2184
2173
  * @type {string}
2185
2174
  * @name CHECKMETHOD_OVERLAP
2186
- * @memberof DroptargetEntity
2175
+ * @memberof DropTarget
2187
2176
  */
2188
2177
  public CHECKMETHOD_OVERLAP: string;
2189
2178
  /**
@@ -2192,7 +2181,7 @@ export class DroptargetEntity extends Entity {
2192
2181
  * @constant
2193
2182
  * @type {string}
2194
2183
  * @name CHECKMETHOD_CONTAINS
2195
- * @memberof DroptargetEntity
2184
+ * @memberof DropTarget
2196
2185
  */
2197
2186
  public CHECKMETHOD_CONTAINS: string;
2198
2187
  /**
@@ -2201,13 +2190,14 @@ export class DroptargetEntity extends Entity {
2201
2190
  * @constant
2202
2191
  * @type {string}
2203
2192
  * @name checkMethod
2204
- * @memberof DroptargetEntity
2193
+ * @default "overlaps"
2194
+ * @memberof DropTarget
2205
2195
  */
2206
2196
  public checkMethod: string;
2207
2197
  /**
2208
2198
  * Sets the collision method which is going to be used to check a valid drop
2209
2199
  * @name setCheckMethod
2210
- * @memberof DroptargetEntity
2200
+ * @memberof DropTarget
2211
2201
  * @function
2212
2202
  * @param {string} checkMethod the checkmethod (defaults to CHECKMETHOD_OVERLAP)
2213
2203
  */
@@ -2215,27 +2205,43 @@ export class DroptargetEntity extends Entity {
2215
2205
  /**
2216
2206
  * Checks if a dropped entity is dropped on the current entity
2217
2207
  * @name checkOnMe
2218
- * @memberof DroptargetEntity
2208
+ * @memberof DropTarget
2219
2209
  * @function
2220
2210
  * @param {object} e the triggering event
2221
- * @param {object} draggableEntity the draggable entity that is dropped
2211
+ * @param {Draggable} draggable the draggable object that is dropped
2222
2212
  */
2223
- checkOnMe(e: object, draggableEntity: object): void;
2213
+ checkOnMe(e: object, draggable: Draggable): void;
2224
2214
  /**
2225
2215
  * Gets called when a draggable entity is dropped on the current entity
2226
2216
  * @name drop
2227
- * @memberof DroptargetEntity
2217
+ * @memberof DropTarget
2228
2218
  * @function
2229
- * @param {object} draggableEntity the draggable entity that is dropped
2219
+ * @param {Draggable} draggable the draggable object that is dropped
2230
2220
  */
2231
2221
  drop(): void;
2232
2222
  /**
2233
2223
  * Destructor
2234
2224
  * @name destroy
2235
- * @memberof DroptargetEntity
2225
+ * @memberof DropTarget
2236
2226
  * @function
2227
+ * @private
2237
2228
  */
2238
- destroy(): void;
2229
+ private destroy;
2230
+ }
2231
+ /**
2232
+ * @classdesc
2233
+ * Used to make a game entity a droptarget
2234
+ * @augments Entity
2235
+ * @deprecated since 10.5.0
2236
+ * @see DropTarget
2237
+ */
2238
+ export class DroptargetEntity extends Entity {
2239
+ /**
2240
+ * @param {number} x the x coordinates of the draggable object
2241
+ * @param {number} y the y coordinates of the draggable object
2242
+ * @param {object} settings Entity properties (see {@link Entity})
2243
+ */
2244
+ constructor(x: number, y: number, settings: object);
2239
2245
  }
2240
2246
  /**
2241
2247
  * @classdesc
@@ -9187,10 +9193,6 @@ export function boot(): void;
9187
9193
  * @namespace collision
9188
9194
  */
9189
9195
  export var collision: any;
9190
- export var deprecated: Readonly<{
9191
- __proto__: any;
9192
- warning: typeof warning;
9193
- }>;
9194
9196
  declare namespace device$1 {
9195
9197
  namespace turnOnPointerLock { }
9196
9198
  namespace turnOffPointerLock { }
@@ -10969,6 +10971,17 @@ export var video: Readonly<{
10969
10971
  getParent: typeof getParent;
10970
10972
  scale: typeof scale;
10971
10973
  }>;
10974
+ /**
10975
+ * placeholder for all deprecated classes and corresponding alias for backward compatibility
10976
+ */
10977
+ /**
10978
+ * display a deprecation warning in the console
10979
+ * @ignore
10980
+ * @param {string} deprecated deprecated class,function or property name
10981
+ * @param {string} replacement the replacement class, function, or property name
10982
+ * @param {string} version the version since when the lass,function or property is deprecated
10983
+ */
10984
+ export function warning(deprecated: string, replacement: string, version: string): void;
10972
10985
  /**
10973
10986
  * @classdesc
10974
10987
  * a bound object contains methods for creating and manipulating axis-aligned bounding boxes (AABB).
@@ -11241,7 +11254,7 @@ declare class TextureCache {
11241
11254
  * @ignore
11242
11255
  */
11243
11256
  constructor(max_size: any);
11244
- cache: Map<any, any>;
11257
+ cache: any;
11245
11258
  tinted: Map<any, any>;
11246
11259
  units: Map<any, any>;
11247
11260
  max_size: any;
@@ -11269,67 +11282,12 @@ declare class TextureCache {
11269
11282
  /**
11270
11283
  * @ignore
11271
11284
  */
11272
- set(image: any, texture: any): void;
11285
+ set(image: any, texture: any): any;
11273
11286
  /**
11274
11287
  * @ignore
11275
11288
  */
11276
11289
  getUnit(texture: any): any;
11277
11290
  }
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
11291
  /**
11334
11292
  * returns true if the given value is a power of two
11335
11293
  * @public
@@ -11799,17 +11757,6 @@ declare function unload(sound_name: string): boolean;
11799
11757
  * me.audio.unloadAll();
11800
11758
  */
11801
11759
  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
11760
  /**
11814
11761
  * calls each of the listeners registered for a given event.
11815
11762
  * @function event.emit
@@ -11966,6 +11913,61 @@ declare function bindPointer(...args: any[]): void;
11966
11913
  * me.input.unbindPointer(me.input.pointer.LEFT);
11967
11914
  */
11968
11915
  declare function unbindPointer(button?: number): void;
11916
+ /**
11917
+ * allows registration of event listeners on the object target. <br>
11918
+ * melonJS will pass a me.Pointer object to the defined callback.
11919
+ * @see Pointer
11920
+ * @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list}
11921
+ * @name registerPointerEvent
11922
+ * @memberof input
11923
+ * @public
11924
+ * @function
11925
+ * @param {string} eventType The event type for which the object is registering <br>
11926
+ * melonJS currently supports: <br>
11927
+ * <ul>
11928
+ * <li><code>"pointermove"</code></li>
11929
+ * <li><code>"pointerdown"</code></li>
11930
+ * <li><code>"pointerup"</code></li>
11931
+ * <li><code>"pointerenter"</code></li>
11932
+ * <li><code>"pointerover"</code></li>
11933
+ * <li><code>"pointerleave"</code></li>
11934
+ * <li><code>"pointercancel"</code></li>
11935
+ * <li><code>"wheel"</code></li>
11936
+ * </ul>
11937
+ * @param {Rect|Polygon|Line|Ellipse} region a shape representing the region to register on
11938
+ * @param {Function} callback methods to be called when the event occurs.
11939
+ * Returning `false` from the defined callback will prevent the event to be propagated to other objects
11940
+ * @example
11941
+ * // onActivate function
11942
+ * onActivateEvent: function () {
11943
+ * // register on the 'pointerdown' event
11944
+ * me.input.registerPointerEvent('pointerdown', this, this.pointerDown.bind(this));
11945
+ * },
11946
+ *
11947
+ * // pointerDown event callback
11948
+ * pointerDown: function (pointer) {
11949
+ * // do something
11950
+ * ....
11951
+ * // don"t propagate the event to other objects
11952
+ * return false;
11953
+ * },
11954
+ */
11955
+ declare function registerPointerEvent(eventType: string, region: Rect | Polygon | Line | Ellipse, callback: Function): void;
11956
+ /**
11957
+ * allows the removal of event listeners from the object target.
11958
+ * @see {@link http://www.w3.org/TR/pointerevents/#list-of-pointer-events|W3C Pointer Event list}
11959
+ * @name releasePointerEvent
11960
+ * @memberof input
11961
+ * @public
11962
+ * @function
11963
+ * @param {string} eventType The event type for which the object was registered. See {@link input.registerPointerEvent}
11964
+ * @param {Rect|Polygon|Line|Ellipse} region the registered region to release for this event
11965
+ * @param {Function} [callback="all"] if specified unregister the event only for the specific callback
11966
+ * @example
11967
+ * // release the registered region on the 'pointerdown' event
11968
+ * me.input.releasePointerEvent('pointerdown', this);
11969
+ */
11970
+ declare function releasePointerEvent(eventType: string, region: Rect | Polygon | Line | Ellipse, callback?: Function): void;
11969
11971
  /**
11970
11972
  * allows the removal of all registered event listeners from the object target.
11971
11973
  * @name releaseAllPointerEvents