1+ <?php
2+ $ title = "Rotate point " ;
3+ require ('../head.php ' );
4+ ?>
5+
6+ <script type="text/javascript">
7+
8+
9+
10+ var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,update:update,render:render});
11+
12+ var p1;
13+ var p2;
14+ var p3;
15+ var p4;
16+
17+ var d2 = 0;
18+ var d3 = 0;
19+ var d4 = 0;
20+
21+ function create() {
22+
23+ p1 = new Phaser.Point(game.world.centerX, game.world.centerY);
24+ p2 = new Phaser.Point(p1.x - 50, p1.y - 50);
25+ p3 = new Phaser.Point(p2.x - 50, p2.y - 50);
26+ p4 = new Phaser.Point(p3.x - 50, p3.y - 50);
27+
28+ }
29+
30+ function update() {
31+
32+ p2.rotate(p1.x, p1.y, game.math.wrapAngle(d2), true, 150);
33+ p3.rotate(p2.x, p2.y, game.math.wrapAngle(d3), true, 50);
34+ p4.rotate(p3.x, p3.y, game.math.wrapAngle(d4), true, 100);
35+
36+ d2 += 1;
37+ d3 += 4;
38+ d4 += 6;
39+
40+ }
41+
42+ function render() {
43+
44+ game.context.strokeStyle = 'rgb(0,255,255)';
45+ game.context.beginPath();
46+ game.context.moveTo(p1.x, p1.y);
47+ game.context.lineTo(p2.x, p2.y);
48+ game.context.lineTo(p3.x, p3.y);
49+ game.context.lineTo(p4.x, p4.y);
50+ game.context.stroke();
51+ game.context.closePath();
52+
53+ game.context.fillStyle = 'rgb(255,255,0)';
54+ game.context.fillRect(p1.x, p1.y, 4, 4);
55+
56+ game.context.fillStyle = 'rgb(255,0,0)';
57+ game.context.fillRect(p2.x, p2.y, 4, 4);
58+
59+ game.context.fillStyle = 'rgb(0,255,0)';
60+ game.context.fillRect(p3.x, p3.y, 4, 4);
61+
62+ game.context.fillStyle = 'rgb(255,0,255)';
63+ game.context.fillRect(p4.x, p4.y, 4, 4);
64+
65+ }
66+ </script>
67+
68+ <?php
69+ require ('../foot.php ' );
70+ ?>
0 commit comments