JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgit.com/photonstorm/phaser/master/build/phaser.min.js"></script>
<div id="game"></div>
JavaScript
var game = new Phaser.Game(325, 325, Phaser.AUTO, 'game');
BasicGame = {};
BasicGame.Game = function (game) {};
BasicGame.Game.prototype = {
preload: function () {},
create: function () {
this.stage.backgroundColor = '#005b7f';
this.blocks = this.add.group();
this.blocks.enableBody = true;
this.blocks.physicsBodyType = Phaser.Physics.ARCADE;
this.blocks.createMultiple(81, 'block');
this.blocks.setAll('outOfBoundsKill', true);
this.blocks.setAll('checkWorldBounds', true);
this.blocks.setAll('body.collideWorldBounds', true);
this.time.events.loop(500, this.spawnBlocks, this);
},
update: function () {
this.physics.arcade.collide(this.blocks, this.blocks);
},
spawnBlocks: function () {
if (!this.blocks.countDead()) return;
var block = this.blocks.getFirstExists(false);
block.reset(this.rnd.integerInRange(0, 8) * 35, 0);
block.body.velocity.y = 200;
}
};
game.state.add('Game', BasicGame.Game);
game.state.start('Game');