forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Final commit, the wip/examples folder can be removed,
- Loading branch information
Webeled
committed
Sep 30, 2013
1 parent
bdc8ede
commit 933edb2
Showing
6 changed files
with
201 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
$title = "Multi Touch"; | ||
require('../head.php'); | ||
?> | ||
|
||
<script type="text/javascript"> | ||
|
||
(function () { | ||
|
||
function loadStarted(size) { | ||
console.log('Loader started, queue size:', size); | ||
} | ||
|
||
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize | ||
function fileLoaded(progress, key, success, remaining, total) { | ||
console.log('File Loaded:', key); | ||
console.log('Progress: ' + progress + '%'); | ||
console.log('File: ' + remaining + ' out of ' + total); | ||
} | ||
|
||
function loadCompleted() { | ||
|
||
console.log('Loader finished'); | ||
|
||
// Let's try adding an image to the DOM | ||
document.body.appendChild(game.cache.getImage('cockpit')); | ||
|
||
// And some text | ||
var para = document.createElement('pre'); | ||
para.innerHTML = game.cache.getText('copyright'); | ||
document.body.appendChild(para); | ||
|
||
} | ||
|
||
var game = new Phaser.Game(320, 240, Phaser.AUTO, '', {preload:preload}); | ||
|
||
function preload () { | ||
|
||
game.load.image('cockpit', 'assets/pics/cockpit.png'); | ||
game.load.image('rememberMe', 'assets/pics/remember-me.jpg'); | ||
game.load.image('overdose', 'assets/pics/lance-overdose-loader_eye.png'); | ||
game.load.text('copyright', 'assets/warning - copyright.txt'); | ||
|
||
game.load.onLoadStart.add(loadStarted, this); | ||
game.load.onFileComplete.add(fileLoaded, this); | ||
game.load.onLoadComplete.add(loadCompleted, this); | ||
|
||
} | ||
|
||
|
||
|
||
})(); | ||
|
||
</script> | ||
|
||
|
||
|
||
<?php | ||
require('../foot.php'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
$title = "Loading and caching a spritesheet"; | ||
require('../head.php'); | ||
?> | ||
|
||
<script type="text/javascript"> | ||
|
||
(function () { | ||
|
||
function loadStarted(size) { | ||
console.log('Loader started, queue size:', size); | ||
} | ||
|
||
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize | ||
function fileLoaded(progress, key, success, remaining, total) { | ||
console.log('File Loaded:', key); | ||
console.log('Progress: ' + progress + '%'); | ||
console.log('File: ' + remaining + ' out of ' + total); | ||
} | ||
|
||
function loadCompleted() { | ||
|
||
console.log('Loader finished'); | ||
|
||
// Let's try adding an image to the DOM | ||
document.body.appendChild(game.cache.getImage('mummy')); | ||
|
||
// Dump the animation data out | ||
console.log(game.cache.getFrameData('mummy')); | ||
} | ||
|
||
var game = new Phaser.Game(320, 240, Phaser.AUTO, '', {preload:preload}); | ||
|
||
function preload () { | ||
|
||
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45); | ||
|
||
game.load.onLoadStart.add(loadStarted, this); | ||
game.load.onFileComplete.add(fileLoaded, this); | ||
game.load.onLoadComplete.add(loadCompleted, this); | ||
|
||
} | ||
|
||
|
||
|
||
})(); | ||
|
||
</script> | ||
|
||
|
||
|
||
<?php | ||
require('../foot.php'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
$title = "Random Data Generators"; | ||
require('../head.php'); | ||
?> | ||
|
||
<script type="text/javascript"> | ||
|
||
(function () { | ||
|
||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create }); | ||
|
||
|
||
function create() { | ||
|
||
game.stage.backgroundColor = '#454645'; | ||
|
||
var style = { font: "14px Arial", fill: "#ff0044", align: "center" }; | ||
|
||
game.add.text(10,20,game.rnd.integer()); | ||
game.add.text(10,40,game.rnd.frac()); | ||
game.add.text(10,60,game.rnd.real()); | ||
game.add.text(10,80,game.rnd.integerInRange(100,200)); | ||
|
||
} | ||
|
||
})(); | ||
|
||
</script> | ||
|
||
<?php | ||
require('../foot.php'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
$title = "Sprite is out of world bounds"; | ||
require('../head.php'); | ||
?> | ||
|
||
<script type="text/javascript"> | ||
|
||
(function () { | ||
|
||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create}); | ||
|
||
function preload() { | ||
game.load.image('alien', 'assets/sprites/space-baddie.png'); | ||
game.load.image('ship', 'assets/sprites/shmup-ship.png'); | ||
} | ||
|
||
var player, | ||
aliens; | ||
|
||
function create() { | ||
|
||
player = game.add.sprite(400, 500, 'ship'); | ||
player.anchor.setTo(0.5, 0.5); | ||
|
||
aliens = game.add.group(); | ||
|
||
for (var y = 0; y < 4; y++) | ||
{ | ||
for (var x = 0; x < 10; x++) | ||
{ | ||
var alien = aliens.create(200 + x * 48, y * 50, 'alien'); | ||
alien.name = 'alien' + x.toString() + y.toString(); | ||
alien.events.onOutOfBounds.add(alienOut, this); | ||
alien.body.velocity.y = 50 + Math.random() * 200; | ||
} | ||
} | ||
|
||
} | ||
|
||
function alienOut(alien) { | ||
|
||
// Move the alien to the top of the screen again | ||
alien.reset(alien.x, -32); | ||
// And give it a new random velocity | ||
alien.body.velocity.y = 50 + Math.random() * 200; | ||
|
||
} | ||
|
||
})(); | ||
</script> | ||
|
||
<?php | ||
require('../foot.php'); | ||
?> |