ctmartinez1992 Posted March 13, 2014 Share Posted March 13, 2014 So i have this method that creates the bulletscreateBullets() { this.bullets.createMultiple(30, 'bullet'); this.bullets.setAll('anchor.x', 0.5); this.bullets.setAll('anchor.y', 0.5); this.bullets.setAll('outOfBoundsKill', true);}and then i update them here to fire the bullets update() { if (this.fireKey.isDown) { if (this.game.time.now > this.firingTimer) { this.fire(); } } if (this.game.physics.collide(this.bullets, this.enemies, this.bulletCollidesEnemy)) { this.score++; this.scoreText.content = "Score " + this.score; } } }And the collide handler and the fire mechanism bulletCollidesEnemy(bu, bo) { bu.kill(); bo.destroy() } fire() { var bullet: Phaser.Sprite = this.bullets.getFirstExists(false); if (bullet) { bullet.reset(this.player.x + 12, this.player.y - 6); bullet.body.velocity.y = -300; this.firingTimer = this.game.time.now + this.fireTimeControl; } }This sometimes works well and the next second its broken and then works again, here, you can see it for yourself: https://dl.dropboxusercontent.com/u/52790690/HTML5%20GD/game4/game4/default.htmIf you hold space it will fire half a dozen of bullets and then some of them will just get stuck and not move at all. Eventually you will run out of bullets in the group because they are all stuck in there. I need help on this one, i can't understand what i am possibly doing wrong. Link to comment Share on other sites More sharing options...
Recommended Posts