Weapon#Weapon

new Weapon(game, parent) The Weapon Plugin provides the ability to easily create a bullet pool and manager. Weapons fire Phaser.Bullet objects, which are essentially Sprites with a few extra properties.The Bullets are enabled for Arcade Physics. They do not currently work with P2 Physics. The Bullets are created inside of Weapon.bullets, which is a Phaser.Group instance. Anything youcan usually do with a Group, such as move it around the display list, iterate it, etc can be doneto the bullets

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 Spritesposition 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.trackedPo

Weapon#trackRotation

trackRotation : boolean If the Weapon is tracking a Sprite, should it also track the Sprites rotation?This is useful for a game such as Asteroids, where you want the weapon to fire basedon the sprites rotation. Source code: plugins/weapon/WeaponPlugin.js (Line 350)

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 Pointersposition 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 canonly tr

Weapon#trackOffset

trackOffset : Phaser.Point The Track Offset is a Point object that allows you to specify a pixel offset that bullets usewhen launching from a tracked Sprite or Pointer. For example if you've got a bullet that is 2x2 pixelsin size, but you're tracking a Sprite that is 32x32, then you can set trackOffset.x = 16 to havethe bullet launched from the center of the Sprite. Source code: plugins/weapon/WeaponPlugin.js (Line 360)

Weapon#trackedSprite

trackedSprite : Phaser.Sprite | Object The Sprite currently being tracked by the Weapon, if any.This is set via the Weapon.trackSprite method. Type Phaser.Sprite | Object Source code: plugins/weapon/WeaponPlugin.js (Line 333)

Weapon#trackedPointer

trackedPointer : Phaser.Pointer The Pointer currently being tracked by the Weapon, if any.This is set via the Weapon.trackPointer method. Source code: plugins/weapon/WeaponPlugin.js (Line 341)

Weapon#shots

shots : number The total number of bullets this Weapon has fired so far.You can limit the number of shots allowed (via fireLimit), and resetthis total via Weapon.resetShots. Source code: plugins/weapon/WeaponPlugin.js (Line 61)

Weapon#setBulletFrames()

setBulletFrames(min, max, cycle, random) → {Phaser.Weapon} Sets the texture frames that the bullets can use when being launched. This is intended for use when you've got numeric based frames, such as those loaded via a Sprite Sheet. It works by calling Phaser.ArrayUtils.numberArray internally, using the min and max valuesprovided. Then it sets the frame index to be zero. You can optionally set the cycle and random booleans, to allow bullets to cycle through the frameswhen they're fired, or pi

Weapon#setBulletBodyOffset()

setBulletBodyOffset(width, height, offsetX, offsetY) → {Phaser.Weapon} You can modify the size of the physics Body the Bullets use to be any dimension you need.This allows you to make it smaller, or larger, than the parent Sprite.You can also control the x and y offset of the Body. This is the position of theBody relative to the top-left of the Sprite texture. For example: If you have a Sprite with a texture that is 80x100 in size,and you want the physics body to be 32x32 pixels in the middle