Skip to content

Commit c3b4590

Browse files
authored
Merge pull request phaserjs#2731 from JTronLabs/dev
Cleaned up commits from previous PR
2 parents 85fc05e + 42ca43d commit c3b4590

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/physics/arcade/Body.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,9 +1046,9 @@ Phaser.Physics.Arcade.Body.prototype = {
10461046
* For example: If you have a Sprite with a texture that is 80x100 in size,
10471047
* and you want the physics body to be 32x32 pixels in the middle of the texture, you would do:
10481048
*
1049-
* `setSize(32, 32, 24, 34)`
1049+
* `setSize(32 / Math.abs(this.scale.x), 32 / Math.abs(this.scale.y), 24, 34)`
10501050
*
1051-
* Where the first two parameters is the new Body size (32x32 pixels).
1051+
* Where the first two parameters are the new Body size (32x32 pixels) relative to the Sprite's scale.
10521052
* 24 is the horizontal offset of the Body from the top-left of the Sprites texture, and 34
10531053
* is the vertical offset.
10541054
*

src/plugins/weapon/WeaponPlugin.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,10 @@ Phaser.Weapon.prototype.trackPointer = function (pointer, offsetX, offsetY) {
690690

691691
/**
692692
* Attempts to fire a single Bullet. If there are no more bullets available in the pool, and the pool cannot be extended,
693-
* then this method returns `false`. It will also return false if not enough time has expired since the last time
693+
* then this method returns `null`. It will also return `null` if not enough time has expired since the last time
694694
* the Weapon was fired, as defined in the `Weapon.fireRate` property.
695695
*
696-
* Otherwise the first available bullet is selected and launched.
696+
* Otherwise the first available bullet is selected, launched, and returned.
697697
*
698698
* The arguments are all optional, but allow you to control both where the bullet is launched from, and aimed at.
699699
*
@@ -979,9 +979,9 @@ Phaser.Weapon.prototype.fireAtXY = function (x, y) {
979979
* For example: If you have a Sprite with a texture that is 80x100 in size,
980980
* and you want the physics body to be 32x32 pixels in the middle of the texture, you would do:
981981
*
982-
* `setSize(32, 32, 24, 34)`
982+
* `setSize(32 / Math.abs(this.scale.x), 32 / Math.abs(this.scale.y), 24, 34)`
983983
*
984-
* Where the first two parameters is the new Body size (32x32 pixels).
984+
* Where the first two parameters are the new Body size (32x32 pixels) relative to the Sprite's scale.
985985
* 24 is the horizontal offset of the Body from the top-left of the Sprites texture, and 34
986986
* is the vertical offset.
987987
*
@@ -1127,8 +1127,10 @@ Object.defineProperty(Phaser.Weapon.prototype, "bulletClass", {
11271127

11281128
this._bulletClass = classType;
11291129

1130-
this.bullets.classType = this._bulletClass;
1131-
1130+
//prevent crash if weapon's bullets have not yet been initialized
1131+
if (this.bullets) {
1132+
this.bullets.classType = this._bulletClass;
1133+
}
11321134
}
11331135

11341136
});

0 commit comments

Comments
 (0)