Merge pull request #2672 from bobonthenet/master

Weapon.Fire now tracks offset rotation
This commit is contained in:
Richard Davey 2016-08-25 13:06:31 +01:00 committed by GitHub
commit dfbdd59f33

View file

@ -730,14 +730,38 @@ Phaser.Weapon.prototype.fire = function (from, x, y) {
}
else if (this.trackedSprite)
{
if (this.fireFrom.width > 1)
if (this.trackRotation)
{
this.fireFrom.centerOn(this.trackedSprite.world.x + this.trackOffset.x, this.trackedSprite.world.y + this.trackOffset.y);
if(!this.rotatedPoint)
{
this.rotatedPoint = new Phaser.Point(this.trackedSprite.world.x + this.trackOffset.x, this.trackedSprite.world.y + this.trackOffset.y);
} else {
this.rotatedPoint.x = this.trackedSprite.world.x + this.trackOffset.x;
this.rotatedPoint.y = this.trackedSprite.world.y + this.trackOffset.y;
}
this.rotatedPoint.rotate(this.trackedSprite.world.x, this.trackedSprite.world.y, this.trackedSprite.rotation);
if (this.fireFrom.width > 1)
{
this.fireFrom.centerOn(this.rotatedPoint.x, this.rotatedPoint.y);
}
else
{
this.fireFrom.x = this.rotatedPoint.x;
this.fireFrom.y = this.rotatedPoint.y;
}
}
else
{
this.fireFrom.x = this.trackedSprite.world.x + this.trackOffset.x;
this.fireFrom.y = this.trackedSprite.world.y + this.trackOffset.y;
if (this.fireFrom.width > 1)
{
this.fireFrom.centerOn(this.trackedSprite.world.x + this.trackOffset.x, this.trackedSprite.world.y + this.trackOffset.y);
}
else
{
this.fireFrom.x = this.trackedSprite.world.x + this.trackOffset.x;
this.fireFrom.y = this.trackedSprite.world.y + this.trackOffset.y;
}
}
if (this.bulletInheritSpriteSpeed)