Skip to content

Commit

Permalink
Merge pull request phaserjs#2672 from bobonthenet/master
Browse files Browse the repository at this point in the history
Weapon.Fire now tracks offset rotation
  • Loading branch information
photonstorm authored Aug 25, 2016
2 parents d8cb40a + 7da5604 commit dfbdd59
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/plugins/weapon/WeaponPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dfbdd59

Please sign in to comment.