phaser/wip/TS Tests/textures/starling texture atlas.ts
2013-09-13 16:24:01 +01:00

51 lines
1.2 KiB
TypeScript

/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
function preload() {
// Starling/Sparrow XML Texture Atlas Method 1
//
// In this example we assume that the XML data is stored in an external file
game.load.atlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
game.load.atlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
}
var bits: Phaser.Sprite;
var bot: Phaser.Sprite;
function create() {
bot = game.add.sprite(800, 200, 'bot');
bot.animations.add('run');
bot.animations.play('run', 20, true);
bits = game.add.sprite(200, 200, 'bits');
bits.frame = 0;
}
function update() {
bot.x -= 5;
if (bot.x < -bot.width)
{
bot.x = game.stage.width;
bits.frame++;
if (bits.frame == bits.animations.frameTotal - 1)
{
bits.frame = 0;
}
}
}
})();