wilbertom Posted March 14, 2014 Share Posted March 14, 2014 Hey guys. I have been learning Phaser as my first attempt to do game development. So far it is great. I only have one issue. Reading http://blog.lessmilk.com/how-to-make-flappy-bird-in-html5-1/ I learned about using dead group items to add objects to the game. Code can better explain:this.pipes = game.add.group(); this.pipes.createMultiple(20, 'pipe'); // later onadd_one_pipe: function(x, y) { // Get the first dead pipe of our group var pipe = this.pipes.getFirstDead(); // Set the new position of the pipe pipe.reset(x, y); // Add velocity to the pipe to make it move left pipe.body.velocity.x = -200; // Kill the pipe when it's no longer visible pipe.outOfBoundsKill = true;},I refactored this to my first attempt at a game, but I'm having problems. Whenever a user leaves the screen and then comes back, the screen is bombarded with items. At first I thought that maybe it was just the wrong way to implement it. But in the Phaser example http://examples.phaser.io/_site/view_full.html?d=games&f=invaders.js&t=invaders the same thing happens. If you play for a little while. Leave the tab or open the js console and cause the game to stop playing(I think when requestAnimationFrame stops), all the bullets fire at you. This gets worse with the more time you play. I think the more group items that are revived(with getFirstDead()) and then paused, the worse it is. Link to comment Share on other sites More sharing options...
rich Posted March 14, 2014 Share Posted March 14, 2014 It's probably timer related rather than Group related (as Groups don't have any timers in them at all). I spent a lot of time fixing the timers in 2.0, so it'd be worth looking at that if you can. Link to comment Share on other sites More sharing options...
wilbertom Posted March 14, 2014 Author Share Posted March 14, 2014 I just saw the release post, I'll upgrade and let you know. Link to comment Share on other sites More sharing options...
wilbertom Posted March 14, 2014 Author Share Posted March 14, 2014 Worked! Link to comment Share on other sites More sharing options...
Recommended Posts