phaser/TS Tests/textures/texture atlas 2.js

271 lines
7.5 KiB
JavaScript
Raw Normal View History

2013-07-13 11:38:59 +00:00
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
function preload() {
2013-08-02 17:32:26 +00:00
// Texture Atlas Method 2
2013-07-13 11:38:59 +00:00
//
// In this example we assume that the TexturePacker JSON data is a real json object stored as a var
// (in this case botData)
2013-08-02 17:32:26 +00:00
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
2013-07-13 11:38:59 +00:00
}
var bot;
function create() {
2013-08-02 17:32:26 +00:00
bot = game.add.sprite(game.stage.width, 300, 'bot');
2013-07-13 11:38:59 +00:00
bot.animations.add('run');
bot.animations.play('run', 10, true);
}
function update() {
2013-08-02 17:32:26 +00:00
bot.x -= 2;
if(bot.x < -bot.width) {
2013-08-02 17:32:26 +00:00
bot.x = game.stage.width;
2013-07-13 11:38:59 +00:00
}
}
var botData = {
"frames": [
{
"filename": "running bot.swf/0000",
"frame": {
"x": 34,
"y": 128,
"w": 56,
"h": 60
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 2,
"w": 56,
"h": 60
},
"sourceSize": {
"w": 56,
"h": 64
}
},
2013-07-13 11:38:59 +00:00
{
"filename": "running bot.swf/0001",
"frame": {
"x": 54,
"y": 0,
"w": 56,
"h": 58
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 3,
"w": 56,
"h": 58
},
"sourceSize": {
"w": 56,
"h": 64
}
},
2013-07-13 11:38:59 +00:00
{
"filename": "running bot.swf/0002",
"frame": {
"x": 54,
"y": 58,
"w": 56,
"h": 58
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 3,
"w": 56,
"h": 58
},
"sourceSize": {
"w": 56,
"h": 64
}
},
2013-07-13 11:38:59 +00:00
{
"filename": "running bot.swf/0003",
"frame": {
"x": 0,
"y": 192,
"w": 34,
"h": 64
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 11,
"y": 0,
"w": 34,
"h": 64
},
"sourceSize": {
"w": 56,
"h": 64
}
},
2013-07-13 11:38:59 +00:00
{
"filename": "running bot.swf/0004",
"frame": {
"x": 0,
"y": 64,
"w": 54,
"h": 64
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 1,
"y": 0,
"w": 54,
"h": 64
},
"sourceSize": {
"w": 56,
"h": 64
}
},
2013-07-13 11:38:59 +00:00
{
"filename": "running bot.swf/0005",
"frame": {
"x": 196,
"y": 0,
"w": 56,
"h": 58
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 3,
"w": 56,
"h": 58
},
"sourceSize": {
"w": 56,
"h": 64
}
},
2013-07-13 11:38:59 +00:00
{
"filename": "running bot.swf/0006",
"frame": {
"x": 0,
"y": 0,
"w": 54,
"h": 64
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 1,
"y": 0,
"w": 54,
"h": 64
},
"sourceSize": {
"w": 56,
"h": 64
}
},
2013-07-13 11:38:59 +00:00
{
"filename": "running bot.swf/0007",
"frame": {
"x": 140,
"y": 0,
"w": 56,
"h": 58
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 3,
"w": 56,
"h": 58
},
"sourceSize": {
"w": 56,
"h": 64
}
},
2013-07-13 11:38:59 +00:00
{
"filename": "running bot.swf/0008",
"frame": {
"x": 34,
"y": 188,
"w": 50,
"h": 60
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 3,
"y": 2,
"w": 50,
"h": 60
},
"sourceSize": {
"w": 56,
"h": 64
}
},
2013-07-13 11:38:59 +00:00
{
"filename": "running bot.swf/0009",
"frame": {
"x": 0,
"y": 128,
"w": 34,
"h": 64
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 11,
"y": 0,
"w": 34,
"h": 64
},
"sourceSize": {
"w": 56,
"h": 64
}
},
2013-07-13 11:38:59 +00:00
{
"filename": "running bot.swf/0010",
"frame": {
"x": 84,
"y": 188,
"w": 56,
"h": 58
},
2013-07-13 11:38:59 +00:00
"rotated": false,
"trimmed": true,
"spriteSourceSize": {
"x": 0,
"y": 3,
"w": 56,
"h": 58
},
"sourceSize": {
"w": 56,
"h": 64
}
2013-07-13 11:38:59 +00:00
}
],
"meta": {
"app": "http://www.texturepacker.com",
"version": "1.0",
"image": "running_bot.png",
"format": "RGBA8888",
"size": {
"w": 252,
"h": 256
},
2013-07-13 11:38:59 +00:00
"scale": "0.2",
"smartupdate": "$TexturePacker:SmartUpdate:fb56f261b1eb04e3215824426595f64c$"
}
};
})();