core2d 2.10.4 → 2.11.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.
- package/README.md +73 -0
- package/package.json +53 -48
- package/src/ACL.mjs +55 -55
- package/src/Animation.mjs +87 -50
- package/src/Axis.mjs +1 -6
- 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 +85 -50
- package/src/Core2D.mjs +272 -124
- package/src/Direction.mjs +22 -22
- package/src/Engine.mjs +448 -445
- package/src/FontFamily.mjs +5 -5
- package/src/Frame.mjs +40 -16
- package/src/GamePad.mjs +43 -39
- package/src/Input.mjs +114 -111
- package/src/Key.mjs +18 -18
- package/src/KeyMap.mjs +18 -18
- package/src/Keyboard.mjs +28 -28
- package/src/Mouse.mjs +35 -23
- package/src/Point.mjs +64 -28
- package/src/Pointer.mjs +59 -37
- package/src/Rect.mjs +243 -121
- package/src/RenderableList.mjs +12 -12
- package/src/Scene.mjs +141 -100
- package/src/Sound.mjs +134 -130
- package/src/Sprite.mjs +690 -358
- package/src/Static.mjs +54 -54
- package/src/TextSprite.mjs +232 -132
- package/src/Touch.mjs +41 -29
- package/src/Transition.mjs +12 -12
- package/src/plugin/BaseTile.mjs +5 -5
- package/src/plugin/ClickableSprite.mjs +15 -16
- package/src/plugin/ControllableSprite.mjs +37 -31
- package/src/plugin/CursorSprite.mjs +33 -33
- package/src/plugin/Fog.mjs +23 -20
- package/src/plugin/FontSprite.mjs +72 -67
- package/src/plugin/JumperSprite.mjs +132 -133
- package/src/plugin/RandomRectTransition.mjs +22 -23
- package/src/plugin/Starfield.mjs +47 -45
|
@@ -4,35 +4,41 @@ import { Command } from "../Command.mjs";
|
|
|
4
4
|
import { Core2D } from "../Core2D.mjs";
|
|
5
5
|
import { Sprite } from "../Sprite.mjs";
|
|
6
6
|
|
|
7
|
-
export
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
7
|
+
export class ControllableSprite extends Sprite {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.controller = Core2D.getController();
|
|
11
|
+
this.step = 2;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
setStep(step) {
|
|
15
|
+
this.step = step;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
sync() {
|
|
20
|
+
if (this.controller.keyDown(Command.LEFT) && this.left > 0) {
|
|
21
|
+
this.x -= this.step;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (
|
|
25
|
+
this.controller.keyDown(Command.RIGHT) &&
|
|
26
|
+
this.right < this.scene.width
|
|
27
|
+
) {
|
|
28
|
+
this.x += this.step;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (this.controller.keyDown(Command.UP) && this.top > 0) {
|
|
32
|
+
this.y -= this.step;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (
|
|
36
|
+
this.controller.keyDown(Command.DOWN) &&
|
|
37
|
+
this.bottom < this.scene.height
|
|
38
|
+
) {
|
|
39
|
+
this.y += this.step;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return Sprite.prototype.sync.call(this);
|
|
43
|
+
}
|
|
38
44
|
}
|
|
@@ -4,42 +4,42 @@ import { Core2D } from "../Core2D.mjs";
|
|
|
4
4
|
import { Rect } from "../Rect.mjs";
|
|
5
5
|
import { Sprite } from "../Sprite.mjs";
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export class CursorSprite extends Sprite {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.hovering = null;
|
|
11
|
+
this.pointer = Core2D.getPointer();
|
|
12
|
+
this.setSolid();
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
check(sprite) {
|
|
16
|
+
const FOCUS = new Rect(this.getLeft(), this.getTop(), 1, 1);
|
|
17
|
+
return sprite.hasCollision(FOCUS);
|
|
18
|
+
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
onCollision(sprite) {
|
|
21
|
+
if (sprite.hasTag("clickable") && this.check(sprite)) {
|
|
22
|
+
if (this.hovering != sprite) {
|
|
23
|
+
if (this.hovering) {
|
|
24
|
+
this.hovering.onHoverOut();
|
|
25
|
+
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
this.hovering = sprite;
|
|
28
|
+
sprite.onHoverIn();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
update() {
|
|
34
|
+
this.setPosition(this.pointer);
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
if (this.hovering) {
|
|
37
|
+
if (!this.hasCollision(this.hovering)) {
|
|
38
|
+
this.hovering.onHoverOut();
|
|
39
|
+
this.hovering = null;
|
|
40
|
+
} else if (this.pointer.getPush()) {
|
|
41
|
+
this.hovering.onClick();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
45
|
}
|
package/src/plugin/Fog.mjs
CHANGED
|
@@ -3,29 +3,32 @@
|
|
|
3
3
|
import { Sprite } from "../Sprite.mjs";
|
|
4
4
|
|
|
5
5
|
export class Fog extends Sprite {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.setImageId("fogSprite0")
|
|
9
|
-
.setSpeedX(-1));
|
|
6
|
+
init() {
|
|
7
|
+
this.scene.add(new FogLayer().setImageId("fogSprite0").setSpeedX(-1));
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
this.scene.add(
|
|
10
|
+
new FogLayer()
|
|
11
|
+
.setImageId("fogSprite1")
|
|
12
|
+
.setSpeedX(1)
|
|
13
|
+
.setRight(this.scene.right)
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
class FogLayer extends Sprite {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
init() {
|
|
20
|
+
this.setLayerIndex(2)
|
|
21
|
+
.setHeight(this.scene.height)
|
|
22
|
+
.setWidth(this.scene.width * 2);
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
update() {
|
|
26
|
+
if (
|
|
27
|
+
(this.speedX < 0 && this.right == this.scene.right) ||
|
|
28
|
+
(this.speedX > 0 && this.left == this.scene.left)
|
|
29
|
+
) {
|
|
30
|
+
const SIGNAL = this.speedX / Math.abs(this.speedX);
|
|
31
|
+
this.x -= this.scene.width * SIGNAL;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
31
34
|
}
|
|
@@ -4,71 +4,76 @@ import { Core2D } from "../Core2D.mjs";
|
|
|
4
4
|
import { Sprite } from "../Sprite.mjs";
|
|
5
5
|
|
|
6
6
|
export class FontSprite extends Sprite {
|
|
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
|
-
|
|
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
|
-
|
|
7
|
+
constructor(text = "") {
|
|
8
|
+
super();
|
|
9
|
+
this.font = "";
|
|
10
|
+
this.text = text;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
render(context) {
|
|
14
|
+
Sprite.prototype.render.call(this, context) && this._parse(context);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
setFont(font) {
|
|
18
|
+
this.font = font;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
setText(text) {
|
|
22
|
+
this._text = text;
|
|
23
|
+
this._parse();
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get text() {
|
|
28
|
+
return this._text;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
set text(text) {
|
|
32
|
+
this.setText(text);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_parse(context) {
|
|
36
|
+
const SPACE = 4;
|
|
37
|
+
const SPACING = 0;
|
|
38
|
+
let height = 0;
|
|
39
|
+
let width = 0;
|
|
40
|
+
let x = 0;
|
|
41
|
+
let y = 0;
|
|
42
|
+
|
|
43
|
+
for (let i = 0; i < this._text.length; ++i) {
|
|
44
|
+
let character = this._text[i];
|
|
45
|
+
|
|
46
|
+
if (character == " ") {
|
|
47
|
+
x += SPACE + SPACING;
|
|
48
|
+
} else if (character == "\n") {
|
|
49
|
+
x = 0;
|
|
50
|
+
y += height + SPACING;
|
|
51
|
+
} else {
|
|
52
|
+
const IMAGE = Core2D.image(character + this.font + "Font");
|
|
53
|
+
|
|
54
|
+
if (context) {
|
|
55
|
+
context.drawImage(
|
|
56
|
+
IMAGE,
|
|
57
|
+
this.x + this.scene.x + x,
|
|
58
|
+
this.y + this.scene.y + y,
|
|
59
|
+
IMAGE.width,
|
|
60
|
+
IMAGE.height
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
x += IMAGE.width + SPACING;
|
|
65
|
+
|
|
66
|
+
if (x > width) {
|
|
67
|
+
width = x;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (IMAGE.height > height) {
|
|
71
|
+
height = IMAGE.height;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.setWidth(width);
|
|
77
|
+
this.setHeight(y + height);
|
|
78
|
+
}
|
|
73
79
|
}
|
|
74
|
-
|
|
@@ -7,137 +7,136 @@ import { Sprite } from "../Sprite.mjs";
|
|
|
7
7
|
const PUSHABLE_TAG = "pushable";
|
|
8
8
|
|
|
9
9
|
export class JumperSprite extends Sprite {
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
10
|
+
constructor(scene) {
|
|
11
|
+
super(scene);
|
|
12
|
+
this.accelerationY = 0.5;
|
|
13
|
+
this.canGoLeft = true;
|
|
14
|
+
this.canGoRight = true;
|
|
15
|
+
this.canJump = false;
|
|
16
|
+
this.controller = Core2D.getController();
|
|
17
|
+
this.jumpCommand = Command.A;
|
|
18
|
+
this.jumpSpeed = -8;
|
|
19
|
+
this.solid = true;
|
|
20
|
+
this.step = 2;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
setJumpCommand(jumpCommand) {
|
|
24
|
+
this.jumpCommand = jumpCommand;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setJumpSpeed(jumpSpeed) {
|
|
29
|
+
this.jumpSpeed = jumpSpeed;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setStep(step) {
|
|
34
|
+
this.step = step;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
jump() {
|
|
39
|
+
this.canJump = false;
|
|
40
|
+
this.setSpeedY(this.jumpSpeed);
|
|
41
|
+
this.onJump();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
onCollision(sprite) {
|
|
45
|
+
const collision = this.getCollision(sprite);
|
|
46
|
+
|
|
47
|
+
if (collision.bottom) {
|
|
48
|
+
if (this.speedY > 0) {
|
|
49
|
+
this.setSpeedY(0);
|
|
50
|
+
this.setBottom(sprite.top - 1);
|
|
51
|
+
this.canJump = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.onBottomCollision(sprite);
|
|
55
|
+
} else if (collision.top) {
|
|
56
|
+
if (this.speedY < 0) {
|
|
57
|
+
this.setSpeedY(0);
|
|
58
|
+
this.setTop(sprite.bottom + 1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this.onTopCollision(sprite);
|
|
62
|
+
} else if (collision.left) {
|
|
63
|
+
if (!sprite.hasTag(PUSHABLE_TAG)) {
|
|
64
|
+
this.canGoLeft = false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
this.setLeft(sprite.right + 1);
|
|
68
|
+
this.onLeftCollision(sprite);
|
|
69
|
+
} else if (collision.right) {
|
|
70
|
+
if (!sprite.hasTag(PUSHABLE_TAG)) {
|
|
71
|
+
this.canGoRight = false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.setRight(sprite.left - 1);
|
|
75
|
+
this.onRightCollision(sprite);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
sync() {
|
|
80
|
+
if (this.solid) {
|
|
81
|
+
if (this.canJump && this.controller.keyPush(this.jumpCommand)) {
|
|
82
|
+
this.jump();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (this.canGoLeft && this.controller.keyDown(Command.LEFT)) {
|
|
86
|
+
this.x -= this.step;
|
|
87
|
+
this.canGoRight = true;
|
|
88
|
+
this.onLeft();
|
|
89
|
+
} else if (this.canGoRight && this.controller.keyDown(Command.RIGHT)) {
|
|
90
|
+
this.x += this.step;
|
|
91
|
+
this.canGoLeft = true;
|
|
92
|
+
this.onRight();
|
|
93
|
+
} else {
|
|
94
|
+
this.onIdle();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!this.collided) {
|
|
98
|
+
this.canGoLeft = true;
|
|
99
|
+
this.canGoRight = true;
|
|
100
|
+
this.canJump = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return Sprite.prototype.sync.call(this);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
onJump() {
|
|
108
|
+
// no default behavior
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
onIdle() {
|
|
112
|
+
// no default behavior
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
onLeft() {
|
|
116
|
+
// no default behavior
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
onRight() {
|
|
120
|
+
// no default behavior
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
onLeftCollision(sprite) {
|
|
124
|
+
// no default behavior
|
|
125
|
+
return sprite;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
onRightCollision(sprite) {
|
|
129
|
+
// no default behavior
|
|
130
|
+
return sprite;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
onTopCollision(sprite) {
|
|
134
|
+
// no default behavior
|
|
135
|
+
return sprite;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
onBottomCollision(sprite) {
|
|
139
|
+
// no default behavior
|
|
140
|
+
return sprite;
|
|
141
|
+
}
|
|
142
142
|
}
|
|
143
|
-
|
|
@@ -5,30 +5,29 @@ import { Core2D } from "../Core2D.mjs";
|
|
|
5
5
|
import { Sprite } from "../Sprite.mjs";
|
|
6
6
|
|
|
7
7
|
export class RandomRectTransition extends Sprite {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
init() {
|
|
9
|
+
this.columns = 16;
|
|
10
|
+
this.rows = 8;
|
|
11
|
+
this.setColor(Color.Black);
|
|
12
|
+
this.setWidth(this.scene.width / this.columns);
|
|
13
|
+
this.setHeight(this.scene.height / this.rows);
|
|
14
|
+
this.rects = [];
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
for (let i = 0; i < this.columns * this.rows; ++i) {
|
|
17
|
+
this.rects.push(i);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
sync() {
|
|
22
|
+
if (!this.rects.length) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const number = this.rects.splice(Core2D.random(this.rects.length - 1), 1);
|
|
27
|
+
const column = number % this.columns;
|
|
28
|
+
const row = Math.floor(number / this.columns);
|
|
29
|
+
this.x = column * this.width;
|
|
30
|
+
this.y = row * this.height;
|
|
31
|
+
return Sprite.prototype.sync.call(this);
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
|
-
|