Infinity runner
https://habrahabr.ru/post/307650/
by Ali Dadmand
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.1/phaser.min.js"></script>
<div id="phaser-example"></div>
JavaScript
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', {
preload: preload,
create: create,
update: update
});
function preload() {
game.load.crossOrigin = 'anonymous';
game.load.image('bg', 'http://image.prntscr.com/image/a15ff5fa6b284ce1a45ccabcba7b4a1d.jpg');
game.load.image('ground', 'http://image.prntscr.com/image/4691b7fd003f438f9386d970d6aa5728.png');
game.load.spritesheet('dog', 'http://image.prntscr.com/image/a6487a73e41f4aedbf225b3dc1a24957.png', 150, 120, 5);
}
function create() {
game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
game.stage.disableVisibilityChange = true;
this.bg = game.add.tileSprite(0, 0, 1286, 640, 'bg');
this.bg.autoScroll(-100, 0);
this.ground = game.add.tileSprite(0, game.world.height, 1286, 179, 'ground');
this.ground.anchor.y = 1;
this.ground.autoScroll(-300, 0);
var dog = game.add.sprite(game.world.centerX, game.world.height - this.ground.height - 50, 'dog');
dog.anchor.setTo(1, 0);
dog.animations.add('dog_animation')
dog.animations.play('dog_animation', 10, true)
}
function update() {
//this.ground.tilePosition.x -= 4;
this.bg.tilePosition.x -= 2;
}