forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransform.php
More file actions
131 lines (79 loc) · 2.93 KB
/
Copy pathtransform.php
File metadata and controls
131 lines (79 loc) · 2.93 KB
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
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
<?php
$title = "Transform Tests";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
game.load.image('flectrum', 'assets/sprites/flectrum.png');
}
var testGroup;
var sprite1;
var sprite2;
var sprite3;
function create() {
game.stage.backgroundColor = '#2d2d2d';
game.world.setBounds(-1000, -1000, 2000, 2000);
testGroup = game.add.group();
test2();
}
function test1 () {
// Test 1 - 2 sprites in world space (seems to work fine with local transform?)
sprite1 = game.add.sprite(-600, 200, 'atari');
sprite1.name = 'atari';
// sprite1.body.setSize(100, 100, 0, 0);
sprite2 = game.add.sprite(-100, 220, 'mushroom');
sprite2.name = 'mushroom';
game.camera.focusOn(sprite1);
game.camera.x += 300;
game.input.onDown.add(go1, this);
}
function test2 () {
// 1 sprite in world space (seems to work fine with local transform?) and 1 in a group
sprite1 = testGroup.create(0, -150, 'atari');
sprite1.name = 'atari';
sprite1.body.immovable = true;
// sprite1.body.setSize(100, 100, 0, 0);
sprite2 = game.add.sprite(-100, 150, 'mushroom');
sprite2.name = 'mushroom';
sprite3 = game.add.sprite(-200, 150, 'flectrum');
sprite3.name = 'tall';
testGroup.x = -600;
testGroup.y = 200;
game.camera.focusOn(sprite2);
game.camera.x -= 300;
game.input.onDown.add(go2, this);
}
function go1 () {
sprite1.body.velocity.x = 100;
sprite2.body.velocity.x = -100;
}
function go2 () {
sprite2.body.velocity.x = -100;
}
function update () {
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
// sprite3.angle += 0.5;
}
function collisionHandler (obj1, obj2) {
game.stage.backgroundColor = '#992d2d';
console.log(obj1.name + ' collided with ' + obj2.name);
}
function render() {
// game.debug.renderSpriteInfo(sprite1, 32, 32);
// game.debug.renderSpriteCollision(sprite1, 32, 400);
game.debug.renderSpriteCoords(sprite1, 32, 32);
game.debug.renderSpriteCoords(sprite2, 300, 32);
game.debug.renderCameraInfo(game.camera, 32, 500);
game.debug.renderSpriteBody(sprite1);
game.debug.renderSpriteBody(sprite2);
game.debug.renderSpriteBody(sprite3);
game.debug.renderGroupInfo(testGroup, 500, 500);
game.debug.renderPixel(testGroup.x, testGroup.y, 'rgb(255,255,0)');
}
</script>
<?php
require('../foot.php');
?>