bru Posted May 8, 2014 Share Posted May 8, 2014 Hello, i have a group of platforms :create: function {this.platforms = this.game.add.group();this.platform = this.platforms.create(thsi.game.with, this.game.height-100, 'yellow'); this.platform.anchor.setTo(0, 1); this.platform.scale.setTo(10, 1); game.physics.enable(this.platform, Phaser.Physics.ARCADE); this.platform.body.immovable = true; this.platform.body.reset(startwidth, startheight);}and i make them move like this :update: function{ this.platform.body.x -= 10;}The problem is, when a new platform come the last one stop moving, instead of move until leave the screen, is there any way to solve this ? Link to comment Share on other sites More sharing options...
XekeDeath Posted May 8, 2014 Share Posted May 8, 2014 You are only updating one platform at a time in the update function.I assume that every time you create a new platform, you assign it to the this.platform variable, which would cause the existing platform to stop moving. You would be better off iterating over the children of the this.platforms group and updating each platform that way.Look at Group.forEach and Group.ForEachAlive.update: function{ this.platforms.forEachAlive(function(platform) { platform.body.x -= 10; }} Link to comment Share on other sites More sharing options...
bru Posted May 8, 2014 Author Share Posted May 8, 2014 Yes that was the problem, actually i tried forEachAlive before but i was not give the "platform".It's perfect now, thank you very much. Link to comment Share on other sites More sharing options...
Recommended Posts