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 sprite={}
var circle={}
MonsterGroup = function (game, image,image2) {
Phaser.Group.call(this, game);
this.sprite={}
for (var i = 0; i < 10; i++)
{
this.sprite[i] = this.create(100+i, game.world.randomY, image);
this.sprite[i].scale.setTo(.2,.2)
}
this.button=game.add.sprite(100,100,'circle')
this.button.x=200
this.flag=true
//return sprite
};
MonsterGroup.prototype = Object.create(Phaser.Group.prototype);
MonsterGroup.prototype.constructor = MonsterGroup;
function create() {
customGroup1 = new MonsterGroup(game, 'rect','circle');
customGroup1.alpha=1
//sprite[1].alpha =.2
Object.keys(customGroup1).forEach(function(characteristic) {
if (characteristic=="sprite"){
console.log('object',characteristic,': ',customGroup1[characteristic][2].position.x)
}
})
}