Weapon#trackSprite()

trackSprite(sprite, offsetX, offsetY, trackRotation) → {Phaser.Weapon}

Sets this Weapon to track the given Sprite, or any Object with a public world Point object.
When a Weapon tracks a Sprite it will automatically update its fireFrom value to match the Sprites
position within the Game World, adjusting the coordinates based on the offset arguments.

This allows you to lock a Weapon to a Sprite, so that bullets are always launched from its location.

Calling trackSprite will reset Weapon.trackedPointer to null, should it have been set, as you can
only track either a Sprite, or a Pointer, at once, but not both.

Parameters
Name Type Argument Default Description
sprite Phaser.Sprite | Object

The Sprite to track the position of.

offsetX integer <optional>
0

The horizontal offset from the Sprites position to be applied to the Weapon.

offsetY integer <optional>
0

The vertical offset from the Sprites position to be applied to the Weapon.

trackRotation boolean <optional>
false

Should the Weapon also track the Sprites rotation?

Returns

This Weapon instance.

Source code: plugins/weapon/WeaponPlugin.js (Line 626)
doc_phaser
2017-02-14 11:20:01
Comments
Leave a Comment

Please login to continue.