Weapon#trackPointer()

trackPointer(pointer, offsetX, offsetY) → {Phaser.Weapon}

Sets this Weapon to track the given Pointer.
When a Weapon tracks a Pointer it will automatically update its fireFrom value to match the Pointers
position within the Game World, adjusting the coordinates based on the offset arguments.

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

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

Parameters
Name Type Argument Default Description
pointer Phaser.Pointer <optional>

The Pointer to track the position of. Defaults to Input.activePointer if not specified.

offsetX integer <optional>
0

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

offsetY integer <optional>
0

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

Returns

This Weapon instance.

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

Please login to continue.