Skip to content

Commit 7da5604

Browse files
committed
Use this.rotatedPoint instead of a new object
1 parent 6df44bd commit 7da5604

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/plugins/weapon/WeaponPlugin.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -732,17 +732,23 @@ Phaser.Weapon.prototype.fire = function (from, x, y) {
732732
{
733733
if (this.trackRotation)
734734
{
735-
var rotatedPoint = new Phaser.Point(this.trackedSprite.world.x + this.trackOffset.x, this.trackedSprite.world.y + this.trackOffset.y);
736-
rotatedPoint.rotate(this.trackedSprite.world.x, this.trackedSprite.world.y, this.trackedSprite.rotation);
735+
if(!this.rotatedPoint)
736+
{
737+
this.rotatedPoint = new Phaser.Point(this.trackedSprite.world.x + this.trackOffset.x, this.trackedSprite.world.y + this.trackOffset.y);
738+
} else {
739+
this.rotatedPoint.x = this.trackedSprite.world.x + this.trackOffset.x;
740+
this.rotatedPoint.y = this.trackedSprite.world.y + this.trackOffset.y;
741+
}
742+
this.rotatedPoint.rotate(this.trackedSprite.world.x, this.trackedSprite.world.y, this.trackedSprite.rotation);
737743

738744
if (this.fireFrom.width > 1)
739745
{
740-
this.fireFrom.centerOn(rotatedPoint.x, rotatedPoint.y);
746+
this.fireFrom.centerOn(this.rotatedPoint.x, this.rotatedPoint.y);
741747
}
742748
else
743749
{
744-
this.fireFrom.x = rotatedPoint.x;
745-
this.fireFrom.y = rotatedPoint.y;
750+
this.fireFrom.x = this.rotatedPoint.x;
751+
this.fireFrom.y = this.rotatedPoint.y;
746752
}
747753
}
748754
else

0 commit comments

Comments
 (0)