You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Weapon.multiFire is a new property that allows you to set a Weapon as being allowed to call fire as many times as you like, per game loop. This allows a single Weapon instance to fire multiple bullets.
Weapon.fire has two new arguments: `offsetX` and `offsetY`. If the bullet is fired from a tracked Sprite or Pointer, or the `from` argument is set, this applies a horizontal and vertical offset from the launch position.
Weapon.fireOffset attempts to fire a single Bullet from a tracked Sprite or Pointer, but applies an offset to the position first. This is a shorter form of calling `Weapon.fire` and passing in the offset arguments.
Weapon.fireMany attempts to fire multiple bullets from the positions defined in the given array. If you provide a `from` argument, or if there is a tracked Sprite or Pointer, then the positions are treated as __offsets__ from the given objects position. If `from` is undefined, and there is no tracked object, then the bullets are fired from the given positions, as they exist in the world.
Copy file name to clipboardExpand all lines: README.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -309,14 +309,16 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
309
309
310
310
### New Features
311
311
312
-
*
313
-
*
312
+
* Weapon.multiFire is a new property that allows you to set a Weapon as being allowed to call `fire` as many times as you like, per game loop. This allows a single Weapon instance to fire multiple bullets.
313
+
* Weapon.fire has two new arguments: `offsetX` and `offsetY`. If the bullet is fired from a tracked Sprite or Pointer, or the `from` argument is set, this applies a horizontal and vertical offset from the launch position.
314
+
* Weapon.fireOffset attempts to fire a single Bullet from a tracked Sprite or Pointer, but applies an offset to the position first. This is a shorter form of calling `Weapon.fire` and passing in the offset arguments.
315
+
* Weapon.fireMany attempts to fire multiple bullets from the positions defined in the given array. If you provide a `from` argument, or if there is a tracked Sprite or Pointer, then the positions are treated as __offsets__ from the given objects position. If `from` is undefined, and there is no tracked object, then the bullets are fired from the given positions, as they exist in the world.
314
316
*
315
317
316
318
### Updates
317
319
318
-
* TypeScript definitions fixes and updates (thanks )
319
-
* Docs typo fixes (thanks @JTronLabs)
320
+
* TypeScript definitions fixes and updates (thanks @chriteixeira)
321
+
* Docs typo fixes (thanks @JTronLabs@samme)
320
322
*`Phaser.Line.fromSprite` now uses the Sprite.centerX and centerY properties if the `useCenter` argument is true. Before it required you to have overridden the Sprite and added the property yourself (thanks @samme#2729)
* Attempts to fire multiple bullets from the positions defined in the given array.
738
+
*
739
+
* If you provide a `from` argument, or if there is a tracked Sprite or Pointer, then
740
+
* the positions are treated as __offsets__ from the given objects position.
741
+
*
742
+
* If `from` is undefined, and there is no tracked object, then the bullets are fired
743
+
* from the given positions, as they exist in the world.
744
+
*
745
+
* Calling this method sets `Weapon.multiFire = true`.
746
+
*
747
+
* If there are not enough bullets available in the pool, and the pool cannot be extended,
748
+
* then this method may not fire from all of the given positions.
749
+
*
750
+
* When the bullets are launched they have their texture and frame updated, as required.
751
+
* The velocity of the bullets are calculated based on Weapon properties like `bulletSpeed`.
752
+
*
753
+
* @method Phaser.Weapon#fireMany
754
+
* @param {array} positions - An array of positions. Each position can be any Object, as long as it has public `x` and `y` properties, such as Phaser.Point, { x: 0, y: 0 }, Phaser.Sprite, etc.
755
+
* @param {Phaser.Sprite|Phaser.Point|Object|string} [from] - Optionally fires the bullets **from** the `x` and `y` properties of this object, _instead_ of any `Weapon.trackedSprite` or `trackedPointer` that is set.
756
+
* @return {array} An array containing all of the fired Phaser.Bullet objects, if a launch was successful, otherwise an empty array.
* When the bullet is launched it has its texture and frame updated, as required. The velocity of the bullet is
704
830
* calculated based on Weapon properties like `bulletSpeed`.
705
831
*
832
+
* If you wish to fire multiple bullets in a single game update, then set `Weapon.multiFire = true`
833
+
* and you can call `fire` as many times as you like, per loop. Multiple fires in a single update
834
+
* only counts once towards the `shots` total, but you will still receive a Signal for each bullet.
835
+
*
706
836
* @method Phaser.Weapon#fire
707
-
* @param {Phaser.Sprite|Phaser.Point|Object} [from] - Optionally fires the bullet **from** the `x` and `y` properties of this object. If set this overrides `Weapon.trackedSprite` or `trackedPointer`. Pass `null` to ignore it.
708
-
* @param {number} [x] - The x coordinate, in world space, to fire the bullet **towards**. If left as `undefined` the bullet direction is based on its angle.
709
-
* @param {number} [y] - The y coordinate, in world space, to fire the bullet **towards**. If left as `undefined` the bullet direction is based on its angle.
837
+
* @param {Phaser.Sprite|Phaser.Point|Object|string} [from] - Optionally fires the bullet **from** the `x` and `y` properties of this object. If set this overrides `Weapon.trackedSprite` or `trackedPointer`. Pass `null` to ignore it.
838
+
* @param {number} [x] - The x coordinate, in world space, to fire the bullet **towards**. If left as `undefined`, or `null`, the bullet direction is based on its angle.
839
+
* @param {number} [y] - The y coordinate, in world space, to fire the bullet **towards**. If left as `undefined`, or `null`, the bullet direction is based on its angle.
840
+
* @param {number} [offsetX=0] - If the bullet is fired from a tracked Sprite or Pointer, or the `from` argument is set, this applies a horizontal offset from the launch position.
841
+
* @param {number} [offsetY=0] - If the bullet is fired from a tracked Sprite or Pointer, or the `from` argument is set, this applies a vertical offset from the launch position.
710
842
* @return {Phaser.Bullet} The fired bullet, if a launch was successful, otherwise `null`.
0 commit comments