ZHBZHB Posted August 3, 2017 Share Posted August 3, 2017 Hello, I'm new to Phaser and I have a problem with sprites that are keeping the previous sprites created in a loop. See the multiple legs added to horses in the attached image. This append only on Safari !!! The code I use for that : horsesGrp = this.game.add.group(); horsesGrp.enableBody = true; var horses = []; for (var i = 1; i < 9; i++) { horses[i] = horsesGrp.create(165, i * 90 * scaleY, 'horse-'+i); horses[i].animations.add('run', [0, 1, 2, 3, 4, 5]); horses[i].smoothed = true; this.game.time.events.loop(this.game.rnd.integerInRange(500, 1000), this.updateVelocity, this, horses[i]); horses[i].anchor.set(0.5, 0.5); horses[i].checkWorldBounds = true; horses[i].autoCull = true; } Thank you in advance for your help ! Link to comment Share on other sites More sharing options...
squilibob Posted August 7, 2017 Share Posted August 7, 2017 Since this cloning of the group is only happening in Safari during each loop, try instead making an array of sprites first (your horses array) and then adding them all at once to the group after the loop is done horsesGrp = this.game.add.group(); horsesGrp.enableBody = true; var horses = []; for (var i = 1; i < 9; i++) { horses[i] = this.game.add.sprite(165, i * 90 * scaleY, 'horse-'+i); horses[i].animations.add('run', [0, 1, 2, 3, 4, 5]); horses[i].smoothed = true; this.game.time.events.loop(this.game.rnd.integerInRange(500, 1000), this.updateVelocity, this, horses[i]); horses[i].anchor.set(0.5, 0.5); horses[i].checkWorldBounds = true; horses[i].autoCull = true; } horsesGrp.addMultiple(horses); Link to comment Share on other sites More sharing options...
Recommended Posts