JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgit.com/photonstorm/phaser/v2.0.7/build/phaser.js"></script>
<div id='phaser-example'></div>
JavaScript
var game = new Phaser.Game(400, 300, Phaser.AUTO, 'phaser-example', { create: create, update: update});
var coins;
function create() {
coins = game.add.physicsGroup();
for (var i = 0; i < 10; i++)
{
var coin = coins.create(game.world.randomX, game.world.randomY, 'coin');
coin.body.velocity.x -= 250;
}
}
function update() {
coins.forEach(function(coin) {
if (typeof coin === 'undefined') {
return;
}
if (coin.x < 0) {
coins.remove(coin, true);
console.log('removed');
}
}, this);
}