/
clone.js
52 lines (39 loc) · 1.01 KB
/
clone.js
1
2
3
4
5
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class Example extends Phaser.Scene
{
lines;
line;
graphics;
create ()
{
this.graphics = this.add.graphics({ lineStyle: { width: 4, color: 0xaa00aa, alpha: 0.6 } });
this.line = new Phaser.Geom.Line(100, 300, 400, 300);
this.lines = [];
}
update ()
{
Phaser.Geom.Line.Rotate(this.line, 0.03);
this.lines.push(Phaser.Geom.Line.Clone(this.line));
this.graphics.clear();
this.graphics.strokeLineShape(this.line);
for (let i = 0; i < this.lines.length; i++)
{
Phaser.Geom.Line.Offset(this.lines[i], 3, 0);
if (this.lines[i].left > 800)
{
this.lines.splice(i--, 1);
}
else
{
this.graphics.strokeLineShape(this.lines[i]);
}
}
}
}
const config = {
width: 800,
height: 600,
type: Phaser.AUTO,
parent: 'phaser-example',
scene: Example
};
const game = new Phaser.Game(config);