Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Webeled committed Oct 11, 2013
1 parent 3acdad9 commit eb98998
Show file tree
Hide file tree
Showing 25 changed files with 1,335 additions and 0 deletions.
144 changes: 144 additions & 0 deletions examples/animation/Animation from a JSON object.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?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');
?>
38 changes: 38 additions & 0 deletions examples/animation/Animation from a texturePacker file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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');
?>
52 changes: 52 additions & 0 deletions examples/animation/animation wraparound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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');
?>
Binary file added examples/assets/maps/cybernoid.png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions examples/groups/add to group after creation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
$title = "Adding to group using 'add'";
require('../head.php');
?>

<script type="text/javascript">



var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create,render:render });

var friendAndFoe,
enemies;

function preload() {
game.load.image('ufo', 'assets/sprites/ufo.png');
game.load.image('baddie', 'assets/sprites/space-baddie.png');

}
function create() {

// Create some local groups for later use.
friendAndFoe = game.add.group();
enemies = game.add.group();

// Use game.add (GameObjectFactory) to create sprites, those
// newly created ones will be added to game.world.group
// automatically. While you can still use new to allocate and
// only add them to your own groups.
var ufo = game.add.sprite(200, 240, 'ufo');
friendAndFoe.add(ufo);


// Create some enemies using new keyword.
// (Don't forget to pass game as the first parameter.)
var enemy;
for (var i = 0; i < 16; i++) {

enemy = new Phaser.Sprite(game,
360 + Math.random() * 200, 120 + Math.random() * 200,
'baddie');

enemies.add(enemy);
}

}
function render() {

game.debug.renderText('ufo added to game.world.and "friendAndFoe" group', 20, 24);
game.debug.renderText('others ONLY added to "enemies" group', 20, 40);

}





</script>

<?php
require('../foot.php');
?>

Loading

0 comments on commit eb98998

Please sign in to comment.