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.
- package/dist/melonjs.js +748 -240
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +125 -123
- package/dist/melonjs.module.js +742 -238
- package/package.json +9 -8
- package/src/index.js +5 -12
- package/src/lang/deprecated.js +40 -0
- package/src/level/tiled/TMXTileMap.js +2 -0
- package/src/physics/body.js +2 -1
- package/src/physics/detector.js +4 -3
- package/src/renderable/dragndrop.js +224 -0
- package/src/video/texture_cache.js +23 -5
- package/src/entity/draggable.js +0 -129
- package/src/entity/droptarget.js +0 -99
package/src/entity/droptarget.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as event from "./../system/event.js";
|
|
2
|
-
import Entity from "./entity.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @classdesc
|
|
6
|
-
* Used to make a game entity a droptarget
|
|
7
|
-
* @augments Entity
|
|
8
|
-
*/
|
|
9
|
-
class DroptargetEntity extends Entity {
|
|
10
|
-
/**
|
|
11
|
-
* @param {number} x the x coordinates of the entity object
|
|
12
|
-
* @param {number} y the y coordinates of the entity object
|
|
13
|
-
* @param {object} settings Entity properties (see {@link Entity})
|
|
14
|
-
*/
|
|
15
|
-
constructor(x, y, settings) {
|
|
16
|
-
super(x, y, settings);
|
|
17
|
-
/**
|
|
18
|
-
* constant for the overlaps method
|
|
19
|
-
* @public
|
|
20
|
-
* @constant
|
|
21
|
-
* @type {string}
|
|
22
|
-
* @name CHECKMETHOD_OVERLAP
|
|
23
|
-
* @memberof DroptargetEntity
|
|
24
|
-
*/
|
|
25
|
-
this.CHECKMETHOD_OVERLAP = "overlaps";
|
|
26
|
-
/**
|
|
27
|
-
* constant for the contains method
|
|
28
|
-
* @public
|
|
29
|
-
* @constant
|
|
30
|
-
* @type {string}
|
|
31
|
-
* @name CHECKMETHOD_CONTAINS
|
|
32
|
-
* @memberof DroptargetEntity
|
|
33
|
-
*/
|
|
34
|
-
this.CHECKMETHOD_CONTAINS = "contains";
|
|
35
|
-
/**
|
|
36
|
-
* the checkmethod we want to use
|
|
37
|
-
* @public
|
|
38
|
-
* @constant
|
|
39
|
-
* @type {string}
|
|
40
|
-
* @name checkMethod
|
|
41
|
-
* @memberof DroptargetEntity
|
|
42
|
-
*/
|
|
43
|
-
this.checkMethod = null;
|
|
44
|
-
event.on(event.DRAGEND, this.checkOnMe, this);
|
|
45
|
-
this.checkMethod = this[this.CHECKMETHOD_OVERLAP];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Sets the collision method which is going to be used to check a valid drop
|
|
50
|
-
* @name setCheckMethod
|
|
51
|
-
* @memberof DroptargetEntity
|
|
52
|
-
* @function
|
|
53
|
-
* @param {string} checkMethod the checkmethod (defaults to CHECKMETHOD_OVERLAP)
|
|
54
|
-
*/
|
|
55
|
-
setCheckMethod(checkMethod) {
|
|
56
|
-
// We can improve this check,
|
|
57
|
-
// because now you can use every method in theory
|
|
58
|
-
if (typeof(this[checkMethod]) !== "undefined") {
|
|
59
|
-
this.checkMethod = this[checkMethod];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Checks if a dropped entity is dropped on the current entity
|
|
65
|
-
* @name checkOnMe
|
|
66
|
-
* @memberof DroptargetEntity
|
|
67
|
-
* @function
|
|
68
|
-
* @param {object} e the triggering event
|
|
69
|
-
* @param {object} draggableEntity the draggable entity that is dropped
|
|
70
|
-
*/
|
|
71
|
-
checkOnMe(e, draggableEntity) {
|
|
72
|
-
if (draggableEntity && this.checkMethod(draggableEntity.getBounds())) {
|
|
73
|
-
// call the drop method on the current entity
|
|
74
|
-
this.drop(draggableEntity);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Gets called when a draggable entity is dropped on the current entity
|
|
80
|
-
* @name drop
|
|
81
|
-
* @memberof DroptargetEntity
|
|
82
|
-
* @function
|
|
83
|
-
* @param {object} draggableEntity the draggable entity that is dropped
|
|
84
|
-
*/
|
|
85
|
-
drop() {
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Destructor
|
|
91
|
-
* @name destroy
|
|
92
|
-
* @memberof DroptargetEntity
|
|
93
|
-
* @function
|
|
94
|
-
*/
|
|
95
|
-
destroy() {
|
|
96
|
-
event.off(event.DRAGEND, this.checkOnMe);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
export default DroptargetEntity;
|