Revamping the examples area.

This commit is contained in:
photonstorm committed 2013-10-22 03:58:20 +01:00
1 parent 82df8c9f54
commit 07724e5001
380 files changed
+8619 -10707

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@
$buildLog = "Building version $version \n\n";
$header = "";
$js = file(dirname(__FILE__) . '/../examples/js.php');
$js = file(dirname(__FILE__) . '/../examples/phaser-debug-js.php');
$output = "";
for ($i = 0; $i < count($js); $i++)
+1 -1
View File
@@ -9,7 +9,7 @@
*
* Phaser - http://www.phaser.io
*
* v1.0.7 - Built at: Fri, 18 Oct 2013 01:36:29 +0100
* v1.0.7 - Built at: Tue, 22 Oct 2013 00:54:52 +0100
*
* By Richard Davey http://www.photonstorm.com @photonstorm
*
@@ -1,52 +0,0 @@
<?php
$title = "Animation Wraparound";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create,update:update });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
}
var bot;
function create() {
// This sprite is using a texture atlas for all of its animation data
bot = game.add.sprite(200, 200, 'bot');
// Here we add a new animation called 'run'
// We haven't specified any frames because it's using every frame in the texture atlas
bot.animations.add('run');
// And this starts the animation playing by using its key ("run")
// 15 is the frame rate (15fps)
// true means it will loop when it finishes
bot.animations.play('run', 15, true);
}
function update() {
bot.x -= 2;
if (bot.x < -bot.width)
{
bot.x = game.world.width;
}
}
</script>
<?php
require('../foot.php');
?>
@@ -0,0 +1,39 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
var bot;
function create() {
bot = game.add.sprite(200, 200, 'bot');
bot.animations.add('run');
bot.animations.play('run', 15, true);
game.input.onDown.addOnce(changeMummy, this);
}
function changeMummy() {
bot.loadTexture('mummy', 0);
bot.animations.add('walk');
bot.animations.play('walk', 30, true);
}
function render() {
game.debug.renderSpriteBounds(bot);
}
-51
View File
@@ -1,51 +0,0 @@
<?php
$title = "Changing a Sprite Texture";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, render: render });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
var bot;
function create() {
bot = game.add.sprite(200, 200, 'bot');
bot.animations.add('run');
bot.animations.play('run', 15, true);
game.input.onDown.addOnce(changeMummy, this);
}
function changeMummy() {
bot.loadTexture('mummy', 0);
bot.animations.add('walk');
bot.animations.play('walk', 30, true);
}
function render() {
game.debug.renderSpriteBounds(bot);
}
</script>
<?php
require('../foot.php');
?>
-144
View File
@@ -1,144 +0,0 @@
<?php
$title = "Animation from a Texture Atlas";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create});
function preload() {
// Texture Atlas Method 2
//
// In this example we assume that the TexturePacker JSON data is a real json object stored as a var
// (in this case botData)
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
}
var bot;
function create() {
bot = game.add.sprite(game.world.centerX, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
}
var botData = {
"frames": [
{
"filename": "running bot.swf/0000",
"frame": { "x": 34, "y": 128, "w": 56, "h": 60 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 2, "w": 56, "h": 60 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0001",
"frame": { "x": 54, "y": 0, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0002",
"frame": { "x": 54, "y": 58, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0003",
"frame": { "x": 0, "y": 192, "w": 34, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0004",
"frame": { "x": 0, "y": 64, "w": 54, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0005",
"frame": { "x": 196, "y": 0, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0006",
"frame": { "x": 0, "y": 0, "w": 54, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0007",
"frame": { "x": 140, "y": 0, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0008",
"frame": { "x": 34, "y": 188, "w": 50, "h": 60 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 3, "y": 2, "w": 50, "h": 60 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0009",
"frame": { "x": 0, "y": 128, "w": 34, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0010",
"frame": { "x": 84, "y": 188, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
}],
"meta": {
"app": "http://www.texturepacker.com",
"version": "1.0",
"image": "running_bot.png",
"format": "RGBA8888",
"size": { "w": 252, "h": 256 },
"scale": "0.2",
"smartupdate": "$TexturePacker:SmartUpdate:fb56f261b1eb04e3215824426595f64c$"
}
};
</script>
<?php
require('../foot.php');
?>
@@ -1,38 +0,0 @@
<?php
$title = "Animation from a Texture Atlas From TexturePacker";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
}
function create() {
// This sprite is using a texture atlas for all of its animation data
var bot = game.add.sprite(200, 200, 'bot');
// Here we add a new animation called 'run'
// We haven't specified any frames because it's using every frame in the texture atlas
bot.animations.add('run');
// And this starts the animation playing by using its key ("run")
// 15 is the frame rate (15fps)
// true means it will loop when it finishes
bot.animations.play('run', 15, true);
}
</script>
<?php
require('../foot.php');
?>
+126
View File
@@ -0,0 +1,126 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create});
function preload() {
// Texture Atlas Method 2
//
// In this example we assume that the TexturePacker JSON data is a real json object stored as a var
// (in this case botData)
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
}
var bot;
function create() {
bot = game.add.sprite(game.world.centerX, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
}
var botData = {
"frames": [
{
"filename": "running bot.swf/0000",
"frame": { "x": 34, "y": 128, "w": 56, "h": 60 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 2, "w": 56, "h": 60 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0001",
"frame": { "x": 54, "y": 0, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0002",
"frame": { "x": 54, "y": 58, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0003",
"frame": { "x": 0, "y": 192, "w": 34, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0004",
"frame": { "x": 0, "y": 64, "w": 54, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0005",
"frame": { "x": 196, "y": 0, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0006",
"frame": { "x": 0, "y": 0, "w": 54, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0007",
"frame": { "x": 140, "y": 0, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0008",
"frame": { "x": 34, "y": 188, "w": 50, "h": 60 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 3, "y": 2, "w": 50, "h": 60 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0009",
"frame": { "x": 0, "y": 128, "w": 34, "h": 64 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },
"sourceSize": { "w": 56, "h": 64 }
},
{
"filename": "running bot.swf/0010",
"frame": { "x": 84, "y": 188, "w": 56, "h": 58 },
"rotated": false,
"trimmed": true,
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
"sourceSize": { "w": 56, "h": 64 }
}],
"meta": {
"app": "http://www.texturepacker.com",
"version": "1.0",
"image": "running_bot.png",
"format": "RGBA8888",
"size": { "w": 252, "h": 256 },
"scale": "0.2",
"smartupdate": "$TexturePacker:SmartUpdate:fb56f261b1eb04e3215824426595f64c$"
}
};
+35
View File
@@ -0,0 +1,35 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
}
var bot;
function create() {
// This sprite is using a texture atlas for all of its animation data
bot = game.add.sprite(200, 200, 'bot');
// Here we add a new animation called 'run'
// We haven't specified any frames because it's using every frame in the texture atlas
bot.animations.add('run');
// And this starts the animation playing by using its key ("run")
// 15 is the frame rate (15fps)
// true means it will loop when it finishes
bot.animations.play('run', 15, true);
}
function update() {
bot.x -= 2;
if (bot.x < -bot.width)
{
bot.x = game.world.width;
}
}
+20
View File
@@ -0,0 +1,20 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.atlas('bot', 'assets/misc/NumberSprite.png', 'assets/misc/NumberSprite.json');
}
function create() {
var bot = game.add.sprite(200, 200, 'bot');
bot.animations.add('num1', ['num10000','num10001','num10002','num10003','num10004','num10005'], 24, false, false);
bot.animations.add('num2', ['num20000','num20001','num20002','num20003','num20004','num20005'], 24, false, false);
bot.animations.add('num3', ['num30000','num30001','num30002','num30003','num30004','num30005'], 24, false, false);
// bot.animations.play('num1', 15, true);
// bot.animations.play('num2', 15, true);
// bot.animations.play('num3', 15, true);
}
-36
View File
@@ -1,36 +0,0 @@
<?php
$title = "Multiple Animations";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.atlas('bot', 'assets/misc/NumberSprite.png', 'assets/misc/NumberSprite.json');
}
function create() {
var bot = game.add.sprite(200, 200, 'bot');
bot.animations.add('num1', ['num10000','num10001','num10002','num10003','num10004','num10005'], 24, false, false);
bot.animations.add('num2', ['num20000','num20001','num20002','num20003','num20004','num20005'], 24, false, false);
bot.animations.add('num3', ['num30000','num30001','num30002','num30003','num30004','num30005'], 24, false, false);
// bot.animations.play('num1', 15, true);
//bot.animations.play('num2', 15, true);
// bot.animations.play('num3', 15, true);
}
</script>
<?php
require('../foot.php');
?>
+27
View File
@@ -0,0 +1,27 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
// 37x45 is the size of each frame
// There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some
// blank frames at the end, so we tell the loader how many to load
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
function create() {
var mummy = game.add.sprite(300, 200, 'mummy');
// Here we add a new animation called 'walk'
// Because we didn't give any other parameters it's going to make an animation from all available frames in the 'mummy' sprite sheet
mummy.animations.add('walk');
// And this starts the animation playing by using its key ("walk")
// 30 is the frame rate (30fps)
// true means it will loop when it finishes
mummy.animations.play('walk', 20, true);
}
-39
View File
@@ -1,39 +0,0 @@
<?php
$title = "Sprite Sheet";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
// 37x45 is the size of each frame
// There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some
// blank frames at the end, so we tell the loader how many to load
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
function create() {
var mummy = game.add.sprite(300, 200, 'mummy');
// Here we add a new animation called 'walk'
// Because we didn't give any other parameters it's going to make an animation from all available frames in the 'mummy' sprite sheet
mummy.animations.add('walk');
// And this starts the animation playing by using its key ("walk")
// 30 is the frame rate (30fps)
// true means it will loop when it finishes
mummy.animations.play('walk', 20, true);
}
</script>
<?php
require('../foot.php');
?>
@@ -0,0 +1,22 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
}
function create() {
// This sprite is using a texture atlas for all of its animation data
var bot = game.add.sprite(200, 200, 'bot');
// Here we add a new animation called 'run'
// We haven't specified any frames because it's using every frame in the texture atlas
bot.animations.add('run');
// And this starts the animation playing by using its key ("run")
// 15 is the frame rate (15fps)
// true means it will loop when it finishes
bot.animations.play('run', 15, true);
}
File renamed without changes.
Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

+28
View File
@@ -0,0 +1,28 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create});
function preload() {
game.load.image('spyro', 'assets/pics/spyro.png');
// Firefox doesn't support mp3 files, so use ogg
game.load.audio('squit', ['assets/audio/SoundEffects/squit.mp3', 'assets/audio/SoundEffects/squit.ogg']);
}
var s;
var music;
function create() {
game.stage.backgroundColor = '#255d3b';
music = game.add.audio('squit',1,true);
music.play('',0,1,true);
s = game.add.sprite(game.world.centerX, game.world.centerY, 'spyro');
s.anchor.setTo(0.5, 0.5);
}
-46
View File
@@ -1,46 +0,0 @@
<?php
$title = "Using samples and looping";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create});
function preload() {
game.load.image('spyro', 'assets/pics/spyro.png');
// Firefox doesn't support mp3 files, so use ogg
game.load.audio('squit', ['assets/audio/SoundEffects/squit.mp3', 'assets/audio/SoundEffects/squit.ogg']);
}
var s;
var music;
function create() {
game.stage.backgroundColor = '#255d3b';
music = game.add.audio('squit',1,true);
music.play('',0,1,true);
s = game.add.sprite(game.world.centerX, game.world.centerY, 'spyro');
s.anchor.setTo(0.5, 0.5);
}
</script>
<?php
require('../foot.php');
?>
+51
View File
@@ -0,0 +1,51 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
// Firefox doesn't support mp3 files, so use ogg
game.load.audio('boden', ['assets/audio/bodenstaendig_2000_in_rock_4bit.mp3', 'assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']);
}
var s;
var music;
function create() {
game.stage.backgroundColor = '#182d3b';
game.input.touch.preventDefault = false;
music = game.add.audio('boden');
music.play();
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
s.anchor.setTo(0.5, 0.5);
game.input.onDown.add(changeVolume, this);
}
function changeVolume(pointer) {
if (pointer.y < 300)
{
music.volume += 0.1;
}
else
{
music.volume -= 0.1;
}
}
function update() {
s.rotation += 0.01;
}
function render() {
game.debug.renderSoundInfo(music, 20, 32);
}
-66
View File
@@ -1,66 +0,0 @@
<?php
$title = "Playing an audio file";
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('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
// Firefox doesn't support mp3 files, so use ogg
game.load.audio('boden', ['assets/audio/bodenstaendig_2000_in_rock_4bit.mp3', 'assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']);
}
var s;
var music;
function create() {
game.stage.backgroundColor = '#182d3b';
game.input.touch.preventDefault = false;
music = game.add.audio('boden');
music.play();
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
s.anchor.setTo(0.5, 0.5);
game.input.onDown.add(changeVolume, this);
}
function changeVolume(pointer) {
if (pointer.y < 300)
{
music.volume += 0.1;
}
else
{
music.volume -= 0.1;
}
}
function update() {
s.rotation += 0.01;
}
function render() {
game.debug.renderSoundInfo(music, 20, 32);
}
</script>
<?php
require('../foot.php');
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
require('funcs.php');
?>
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
</head>
<body>
<textarea style="width: 800px; height: 800px">
<?php
$output = "{\n";
foreach ($files as $key => $value)
{
if (is_array($value) && count($value) > 0)
{
$output .= "\"$key\": [\n";
$output .= printJSLinks($key, $value, 'json');
$output .= "],\n";
}
}
$output = rtrim($output);
$output = substr($output, 0, -1);
$output .= "\n}";
echo $output;
file_put_contents('examples.json', $output);
?>
</textarea>
</body>
</html>
+28
View File
@@ -0,0 +1,28 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.image('background','assets/misc/starfield.jpg');
}
var button;
var background;
function create() {
game.stage.backgroundColor = '#182d3b';
background = game.add.tileSprite(0, 0, 800, 600, 'background');
button = game.add.button(game.world.centerX - 95, 400, 'button', actionOnClick, this, 2, 1, 0);
}
function actionOnClick () {
background.visible =! background.visible;
}
-48
View File
@@ -1,48 +0,0 @@
<?php
$title = "Clicking on a button ";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.image('background','assets/misc/starfield.jpg');
}
var button,
background;
function create() {
game.stage.backgroundColor = '#182d3b';
background=game.add.tileSprite(0, 0, 800, 600, 'background');
button = game.add.button(game.world.centerX, 400, 'button', actionOnClick, this, 2, 1, 0);
}
function actionOnClick () {
background.visible=!background.visible;
}
</script>
<?php
require('../foot.php');
?>
+32
View File
@@ -0,0 +1,32 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.spritesheet('button', 'assets/buttons/number-buttons-90x90.png', 90,90);
game.load.image('background','assets/misc/starfield.jpg');
}
var button;
var background;
function create() {
// Setting the background colour
game.stage.backgroundColor = '#182d3b';
// The numbers given in parameters are the indexes of the frames, in this order: over, out, down
button = game.add.button(game.world.centerX, game.world.centerY, 'button', actionOnClick, this, 1, 0, 2);
// setting the anchor to the center
button.anchor.setTo(0.5, 0.5);
}
function actionOnClick () {
// Manually changing the frames of the button, i.e, how it will look when you play with it
button.setFrames(4, 3, 5);
}
-55
View File
@@ -1,55 +0,0 @@
<?php
$title = "Programmatically changing the frames";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.spritesheet('button', 'assets/buttons/number-buttons-90x90.png', 90,90);
game.load.image('background','assets/misc/starfield.jpg');
}
var button,
background;
function create() {
//setting the background colour
game.stage.backgroundColor = '#182d3b';
// the numbers given in parameters are the indexes of the frames, in this order :
// over,out,down
button = game.add.button(game.world.centerX, game.world.centerY, 'button', actionOnClick, this, 1, 0, 2);
//setting the anchor to the center
button.anchor.setTo(0.5,0.5);
}
function actionOnClick () {
//manually changing the frames of the button, i.e, how it will look when you play with it
button.setFrames(4,3,5);
console.log('You clicked on the button');
}
</script>
<?php
require('../foot.php');
?>
+36
View File
@@ -0,0 +1,36 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create,update : update });
function preload() {
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.image('background','assets/misc/starfield.jpg');
}
var button;
var background;
function create() {
game.stage.backgroundColor = '#cccccc';
// The numbers given in parameters are the indexes of the frames, in this order: over, out, down
button = game.add.button(game.world.centerX, game.world.centerY, 'button', actionOnClick, this, 2, 1, 0);
// Set the anchor of the sprite in the center, otherwise it would rotate around the top-left corner
button.anchor.setTo(0.5, 0.5);
}
function actionOnClick () {
alert("Though I'm turning around, you can still click on me");
}
function update () {
button.angle += 1;
}
-47
View File
@@ -1,47 +0,0 @@
<?php
$title = "Rotating a button";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create,update : update });
function preload() {
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
game.load.image('background','assets/misc/starfield.jpg');
}
var button;
var background;
function create() {
game.stage.backgroundColor = '#cccccc';
// The numbers given in parameters are the indexes of the frames, in this order: over, out, down
button = game.add.button(game.world.centerX, game.world.centerY, 'button', actionOnClick, this, 2, 1, 0);
// Set the anchor of the sprite in the center, otherwise it would rotate around the top-left corner
button.anchor.setTo(0.5,0.5);
}
function actionOnClick () {
alert("Though I'm turning around, you can still click on me");
}
function update () {
button.angle += 1;
}
</script>
<?php
require('../foot.php');
?>
+60
View File
@@ -0,0 +1,60 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
var baddie;
var keys = Phaser.Keyboard;
function preload() {
game.load.image('background','assets/misc/starfield.jpg');
game.load.image('ufo','assets/sprites/ufo.png');
game.load.image('baddie','assets/sprites/space-baddie.png');
}
function create() {
game.add.tileSprite(0, 0, 2000, 2000, 'background');
game.world.setBounds(0, 0, 1400,1400);
for (var i = 0; i < 10; i++)
{
game.add.sprite(game.world.randomX, game.world.randomY, 'ufo');
}
baddie = game.add.sprite(150, 320, 'baddie');
game.camera.follow(baddie);
}
function update() {
baddie.body.velocity.setTo(0, 0);
if (game.input.keyboard.isDown(keys.LEFT) && !game.input.keyboard.isDown(keys.RIGHT))
{
baddie.body.velocity.x = -155;
}
else if (game.input.keyboard.isDown(keys.RIGHT) && !game.input.keyboard.isDown(keys.LEFT))
{
baddie.body.velocity.x = 155;
}
else if (game.input.keyboard.isDown(keys.UP) && !game.input.keyboard.isDown(keys.DOWN))
{
baddie.angle = 90;
baddie.body.velocity.y = -155;
}
else if (game.input.keyboard.isDown(keys.DOWN) && !game.input.keyboard.isDown(keys.UP))
{
baddie.angle = 90;
baddie.body.velocity.y = 155;
}
}
function render() {
game.debug.renderCameraInfo(game.camera, 32, 32);
}
-86
View File
@@ -1,86 +0,0 @@
<?php
$title = "Following the player";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
var baddie,
keys=Phaser.Keyboard;
function preload() {
game.load.image('background','assets/misc/starfield.jpg');
game.load.image('ufo','assets/sprites/ufo.png');
game.load.image('baddie','assets/sprites/space-baddie.png');
}
function create() {
game.add.tileSprite(0, 0, 2000, 2000, 'background');
game.world.setBounds(0, 0, 1400,1400);
for(var i=0,nb=10;i<nb;i++){
game.add.sprite(game.world.randomX,game.world.randomY,'ufo');
}
baddie=game.add.sprite(150,320,'baddie');
game.camera.follow(baddie);
}
function update() {
baddie.body.velocity.x=baddie.body.velocity.y=0;
if(game.input.keyboard.isDown(keys.LEFT) && !game.input.keyboard.isDown(keys.RIGHT)){
baddie.body.velocity.x=-155;
}
else if(game.input.keyboard.isDown(keys.RIGHT) && !game.input.keyboard.isDown(keys.LEFT)){
baddie.body.velocity.x=155;
}
else if(game.input.keyboard.isDown(keys.UP) && !game.input.keyboard.isDown(keys.DOWN)){
baddie.angle=90;
baddie.body.velocity.y=-155;
}
else if(game.input.keyboard.isDown(keys.DOWN) && !game.input.keyboard.isDown(keys.UP)){
baddie.angle=90;
baddie.body.velocity.y=155;
}
}
function render() {
game.debug.renderCameraInfo(game.camera, 32, 32);
// game.debug.renderSpriteInfo(d, 32, 200);
// game.debug.renderWorldTransformInfo(d, 32, 200);
// game.debug.renderLocalTransformInfo(d, 32, 400);
// game.debug.renderSpriteCorners(d, false, true);
}
</script>
<?php
require('../foot.php');
?>
+48
View File
@@ -0,0 +1,48 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
}
var s;
function create() {
game.stage.backgroundColor = '#182d3b';
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
s.anchor.setTo(0.5, 0.5);
}
function update() {
s.rotation += 0.01;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
s.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
s.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
s.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
s.y += 4;
}
}
function render() {
game.debug.renderSpriteCorners(s, true, true);
game.debug.renderSpriteInfo(s, 20, 32);
}
-64
View File
@@ -1,64 +0,0 @@
<?php
$title = "Camera Cull";
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('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
}
var s;
function create() {
game.stage.backgroundColor = '#182d3b';
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
s.anchor.setTo(0.5, 0.5);
}
function update() {
s.rotation += 0.01;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
s.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
s.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
s.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
s.y += 4;
}
}
function render() {
game.debug.renderSpriteCorners(s, true, true);
game.debug.renderSpriteInfo(s, 20, 32);
}
</script>
<?php
require('../foot.php');
?>
+109
View File
@@ -0,0 +1,109 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
var ufo;
var Keys = Phaser.Keyboard;
var speed = 4;
var style = 'default';
function preload() {
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
game.load.image('sky', 'assets/tests/sky-2x.png');
game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
game.load.image('ufo','assets/sprites/ufo.png');
game.load.image('baddie','assets/sprites/space-baddie.png');
game.load.spritesheet('button', 'assets/buttons/follow-style-button.png', 224, 70);
}
function create() {
// Make the world larger than the actual canvas
game.world.setBounds(0, 0, 1400, 1400);
for (var i=0; i < 10; i++)
{
game.add.sprite(game.world.randomX, game.world.randomY, 'baddie');
}
// Background images
game.add.tileSprite(0, 0, 1400, 600, 'sky');
game.add.sprite(0, 360, 'ground');
game.add.sprite(0, 400, 'river');
game.add.sprite(200, 120, 'cloud0');
game.add.sprite(-60, 120, 'cloud1');
game.add.sprite(900, 170, 'cloud2');
// ufo sprite
ufo = game.add.sprite(300, 240, 'ufo');
//registration point
ufo.anchor.setTo(0.5, 0.5);
game.camera.follow(ufo);
// follow style switch buttons
btn0 = game.add.button(6, 40, 'button', lockonFollow,this, 0, 0, 0);
btn1 = game.add.button(6, 120, 'button', platformerFollow,this, 1, 1, 1);
btn2 = game.add.button(6, 200, 'button', topdownFollow,this, 2, 2, 2);
btn3 = game.add.button(6, 280, 'button', topdownTightFollow,this, 3, 3, 3);
}
function lockonFollow() {
game.camera.follow(ufo, Phaser.Camera.FOLLOW_LOCKON);
style = 'STYLE_LOCKON';
}
function platformerFollow() {
game.camera.follow(ufo, Phaser.Camera.FOLLOW_PLATFORMER);
style = 'STYLE_PLATFORMER';
}
function topdownFollow() {
game.camera.follow(ufo, Phaser.Camera.FOLLOW_TOPDOWN);
style = 'STYLE_TOPDOWN';
}
function topdownTightFollow() {
game.camera.follow(ufo, Phaser.Camera.FOLLOW_TOPDOWN_TIGHT);
style = 'STYLE_TOPDOWN_TIGHT';
}
function update() {
if (game.input.keyboard.isDown(Keys.LEFT))
{
ufo.x -= speed;
ufo.angle = -15;
}
else if (game.input.keyboard.isDown(Keys.RIGHT))
{
ufo.x += speed;
ufo.angle = 15;
}
else if (game.input.keyboard.isDown(Keys.UP))
{
ufo.y -= speed;
}
else if (game.input.keyboard.isDown(Keys.DOWN))
{
ufo.y += speed;
}
else
{
ufo.angle = 0;
}
}
function render () {
game.debug.renderText('Click buttons to switch follow styles', 32, 32);
game.debug.renderText('Current style: ' + style, 32, 64);
}
-130
View File
@@ -1,130 +0,0 @@
<?php
$title = "Follow Styles";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update,render : render });
var ufo,
Keys=Phaser.Keyboard,
speed=4,
style='default';
function preload() {
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
game.load.image('sky', 'assets/tests/sky-2x.png');
game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
game.load.image('ufo','assets/sprites/ufo.png');
game.load.image('baddie','assets/sprites/space-baddie.png');
game.load.spritesheet('button', 'assets/buttons/follow-style-button.png', 224, 70);
}
function create() {
//make the world larger than the actual canvas
game.world.setBounds(0,0,1400,1400);
for(var i=0,nb=10;i<nb;i++){
game.add.sprite(game.world.randomX,game.world.randomY,'baddie');
}
// background images
game.add.tileSprite(0, 0,1400,600, 'sky');
game.add.sprite(0, 360, 'ground');
game.add.sprite(0, 400, 'river');
game.add.sprite(200, 120, 'cloud0');
game.add.sprite(-60, 120, 'cloud1');
game.add.sprite(900, 170, 'cloud2');
// ufo sprite
ufo = game.add.sprite(300, 240, 'ufo');
//registration point
ufo.anchor.setTo(0.5, 0.5);
game.camera.follow(ufo);
// follow style switch buttons
btn0 = game.add.button(6, 40, 'button', lockonFollow,this, 0, 0, 0);
btn1 = game.add.button(6, 120, 'button', platformerFollow,this, 1, 1, 1);
btn2 = game.add.button(6, 200, 'button', topdownFollow,this, 2, 2, 2);
btn3 = game.add.button(6, 280, 'button', topdownTightFollow,this, 3, 3, 3);
}
function lockonFollow() {
game.camera.follow(ufo, Phaser.Camera.FOLLOW_LOCKON);
style = 'STYLE_LOCKON';
}
function platformerFollow() {
game.camera.follow(ufo, Phaser.Camera.FOLLOW_PLATFORMER);
style = 'STYLE_PLATFORMER';
}
function topdownFollow() {
game.camera.follow(ufo, Phaser.Camera.FOLLOW_TOPDOWN);
style = 'STYLE_TOPDOWN';
}
function topdownTightFollow() {
game.camera.follow(ufo, Phaser.Camera.FOLLOW_TOPDOWN_TIGHT);
style = 'STYLE_TOPDOWN_TIGHT';
}
function update() {
if (game.input.keyboard.isDown(Keys.LEFT)) {
ufo.x -= speed;
ufo.angle = -15;
}
else if (game.input.keyboard.isDown(Keys.RIGHT)) {
ufo.x += speed;
ufo.angle = 15;
}
else if (game.input.keyboard.isDown(Keys.UP)) {
ufo.y -= speed;
}
else if (game.input.keyboard.isDown(Keys.DOWN)) {
ufo.y += speed;
}
else {
ufo.angle = 0;
}
}
function render () {
game.context.fillStyle = '#fff';
game.context.font="24px Courier";
game.context.fillText('Click buttons to switch between different styles.', 60, 220);
game.context.fillText('Current style: ' + style, 60, 250);
}
</script>
<?php
require('../foot.php');
?>
+52
View File
@@ -0,0 +1,52 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
function preload() {
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
function create() {
game.stage.backgroundColor = '#2d2d2d';
// Make our game world 2000x2000 pixels in size (the default is to match the game size)
game.world.setBounds(0,0,2000, 2000);
for (var i = 0; i < 50; i++)
{
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
}
for (var i = 0; i < 50; i++)
{
game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
}
for (var i = 0; i < 50; i++)
{
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
}
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += 4;
}
}
-68
View File
@@ -1,68 +0,0 @@
<?php
$title = "Moving the Camera";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
function create() {
game.stage.backgroundColor = '#2d2d2d';
// Make our game world 2000x2000 pixels in size (the default is to match the game size)
game.world.setBounds(0,0,2000, 2000);
for (var i = 0; i < 50; i++)
{
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
}
for (var i = 0; i < 50; i++)
{
game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
}
for (var i = 0; i < 50; i++)
{
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
}
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += 4;
}
}
</script>
<?php
require('../foot.php');
?>
Loaded 100 of 380 files, more files were not shown because too many files have changed in this diff. Show more