mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 12:43:26 +00:00
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
/// <reference path="../../Phaser/Phaser.ts" />
|
|
(function () {
|
|
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
|
function init() {
|
|
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');
|
|
// If you are using a Texture Atlas and want to specify the frames of an animation by their name rather than frame index
|
|
// then you can use this format:
|
|
bot.animations.add('run', [
|
|
'run00',
|
|
'run01',
|
|
'run02',
|
|
'run03',
|
|
'run04',
|
|
'run05',
|
|
'run06',
|
|
'run07',
|
|
'run08',
|
|
'run09',
|
|
'run10'
|
|
], 10, true, false);
|
|
bot.animations.play('run');
|
|
bot.velocity.x = -100;
|
|
}
|
|
function update() {
|
|
if(bot.x < -bot.width) {
|
|
bot.x = myGame.stage.width;
|
|
}
|
|
}
|
|
})();
|