Skip to content

Commit f812b92

Browse files
committed
Creating test cases.
1 parent a145068 commit f812b92

3 files changed

Lines changed: 323 additions & 101 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<title>phaser.js - a new beginning</title>
5+
<?php
6+
require('js.php');
7+
?>
8+
</head>
9+
<body>
10+
11+
<script type="text/javascript">
12+
13+
(function () {
14+
15+
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
16+
17+
function preload() {
18+
19+
game.load.image('atari', 'assets/sprites/atari130xe.png');
20+
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
21+
22+
}
23+
24+
var sprite1;
25+
var sprite2;
26+
27+
function create() {
28+
29+
game.stage.backgroundColor = '#2d2d2d';
30+
31+
// This will check Sprite vs. Sprite collision
32+
33+
sprite1 = game.add.sprite(50, 200, 'atari');
34+
sprite1.name = 'atari';
35+
sprite1.body.velocity.x = 100;
36+
37+
sprite2 = game.add.sprite(700, 220, 'mushroom');
38+
sprite2.name = 'mushroom';
39+
sprite2.body.velocity.x = -100;
40+
41+
}
42+
43+
function update() {
44+
45+
// object1, object2, collideCallback, processCallback, callbackContext
46+
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
47+
48+
}
49+
50+
function collisionHandler (obj1, obj2) {
51+
52+
game.stage.backgroundColor = '#992d2d';
53+
54+
console.log(obj1.name + ' collided with ' + obj2.name);
55+
56+
}
57+
58+
function render() {
59+
}
60+
61+
})();
62+
</script>
63+
64+
</body>
65+
</html>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<title>phaser.js - a new beginning</title>
5+
<?php
6+
require('js.php');
7+
?>
8+
</head>
9+
<body>
10+
11+
<script type="text/javascript">
12+
13+
(function () {
14+
15+
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
16+
17+
function preload() {
18+
19+
game.load.image('atari', 'assets/sprites/atari130xe.png');
20+
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
21+
22+
}
23+
24+
var sprite1;
25+
var sprite2;
26+
27+
function create() {
28+
29+
game.stage.backgroundColor = '#2d2d2d';
30+
31+
// This will check Sprite vs. Sprite collision using a custom process callback
32+
33+
sprite1 = game.add.sprite(50, 200, 'atari');
34+
sprite1.name = 'atari';
35+
sprite1.body.velocity.x = 100;
36+
37+
sprite2 = game.add.sprite(700, 220, 'mushroom');
38+
sprite2.name = 'mushroom';
39+
sprite2.body.velocity.x = -100;
40+
41+
}
42+
43+
function update() {
44+
45+
// object1, object2, collideCallback, processCallback, callbackContext
46+
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
47+
48+
}
49+
50+
function processHandler (obj1, obj2) {
51+
52+
// This function can perform your own additional checks on the 2 objects that collided.
53+
// For example you could test for velocity, health, etc.
54+
// If you want the collision to be deemed successful this function must return true.
55+
// In which case the collisionHandler will be called, otherwise it won't.
56+
// Note: the objects will have already collided and separated by this point.
57+
58+
}
59+
60+
function collisionHandler (obj1, obj2) {
61+
62+
game.stage.backgroundColor = '#992d2d';
63+
64+
console.log(obj1.name + ' collided with ' + obj2.name);
65+
66+
}
67+
68+
function render() {
69+
}
70+
71+
})();
72+
</script>
73+
74+
</body>
75+
</html>

0 commit comments

Comments
 (0)