diff --git a/README.md b/README.md index 8a86d36914..ddfc853fb0 100644 --- a/README.md +++ b/README.md @@ -347,6 +347,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/ * Text bounds would incorrectly displace if the Text resolution was greater than 1 (thanks @valent-novem #2685) * TilemapParser would calculate widthInPixels and heightInPixels were being read incorrectly from JSON data (capitalisation of properties) (thanks @hexus #2691) * A tinted Texture in Canvas mode wouldn't be updated properly if it was also cropped, beyond the initial crop. Now a cropped texture will re-tint itself every time the crop is updated, and has changed (thanks @phoenixyjll #2688) +* The Weapon.fireRateVariance property was never taken into account internally. It's now applied to the firing rate correctly (thanks @noseglid #2715) ### Pixi Updates diff --git a/src/plugins/weapon/WeaponPlugin.js b/src/plugins/weapon/WeaponPlugin.js index a80f307119..c9180c487f 100644 --- a/src/plugins/weapon/WeaponPlugin.js +++ b/src/plugins/weapon/WeaponPlugin.js @@ -895,7 +895,23 @@ Phaser.Weapon.prototype.fire = function (from, x, y) { bullet.body.velocity.set(moveX, moveY); bullet.body.gravity.set(this.bulletGravity.x, this.bulletGravity.y); - this._nextFire = this.game.time.now + this.fireRate; + if (this.bulletSpeedVariance !== 0) + { + var rate = this.fireRate; + + rate += Phaser.Math.between(-this.fireRateVariance, this.fireRateVariance); + + if (rate < 0) + { + rate = 0; + } + + this._nextFire = this.game.time.now + rate; + } + else + { + this._nextFire = this.game.time.now + this.fireRate; + } this.shots++;