Skip to content

Commit

Permalink
The Weapon.fireRateVariance property was never taken into account int…
Browse files Browse the repository at this point in the history
…ernally. It's now applied to the firing rate correctly (thanks @noseglid #2715)
  • Loading branch information
photonstorm committed Aug 25, 2016
1 parent cbbb2cd commit 19dbd8b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 17 additions & 1 deletion src/plugins/weapon/WeaponPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++;

Expand Down

0 comments on commit 19dbd8b

Please sign in to comment.