KnTproject Posted September 17, 2016 Share Posted September 17, 2016 Hello, Function create(){ dudes = game.add.group(); dudes.enableBody = true; for (var i = -600; i < 600; i = i + 50){ for (var y = -800; y < 800; y = y + 50){ var dude = dudes.create(y,i,'dude'); dude.frame = 4; dude.animations.add('left', [0,1,2,3],10,true); dude.animations.add('right',[5,6,7,8,],10,true); dude.animations.play('right'); dude.body.velocity.x = +50; game.physics.arcade.enable(dudes); } This is my code. I would like to see all of the dudes the whole time. Now, they will disappear from the screen after a while. Which code do I have to write so that the code will repeat continuously? If I have to write something in the function Update(), how do I have to call the dudes? Link to comment Share on other sites More sharing options...
douglas Posted September 17, 2016 Share Posted September 17, 2016 I don't see the problem ? https://jsfiddle.net/johndo101/4bmcr3uL/ Link to comment Share on other sites More sharing options...
Milton Posted September 17, 2016 Share Posted September 17, 2016 dudes.forEach(function(dude) { // check if dude left the screen, and set its new position }); Link to comment Share on other sites More sharing options...
douglas Posted September 17, 2016 Share Posted September 17, 2016 so dudes must be an array no ? forEach uses a callback function on ech elements of an array Link to comment Share on other sites More sharing options...
Recommended Posts