JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdn.rawgit.com/photonstorm/phaser/6c7c0cb1b62b8ea4c1808efde62aff6840ca3099/build/phaser.min.js"></script>
<div id="game"></div>
JavaScript
var GameState = function () {};
GameState.prototype = {
init: function () {
this.stage.backgroundColor = "D8C6A7";
},
preload: function () {
/* Load to sprite of size 1px by 1px */
game.load.image('bar', 'http://s8.postimg.org/bgudkt59d/image.png');
},
create: function () {
/* group to hold bar objects */
this.barGroup = game.add.group();
/* create 5 bar moving from right to left on the screen */
for (var i = 0; i < 5; i++) {
var bar = game.add.sprite(640 + 200 * i, 112, 'bar')
game.physics.arcade.enable(bar);
bar.scale.set(16, 96);
bar.body.velocity.x = -200;
this.barGroup.add(bar);
}
},
update: function () {
/* Reset bar */
this.barGroup.forEach(function (bar) {
if (bar.x <= -16)
bar.x += 1000;
}, this);
},
};
/* Create the game and gamestate objects */
var game = new Phaser.Game(640, 320, Phaser.CANVAS, 'game');
game.state.add('Game', GameState, true);