Loader can now parse both JSON Hash and JSON Array formated texture atlas files.

This commit is contained in:
Richard Davey
2013-08-29 22:53:55 +01:00
parent 5b036557c0
commit 4c1dacfa02
10 changed files with 205 additions and 50 deletions
@@ -0,0 +1,44 @@
{"frames": {
"eggHead.png":
{
"frame": {"x":2,"y":169,"w":142,"h":157},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":142,"h":157},
"sourceSize": {"w":142,"h":157}
},
"flowerTop.png":
{
"frame": {"x":2,"y":328,"w":119,"h":181},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":119,"h":181},
"sourceSize": {"w":119,"h":181}
},
"helmlok.png":
{
"frame": {"x":123,"y":328,"w":123,"h":177},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":123,"h":177},
"sourceSize": {"w":123,"h":177}
},
"skully.png":
{
"frame": {"x":2,"y":2,"w":155,"h":165},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":155,"h":165},
"sourceSize": {"w":155,"h":165}
}},
"meta": {
"app": "http://www.texturepacker.com",
"version": "1.0",
"image": "SpriteSheet.png",
"format": "RGBA8888",
"size": {"w":256,"h":512},
"scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:9e3e5afd01ea8e418afabfbdcd724485$"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

+55
View File
@@ -0,0 +1,55 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }, false, true);
var bunny;
function preload() {
game.load.atlasJSONHash('monsters', 'assets/sprites/pixi_monsters.png', 'assets/sprites/pixi_monsters.json');
}
function create() {
var base = new PIXI.BaseTexture(game.cache.getImage('monsters'));
var texture = new PIXI.Texture(base);
bunny = new PIXI.Sprite(texture);
bunny.anchor.x = 0.5;
bunny.anchor.y = 0.5;
bunny.position.x = game.world.centerX;
bunny.position.y = game.world.centerY;
game.world.add(bunny);
}
function update() {
if (game.paused == false)
{
// bunny.rotation += 0.01;
// bunny.scale.x += 0.01;
// bunny.scale.y += 0.01;
}
}
})();
</script>
</body>
</html>