Skip to content

Commit 933edb2

Browse files
author
Webeled
committed
Final Commit of the day,
Final commit, the wip/examples folder can be removed,
1 parent bdc8ede commit 933edb2

6 files changed

Lines changed: 201 additions & 2 deletions

File tree

examples/input/game scale.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
(function () {
99

10-
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create,update:update,render:render});
10+
var game = new Phaser.Game(320, 240, Phaser.CANVAS, '', { preload: preload, create: create,update:update,render:render});
1111

1212
function preload() {
1313

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
$title = "Multi Touch";
3+
require('../head.php');
4+
?>
5+
6+
<script type="text/javascript">
7+
8+
(function () {
9+
10+
function loadStarted(size) {
11+
console.log('Loader started, queue size:', size);
12+
}
13+
14+
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize
15+
function fileLoaded(progress, key, success, remaining, total) {
16+
console.log('File Loaded:', key);
17+
console.log('Progress: ' + progress + '%');
18+
console.log('File: ' + remaining + ' out of ' + total);
19+
}
20+
21+
function loadCompleted() {
22+
23+
console.log('Loader finished');
24+
25+
// Let's try adding an image to the DOM
26+
document.body.appendChild(game.cache.getImage('cockpit'));
27+
28+
// And some text
29+
var para = document.createElement('pre');
30+
para.innerHTML = game.cache.getText('copyright');
31+
document.body.appendChild(para);
32+
33+
}
34+
35+
var game = new Phaser.Game(320, 240, Phaser.AUTO, '', {preload:preload});
36+
37+
function preload () {
38+
39+
game.load.image('cockpit', 'assets/pics/cockpit.png');
40+
game.load.image('rememberMe', 'assets/pics/remember-me.jpg');
41+
game.load.image('overdose', 'assets/pics/lance-overdose-loader_eye.png');
42+
game.load.text('copyright', 'assets/warning - copyright.txt');
43+
44+
game.load.onLoadStart.add(loadStarted, this);
45+
game.load.onFileComplete.add(fileLoaded, this);
46+
game.load.onLoadComplete.add(loadCompleted, this);
47+
48+
}
49+
50+
51+
52+
})();
53+
54+
</script>
55+
56+
57+
58+
<?php
59+
require('../foot.php');
60+
?>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
$title = "Loading and caching a spritesheet";
3+
require('../head.php');
4+
?>
5+
6+
<script type="text/javascript">
7+
8+
(function () {
9+
10+
function loadStarted(size) {
11+
console.log('Loader started, queue size:', size);
12+
}
13+
14+
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize
15+
function fileLoaded(progress, key, success, remaining, total) {
16+
console.log('File Loaded:', key);
17+
console.log('Progress: ' + progress + '%');
18+
console.log('File: ' + remaining + ' out of ' + total);
19+
}
20+
21+
function loadCompleted() {
22+
23+
console.log('Loader finished');
24+
25+
// Let's try adding an image to the DOM
26+
document.body.appendChild(game.cache.getImage('mummy'));
27+
28+
// Dump the animation data out
29+
console.log(game.cache.getFrameData('mummy'));
30+
}
31+
32+
var game = new Phaser.Game(320, 240, Phaser.AUTO, '', {preload:preload});
33+
34+
function preload () {
35+
36+
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45);
37+
38+
game.load.onLoadStart.add(loadStarted, this);
39+
game.load.onFileComplete.add(fileLoaded, this);
40+
game.load.onLoadComplete.add(loadCompleted, this);
41+
42+
}
43+
44+
45+
46+
})();
47+
48+
</script>
49+
50+
51+
52+
<?php
53+
require('../foot.php');
54+
?>

examples/misc/net.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function render () {
1818
// Add some values to the query string
1919
game.debug.renderText('Query string with new values : '+game.net.updateQueryString('atari', '520'),game.world.centerX-400,80);
2020
game.debug.renderText('Query string with new values : '+game.net.updateQueryString('amiga', '1200'),game.world.centerX-400,100);
21-
game.debug.renderText('Query string with new values : '+game.net.updateQueryString('commodore', '64'),game.world.centerX-400,120);
2221

2322
console.log('Query String: '+game.net.getQueryString(),game.world.centerX-300,140);
2423
console.log('Query String Param: '+game.net.getQueryString('atari'),game.world.centerX-300,160);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
$title = "Random Data Generators";
3+
require('../head.php');
4+
?>
5+
6+
<script type="text/javascript">
7+
8+
(function () {
9+
10+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create });
11+
12+
13+
function create() {
14+
15+
game.stage.backgroundColor = '#454645';
16+
17+
var style = { font: "14px Arial", fill: "#ff0044", align: "center" };
18+
19+
game.add.text(10,20,game.rnd.integer());
20+
game.add.text(10,40,game.rnd.frac());
21+
game.add.text(10,60,game.rnd.real());
22+
game.add.text(10,80,game.rnd.integerInRange(100,200));
23+
24+
}
25+
26+
})();
27+
28+
</script>
29+
30+
<?php
31+
require('../foot.php');
32+
?>

examples/sprites/outOfBounds.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
$title = "Sprite is out of world bounds";
3+
require('../head.php');
4+
?>
5+
6+
<script type="text/javascript">
7+
8+
(function () {
9+
10+
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create});
11+
12+
function preload() {
13+
game.load.image('alien', 'assets/sprites/space-baddie.png');
14+
game.load.image('ship', 'assets/sprites/shmup-ship.png');
15+
}
16+
17+
var player,
18+
aliens;
19+
20+
function create() {
21+
22+
player = game.add.sprite(400, 500, 'ship');
23+
player.anchor.setTo(0.5, 0.5);
24+
25+
aliens = game.add.group();
26+
27+
for (var y = 0; y < 4; y++)
28+
{
29+
for (var x = 0; x < 10; x++)
30+
{
31+
var alien = aliens.create(200 + x * 48, y * 50, 'alien');
32+
alien.name = 'alien' + x.toString() + y.toString();
33+
alien.events.onOutOfBounds.add(alienOut, this);
34+
alien.body.velocity.y = 50 + Math.random() * 200;
35+
}
36+
}
37+
38+
}
39+
40+
function alienOut(alien) {
41+
42+
// Move the alien to the top of the screen again
43+
alien.reset(alien.x, -32);
44+
// And give it a new random velocity
45+
alien.body.velocity.y = 50 + Math.random() * 200;
46+
47+
}
48+
49+
})();
50+
</script>
51+
52+
<?php
53+
require('../foot.php');
54+
?>

0 commit comments

Comments
 (0)