mirror of
https://github.com/photonstorm/phaser
synced 2024-12-12 06:12:53 +00:00
25 lines
843 B
JavaScript
25 lines
843 B
JavaScript
|
/// <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;
|
||
|
}
|
||
|
}
|
||
|
})();
|