phaser/Tests/sprites/texture atlas 3.js

25 lines
843 B
JavaScript
Raw Normal View History

2013-04-12 16:19:56 +00:00
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/Sprite.ts" />
(function () {
var myGame = new Game(this, 'game', 800, 600, init, create, update);
function init() {
// Texture Atlas Method 3
//
// In this example we assume that the TexturePacker JSON data is stored in an external file
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
myGame.loader.load();
}
var bot;
function create() {
bot = myGame.createSprite(myGame.stage.width, 300, 'bot');
bot.animations.add('run');
bot.animations.play('run', 10, true);
bot.velocity.x = -100;
}
function update() {
if(bot.x < -bot.width) {
bot.x = myGame.stage.width;
}
}
})();