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

40 lines
792 B
TypeScript

/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
function preload() {
// Texture Atlas Method 3
//
// In this example we assume that the TexturePacker JSON data is stored in an external file
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
}
var bot: Phaser.Sprite;
function create() {
bot = game.add.sprite(game.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
}
function update() {
bot.x -= 2;
if (bot.x < -bot.width)
{
bot.x = game.stage.width;
}
}
})();