The Weapon.fireRateVariance property was never taken into account internally. It's now applied to the firing rate correctly (thanks @noseglid #2715)

This commit is contained in:
photonstorm 2016-08-25 13:31:43 +01:00
parent cbbb2cd97b
commit 19dbd8bba8
2 changed files with 18 additions and 1 deletions

View file

@ -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

View file

@ -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++;