JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.1/phaser.min.js"></script>
JavaScript
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:preload, create: create });
function preload() {
game.load.image('circle', 'https://s13.postimg.org/xjhlzmiev/disc_png.png');
game.load.image('rect', 'http://s10.postimg.org/6fa6mgrd5/motif.jpg');
}
//E for external module
var E = E || {}
//var sprite={}
var circle={}
MonsterGroup = function (game, image,image2) {
Phaser.Group.call(this, game);
this.sprite=[]
for (var i = 0; i < 5; i++)
{
this.sprite[i] = this.create(100+i, game.world.randomY, image);
this.sprite[i].scale.setTo(.2,.2)
}
//return sprite
};
MonsterGroup.prototype = Object.create(Phaser.Group.prototype);
MonsterGroup.prototype.constructor = MonsterGroup;
E=E || {}
function create() {
console.time("prototype")
customGroup1 = new MonsterGroup(game, 'rect','circle');
console.timeEnd("prototype")
console.time("normal")
var group1= game.add.group()
var sp={}
for (var i = 0; i < 5; i++) {
sp[i]= game.add.sprite(10,game.world.randomY,'rect')
sp[i].scale.setTo(.1,.1)
group1.add(sp[i])
}
console.timeEnd("normal")
}