-
Notifications
You must be signed in to change notification settings - Fork 757
/
Copy pathclone.js
49 lines (39 loc) · 958 Bytes
/
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
var config = {
width: 800,
height: 600,
type: Phaser.AUTO,
parent: 'phaser-example',
scene: {
create: create,
update: update
}
};
var game = new Phaser.Game(config);
var graphics;
var triangle;
var triangles;
function create ()
{
graphics = this.add.graphics({ lineStyle: { width: 4, color: 0xaaaa00, alpha: 0.6 } });
triangle = Phaser.Geom.Triangle.BuildEquilateral(200, 50, 200);
triangles = [];
}
function update ()
{
Phaser.Geom.Triangle.Rotate(triangle, 0.04);
triangles.push(Phaser.Geom.Triangle.Clone(triangle));
graphics.clear();
graphics.strokeTriangleShape(triangle);
for(var i = 0; i < triangles.length; i++)
{
Phaser.Geom.Triangle.Offset(triangles[i], 3, 1.5);
if(triangles[i].left > 800)
{
triangles.splice(i--, 1);
}
else
{
graphics.strokeTriangleShape(triangles[i]);
}
}
}