core2d 2.11.1 → 2.11.4
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 +0 -1
- package/package.json +53 -53
- package/src/ACL.mjs +54 -54
- package/src/Animation.mjs +73 -73
- package/src/ButtonLayout.mjs +36 -36
- package/src/ButtonLayoutMap.mjs +1 -1
- package/src/Color.mjs +148 -148
- package/src/Command.mjs +10 -10
- package/src/CompositeOperations.mjs +11 -11
- package/src/Controller.mjs +82 -82
- package/src/Core2D.mjs +269 -269
- package/src/Direction.mjs +22 -22
- package/src/Engine.mjs +448 -448
- package/src/FontFamily.mjs +5 -5
- package/src/Frame.mjs +37 -37
- package/src/GamePad.mjs +43 -43
- package/src/Input.mjs +114 -114
- package/src/Key.mjs +18 -18
- package/src/KeyMap.mjs +18 -18
- package/src/Keyboard.mjs +28 -28
- package/src/Mouse.mjs +35 -35
- package/src/Point.mjs +61 -61
- package/src/Pointer.mjs +48 -48
- package/src/Rect.mjs +239 -239
- package/src/RenderableList.mjs +12 -12
- package/src/Scene.mjs +137 -137
- package/src/Sound.mjs +134 -134
- package/src/Sprite.mjs +686 -680
- package/src/Static.mjs +54 -54
- package/src/TextSprite.mjs +228 -228
- package/src/Touch.mjs +41 -41
- package/src/Transition.mjs +12 -12
- package/src/plugin/BaseTile.mjs +4 -4
- package/src/plugin/ClickableSprite.mjs +14 -14
- package/src/plugin/ControllableSprite.mjs +36 -36
- package/src/plugin/CursorSprite.mjs +32 -32
- package/src/plugin/Fog.mjs +23 -23
- package/src/plugin/FontSprite.mjs +59 -59
- package/src/plugin/JumperSprite.mjs +132 -132
- package/src/plugin/RandomRectTransition.mjs +22 -22
- package/src/plugin/Starfield.mjs +47 -47
package/src/FontFamily.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export const FontFamily = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
Cursive: "cursive",
|
|
5
|
+
Fantasy: "fantasy",
|
|
6
|
+
Monospace: "monospace",
|
|
7
|
+
SansSerif: "sans-serif",
|
|
8
|
+
Serif: "serif",
|
|
9
9
|
};
|
package/src/Frame.mjs
CHANGED
|
@@ -6,45 +6,45 @@ import { Static } from "./Static.mjs";
|
|
|
6
6
|
* Represents a frame in an animation.
|
|
7
7
|
*/
|
|
8
8
|
export class Frame {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new Frame.
|
|
11
|
+
* @param {HTMLImageElement|HTMLCanvasElement} image The image of the frame.
|
|
12
|
+
* @param {number} [duration=0] The duration of the frame in ticks.
|
|
13
|
+
*/
|
|
14
|
+
constructor(image, duration = 0) {
|
|
15
|
+
this._image = Static.getImage(image);
|
|
16
|
+
this._duration = duration;
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The image of the frame.
|
|
21
|
+
* @type {HTMLImageElement|HTMLCanvasElement}
|
|
22
|
+
*/
|
|
23
|
+
get image() {
|
|
24
|
+
return this._image;
|
|
25
|
+
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The duration of the frame in ticks.
|
|
29
|
+
* @type {number}
|
|
30
|
+
*/
|
|
31
|
+
get duration() {
|
|
32
|
+
return this._duration;
|
|
33
|
+
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The width of the frame.
|
|
37
|
+
* @type {number}
|
|
38
|
+
*/
|
|
39
|
+
get width() {
|
|
40
|
+
return this._image.width;
|
|
41
|
+
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
/**
|
|
44
|
+
* The height of the frame.
|
|
45
|
+
* @type {number}
|
|
46
|
+
*/
|
|
47
|
+
get height() {
|
|
48
|
+
return this._image.height;
|
|
49
|
+
}
|
|
50
50
|
}
|
package/src/GamePad.mjs
CHANGED
|
@@ -8,47 +8,47 @@ import { Input } from "./Input.mjs";
|
|
|
8
8
|
import { Static } from "./Static.mjs";
|
|
9
9
|
|
|
10
10
|
export class GamePad {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
11
|
+
constructor(id = 0) {
|
|
12
|
+
this._id = id;
|
|
13
|
+
this.analogThreshold = 0.5;
|
|
14
|
+
this.layout = ButtonLayout.standard;
|
|
15
|
+
const MODEL = Static.getGamepads()[id].id.toLowerCase();
|
|
16
|
+
|
|
17
|
+
for (let id in ButtonLayoutMap) {
|
|
18
|
+
if (MODEL.includes(id)) {
|
|
19
|
+
this.layout = ButtonLayout[ButtonLayoutMap[id]];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get commands() {
|
|
25
|
+
const BUTTONS = Input.getGamePadButtons(this._id);
|
|
26
|
+
const RESULT = {};
|
|
27
|
+
|
|
28
|
+
if (Input.getGamePadAxes(this._id)[Axis.LEFT_Y] < -this.analogThreshold) {
|
|
29
|
+
RESULT[Command.UP] = true;
|
|
30
|
+
} else if (
|
|
31
|
+
Input.getGamePadAxes(this._id)[Axis.LEFT_Y] > this.analogThreshold
|
|
32
|
+
) {
|
|
33
|
+
RESULT[Command.DOWN] = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (Input.getGamePadAxes(this._id)[Axis.LEFT_X] < -this.analogThreshold) {
|
|
37
|
+
RESULT[Command.LEFT] = true;
|
|
38
|
+
} else if (
|
|
39
|
+
Input.getGamePadAxes(this._id)[Axis.LEFT_X] > this.analogThreshold
|
|
40
|
+
) {
|
|
41
|
+
RESULT[Command.RIGHT] = true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
for (let i in Command) {
|
|
45
|
+
const BUTTON = BUTTONS[this.layout[i]];
|
|
46
|
+
|
|
47
|
+
if (BUTTON && BUTTON.pressed) {
|
|
48
|
+
RESULT[Command[i]] = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return RESULT;
|
|
53
|
+
}
|
|
54
54
|
}
|
package/src/Input.mjs
CHANGED
|
@@ -9,118 +9,118 @@ import { Static } from "./Static.mjs";
|
|
|
9
9
|
import { Touch } from "./Touch.mjs";
|
|
10
10
|
|
|
11
11
|
export class Input {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
12
|
+
constructor() {
|
|
13
|
+
this._controllers = [];
|
|
14
|
+
this._controllerQueue = [];
|
|
15
|
+
this._controllerRequestQueue = [];
|
|
16
|
+
this._pointers = [];
|
|
17
|
+
this._pointerQueue = [];
|
|
18
|
+
this._pointerRequestQueue = [];
|
|
19
|
+
this._gamePads = 0;
|
|
20
|
+
|
|
21
|
+
const ON_KEYBOARD = (event) => {
|
|
22
|
+
removeEventListener("keydown", ON_KEYBOARD);
|
|
23
|
+
console.log("Keyboard detected.");
|
|
24
|
+
this.addController(new Keyboard(event));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const ON_MOUSE = (event) => {
|
|
28
|
+
removeEventListener("mousemove", ON_MOUSE);
|
|
29
|
+
console.log("Mouse detected.");
|
|
30
|
+
this.addPointer(new Mouse(event));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const ON_TOUCH = (event) => {
|
|
34
|
+
removeEventListener("touchstart", ON_TOUCH);
|
|
35
|
+
console.log("Touch detected.");
|
|
36
|
+
this.addPointer(new Touch(event));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
addEventListener("keydown", ON_KEYBOARD, false);
|
|
40
|
+
addEventListener("mousemove", ON_MOUSE, false);
|
|
41
|
+
addEventListener("touchstart", ON_TOUCH, false);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static getGamePadAxes(id) {
|
|
45
|
+
if (Static.getGamepads()[id]) {
|
|
46
|
+
return Static.getGamepads()[id].axes;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static getGamePadButtons(id) {
|
|
53
|
+
const GAMEPAD = Static.getGamepads()[id];
|
|
54
|
+
return (GAMEPAD && GAMEPAD.buttons) || [];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
addController(device) {
|
|
58
|
+
this._controllerQueue.push(device);
|
|
59
|
+
this.checkControllerQueues();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
addPointer(device) {
|
|
63
|
+
this._pointerQueue.push(device);
|
|
64
|
+
this.checkPointerQueues();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
checkGamePads() {
|
|
68
|
+
if (Static.getGamepads()[this._gamePads]) {
|
|
69
|
+
console.log("Game pad detected.");
|
|
70
|
+
this.addController(new GamePad(this._gamePads++));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
checkControllerQueues() {
|
|
75
|
+
if (
|
|
76
|
+
this._controllerRequestQueue.length > 0 &&
|
|
77
|
+
this._controllerQueue.length > 0
|
|
78
|
+
) {
|
|
79
|
+
const REQUESTER = this._controllerRequestQueue.shift();
|
|
80
|
+
const DEVICE = this._controllerQueue.shift();
|
|
81
|
+
REQUESTER.setDevice(DEVICE);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
checkPointerQueues() {
|
|
86
|
+
if (this._pointerRequestQueue.length > 0 && this._pointerQueue.length > 0) {
|
|
87
|
+
const REQUESTER = this._pointerRequestQueue.shift();
|
|
88
|
+
const DEVICE = this._pointerQueue.shift();
|
|
89
|
+
REQUESTER.setDevice(DEVICE);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getController(id = 0) {
|
|
94
|
+
if (this._controllers.length < id + 1) {
|
|
95
|
+
const CONTROLLER = new Controller();
|
|
96
|
+
this._controllers.push(CONTROLLER);
|
|
97
|
+
this._controllerRequestQueue.push(CONTROLLER);
|
|
98
|
+
this.checkControllerQueues();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this._controllers[id];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getPointer(id = 0) {
|
|
105
|
+
if (this._pointers.length < id + 1) {
|
|
106
|
+
const POINTER = new Pointer();
|
|
107
|
+
this._pointers.push(POINTER);
|
|
108
|
+
this._pointerRequestQueue.push(POINTER);
|
|
109
|
+
this.checkPointerQueues();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return this._pointers[id];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
update() {
|
|
116
|
+
this.checkGamePads();
|
|
117
|
+
|
|
118
|
+
for (let i in this._controllers) {
|
|
119
|
+
this._controllers[i].update();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
for (let j in this._pointers) {
|
|
123
|
+
this._pointers[j].update();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
126
|
}
|
package/src/Key.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export const Key = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
BACK: 8,
|
|
5
|
+
ENTER: 13,
|
|
6
|
+
SHIFT: 16,
|
|
7
|
+
CTRL: 17,
|
|
8
|
+
ALT: 18,
|
|
9
|
+
SPACE: 32,
|
|
10
|
+
LEFT: 37,
|
|
11
|
+
UP: 38,
|
|
12
|
+
RIGHT: 39,
|
|
13
|
+
DOWN: 40,
|
|
14
|
+
D: 68,
|
|
15
|
+
E: 69,
|
|
16
|
+
F: 70,
|
|
17
|
+
I: 73,
|
|
18
|
+
J: 74,
|
|
19
|
+
K: 75,
|
|
20
|
+
L: 76,
|
|
21
|
+
S: 83,
|
|
22
22
|
};
|
package/src/KeyMap.mjs
CHANGED
|
@@ -4,22 +4,22 @@ import { Command } from "./Command.mjs";
|
|
|
4
4
|
import { Key } from "./Key.mjs";
|
|
5
5
|
|
|
6
6
|
export const KeyMap = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
[Key.UP]: Command.UP,
|
|
8
|
+
[Key.E]: Command.UP,
|
|
9
|
+
[Key.I]: Command.UP,
|
|
10
|
+
[Key.DOWN]: Command.DOWN,
|
|
11
|
+
[Key.D]: Command.DOWN,
|
|
12
|
+
[Key.K]: Command.DOWN,
|
|
13
|
+
[Key.LEFT]: Command.LEFT,
|
|
14
|
+
[Key.S]: Command.LEFT,
|
|
15
|
+
[Key.J]: Command.LEFT,
|
|
16
|
+
[Key.RIGHT]: Command.RIGHT,
|
|
17
|
+
[Key.F]: Command.RIGHT,
|
|
18
|
+
[Key.L]: Command.RIGHT,
|
|
19
|
+
[Key.SPACE]: Command.A,
|
|
20
|
+
[Key.ALT]: Command.B,
|
|
21
|
+
[Key.CTRL]: Command.X,
|
|
22
|
+
[Key.SHIFT]: Command.Y,
|
|
23
|
+
[Key.ENTER]: Command.START,
|
|
24
|
+
[Key.BACK]: Command.SELECT,
|
|
25
25
|
};
|
package/src/Keyboard.mjs
CHANGED
|
@@ -3,32 +3,32 @@
|
|
|
3
3
|
import { KeyMap } from "./KeyMap.mjs";
|
|
4
4
|
|
|
5
5
|
export class Keyboard {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
6
|
+
constructor(event) {
|
|
7
|
+
this._buffer = {};
|
|
8
|
+
|
|
9
|
+
this.onKey(event, true);
|
|
10
|
+
addEventListener("keydown", (event) => this.onKey(event, true), false);
|
|
11
|
+
addEventListener("keyup", (event) => this.onKey(event, false), false);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get commands() {
|
|
15
|
+
const RESULT = {};
|
|
16
|
+
|
|
17
|
+
for (let i in this._buffer) {
|
|
18
|
+
if (this._buffer[i]) {
|
|
19
|
+
RESULT[i] = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return RESULT;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
onKey(event, isDown) {
|
|
27
|
+
const COMMAND = KeyMap[event.keyCode];
|
|
28
|
+
this._buffer[COMMAND] = isDown;
|
|
29
|
+
|
|
30
|
+
if (isDown && "number" == typeof COMMAND) {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
34
|
}
|
package/src/Mouse.mjs
CHANGED
|
@@ -3,44 +3,44 @@
|
|
|
3
3
|
import { Point } from "./Point.mjs";
|
|
4
4
|
|
|
5
5
|
export class Mouse extends Point {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
constructor(event) {
|
|
7
|
+
super();
|
|
8
|
+
this.updateCoordinates(event);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
addEventListener(
|
|
11
|
+
"mousedown",
|
|
12
|
+
(event) => {
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
this._isDown = true;
|
|
15
|
+
},
|
|
16
|
+
false
|
|
17
|
+
);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
addEventListener(
|
|
20
|
+
"mousemove",
|
|
21
|
+
(event) => {
|
|
22
|
+
this.updateCoordinates(event);
|
|
23
|
+
},
|
|
24
|
+
false
|
|
25
|
+
);
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
addEventListener(
|
|
28
|
+
"mouseup",
|
|
29
|
+
(event) => {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
this._isDown = false;
|
|
32
|
+
},
|
|
33
|
+
false
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
get command() {
|
|
38
|
+
return this._isDown;
|
|
39
|
+
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
updateCoordinates(event) {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
this.x = event.x ?? event.clientX ?? 0;
|
|
44
|
+
this.y = event.y ?? event.clientY ?? 0;
|
|
45
|
+
}
|
|
46
46
|
}
|