/
clone.js
50 lines (39 loc) · 1.09 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
class Example extends Phaser.Scene
{
triangles;
triangle;
graphics;
create ()
{
this.graphics = this.add.graphics({ lineStyle: { width: 4, color: 0xaaaa00, alpha: 0.6 } });
this.triangle = new Phaser.Geom.Triangle.BuildEquilateral(200, 50, 200);
this.triangles = [];
}
update ()
{
Phaser.Geom.Triangle.Rotate(this.triangle, 0.04);
this.triangles.push(Phaser.Geom.Triangle.Clone(this.triangle));
this.graphics.clear();
this.graphics.strokeTriangleShape(this.triangle);
for (let i = 0; i < this.triangles.length; i++)
{
Phaser.Geom.Triangle.Offset(this.triangles[i], 3, 1.5);
if (this.triangles[i].left > 800)
{
this.triangles.splice(i--, 1);
}
else
{
this.graphics.strokeTriangleShape(this.triangles[i]);
}
}
}
}
const config = {
width: 800,
height: 600,
type: Phaser.AUTO,
parent: 'phaser-example',
scene: Example
};
const game = new Phaser.Game(config);