mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Merge pull request #2672 from bobonthenet/master
Weapon.Fire now tracks offset rotation
This commit is contained in:
commit
dfbdd59f33
1 changed files with 28 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue