Skip to content

Commit 89fe81a

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents a786298 + 18f8ee5 commit 89fe81a

12 files changed

Lines changed: 170 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
* `InputManager.onMouseWheel` is a new internal method that handles processing the wheel event.
1919
* `InputManager.processWheelEvent` is a new internal method that handles processing the wheel event sent by the Input Manager.
2020

21+
#### Button Released Support
22+
23+
* `Pointer.button` is a new property that indicates which button was pressed, or released, on the pointer during the most recent event. It is only set during `up` and `down` events and is always 0 for Touch inputs.
24+
* `Pointer.leftButtonReleased` is a new method that returns `true` if it was the left mouse button that was just released. This can be checked in a `pointerup` event handler to find out which button was released.
25+
* `Pointer.rightButtonReleased` is a new method that returns `true` if it was the right mouse button that was just released. This can be checked in a `pointerup` event handler to find out which button was released (thanks @BobtheUltimateProgrammer)
26+
* `Pointer.middleButtonReleased` is a new method that returns `true` if it was the middle mouse button that was just released. This can be checked in a `pointerup` event handler to find out which button was released.
27+
* `Pointer.backButtonReleased` is a new method that returns `true` if it was the back mouse button that was just released. This can be checked in a `pointerup` event handler to find out which button was released.
28+
* `Pointer.forwardButtonReleased` is a new method that returns `true` if it was the forward mouse button that was just released. This can be checked in a `pointerup` event handler to find out which button was released.
29+
2130
#### Input System Bug Fixes
2231

2332
* Calling `setPollAlways()` would cause the `'pointerdown'` event to fire multiple times. Fix #4541 (thanks @Neyromantik)
@@ -98,6 +107,7 @@ The following changes took place in the Pointer class:
98107
*`WebAudioSoundManager.decodeAudio` is a new method that allows you to decode audio data into a format ready for playback and stored in the audio cache. The audio data can be provided as an ArrayBuffer, a base64 string or a data uri. Listen for the events to know when the data is ready for use.
99108
* `Phaser.Sound.Events#DECODED` is a new event emitted by the Web Audio Sound Manager when it has finished decoding audio data.
100109
* `Phaser.Sound.Events#DECODED_ALL` is a new event emitted by the Web Audio Sound Manager when it has finished decoding all of the audio data files passed to the `decodeAudio` method.
110+
* `Phaser.Utils.Objects.Pick` is a new function that will take an object and an array of keys and return a new object containing just the keys provided in the array.
101111

102112
### Updates
103113

@@ -125,6 +135,24 @@ The following changes took place in the Pointer class:
125135
* `LineStyleCanvas` now takes an `altColor` argument which is used to override the context color.
126136
* `LineStyleCanvas` now takes an `altAlpha` argument which is used to override the context alpha.
127137
* `FillStyleCanvas` now takes an `altAlpha` argument which is used to override the context alpha.
138+
* `StaticPhysicsGroup` can now take a `classType` property in its Group Config and will use the value of it, rather than override it. If none is provided it'll default to `ArcadeSprite`. Fix #4401 (thanks @Legomite)
139+
* `Phaser.Tilemaps.Parsers.Tiled` used to run the static function `ParseJSONTiled`. `Parsers.Tiled` is now just a namespace, so access the function within it: `Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled`.
140+
* `Phaser.Tilemaps.Parsers.Impact` used to run the static function `ParseWeltmeister`. `Parsers.Impact` is now just a namespace, so access the function within it: `Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister`.
141+
* `Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties` is now a public static function, available to be called directly.
142+
* `Phaser.Tilemaps.Parsers.Tiled.Base64Decode` is now a public static function, available to be called directly.
143+
* `Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex` is now a public static function, available to be called directly.
144+
* `Phaser.Tilemaps.Parsers.Tiled.ParseGID` is now a public static function, available to be called directly.
145+
* `Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers` is now a public static function, available to be called directly.
146+
* `Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled` is now a public static function, available to be called directly.
147+
* `Phaser.Tilemaps.Parsers.Tiled.ParseObject` is now a public static function, available to be called directly.
148+
* `Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers` is now a public static function, available to be called directly.
149+
* `Phaser.Tilemaps.Parsers.Tiled.ParseTileLayers` is now a public static function, available to be called directly.
150+
* `Phaser.Tilemaps.Parsers.Tiled.ParseTilesets` is now a public static function, available to be called directly.
151+
* `Phaser.Tilemaps.Parsers.Tiled.ParseTilesets` is now a public static function, available to be called directly.
152+
* `Phaser.Tilemaps.Parsers.Impact.ParseTileLayers` is now a public static function, available to be called directly.
153+
* `Phaser.Tilemaps.Parsers.Impact.ParseTilesets` is now a public static function, available to be called directly.
154+
* `Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister` is now a public static function, available to be called directly.
155+
* `Phaser.Tilemaps.Parsers.Tiled.Pick` has been removed. It is now available under `Phaser.Utils.Objects.Pick`, which is a more logical place for it.
128156

129157
### Bug Fixes
130158

@@ -143,6 +171,7 @@ The following changes took place in the Pointer class:
143171
* The `Grid` Game Object wouldn't render in Canvas mode at all. Fix #4585 (thanks @fyyyyy)
144172
* If you had a `Graphics` object in the display list immediately after an object with a Bitmap Mask it would throw an error `Uncaught TypeError: Cannot set property 'TL' of undefined`. Fix #4581 (thanks @Petah @Loonride)
145173
* Calling Arcade Physics `Body.reset` on a Game Object that doesn't have any bounds, like a Container, would throw an error about being unable to access `getTopLeft`. If this is the case, it will now set the position to the given x/y values (thanks Jazz)
174+
* All of the `Tilemaps.Parsers.Tiled` static functions are now available to be called directly. Fix #4318 (thanks @jestarray)
146175

147176
### Examples, Documentation and TypeScript
148177

src/input/Pointer.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ var Pointer = new Class({
103103
*/
104104
this.camera = null;
105105

106+
/**
107+
* A read-only property that indicates which button was pressed, or released, on the pointer
108+
* during the most recent event. It is only set during `up` and `down` events.
109+
*
110+
* On Touch devices the value is always 0.
111+
*
112+
* Users may change the configuration of buttons on their pointing device so that if an event's button property
113+
* is zero, it may not have been caused by the button that is physically left–most on the pointing device;
114+
* however, it should behave as if the left button was clicked in the standard button layout.
115+
*
116+
* @name Phaser.Input.Pointer#button
117+
* @type {integer}
118+
* @readonly
119+
* @default 0
120+
* @since 3.18.0
121+
*/
122+
this.button = 0;
123+
106124
/**
107125
* 0: No button or un-initialized
108126
* 1: Left button
@@ -544,6 +562,8 @@ var Pointer = new Class({
544562

545563
this.event = event;
546564

565+
this.button = event.button;
566+
547567
this.upElement = event.target;
548568

549569
// Sets the local x/y properties
@@ -581,6 +601,8 @@ var Pointer = new Class({
581601

582602
this.event = event;
583603

604+
this.button = event.button;
605+
584606
this.downElement = event.target;
585607

586608
// Sets the local x/y properties
@@ -876,6 +898,71 @@ var Pointer = new Class({
876898
return (this.buttons & 16) ? true : false;
877899
},
878900

901+
/**
902+
* Checks to see if the left button was just released on this Pointer.
903+
*
904+
* @method Phaser.Input.Pointer#leftButtonReleased
905+
* @since 3.18.0
906+
*
907+
* @return {boolean} `true` if the left button was just released.
908+
*/
909+
leftButtonReleased: function ()
910+
{
911+
return (this.button === 0 && !this.isDown);
912+
},
913+
914+
/**
915+
* Checks to see if the right button was just released on this Pointer.
916+
*
917+
* @method Phaser.Input.Pointer#rightButtonReleased
918+
* @since 3.18.0
919+
*
920+
* @return {boolean} `true` if the right button was just released.
921+
*/
922+
rightButtonReleased: function ()
923+
{
924+
return (this.button === 2 && !this.isDown);
925+
},
926+
927+
/**
928+
* Checks to see if the middle button was just released on this Pointer.
929+
*
930+
* @method Phaser.Input.Pointer#middleButtonReleased
931+
* @since 3.18.0
932+
*
933+
* @return {boolean} `true` if the middle button was just released.
934+
*/
935+
middleButtonReleased: function ()
936+
{
937+
return (this.button === 1 && !this.isDown);
938+
},
939+
940+
/**
941+
* Checks to see if the back button was just released on this Pointer.
942+
*
943+
* @method Phaser.Input.Pointer#backButtonReleased
944+
* @since 3.18.0
945+
*
946+
* @return {boolean} `true` if the back button was just released.
947+
*/
948+
backButtonReleased: function ()
949+
{
950+
return (this.button === 3 && !this.isDown);
951+
},
952+
953+
/**
954+
* Checks to see if the forward button was just released on this Pointer.
955+
*
956+
* @method Phaser.Input.Pointer#forwardButtonReleased
957+
* @since 3.18.0
958+
*
959+
* @return {boolean} `true` if the forward button was just released.
960+
*/
961+
forwardButtonReleased: function ()
962+
{
963+
return (this.button === 4 && !this.isDown);
964+
},
965+
879966
/**
880967
* If the Pointer has a button pressed down at the time this method is called, it will return the
881968
* distance between the Pointer's `downX` and `downY` values and the current position.

src/physics/arcade/StaticPhysicsGroup.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
var ArcadeSprite = require('./ArcadeSprite');
88
var Class = require('../../utils/Class');
99
var CONST = require('./const');
10+
var GetFastValue = require('../../utils/object/GetFastValue');
1011
var Group = require('../../gameobjects/group/Group');
1112
var IsPlainObject = require('../../utils/object/IsPlainObject');
1213

@@ -55,7 +56,7 @@ var StaticPhysicsGroup = new Class({
5556
config.createCallback = this.createCallbackHandler;
5657
config.removeCallback = this.removeCallbackHandler;
5758
config.createMultipleCallback = this.createMultipleCallbackHandler;
58-
config.classType = ArcadeSprite;
59+
config.classType = GetFastValue(config, 'classType', ArcadeSprite);
5960
}
6061
else if (Array.isArray(children) && IsPlainObject(children[0]))
6162
{
@@ -68,7 +69,7 @@ var StaticPhysicsGroup = new Class({
6869
singleConfig.createCallback = this.createCallbackHandler;
6970
singleConfig.removeCallback = this.removeCallbackHandler;
7071
singleConfig.createMultipleCallback = this.createMultipleCallbackHandler;
71-
singleConfig.classType = ArcadeSprite;
72+
singleConfig.classType = GetFastValue(singleConfig, 'classType', ArcadeSprite);
7273
});
7374
}
7475

src/tilemaps/parsers/impact/ParseWeltmeister.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ var MapData = require('../../mapdata/MapData');
99
var ParseTileLayers = require('./ParseTileLayers');
1010
var ParseTilesets = require('./ParseTilesets');
1111

12-
/**
13-
* @namespace Phaser.Tilemaps.Parsers.Impact
14-
*/
15-
1612
/**
1713
* Parses a Weltmeister JSON object into a new MapData object.
1814
*
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* @namespace Phaser.Tilemaps.Parsers.Impact
9+
*/
10+
11+
module.exports = {
12+
13+
ParseTileLayers: require('./ParseTileLayers'),
14+
ParseTilesets: require('./ParseTilesets'),
15+
ParseWeltmeister: require('./ParseWeltmeister')
16+
17+
};

src/tilemaps/parsers/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
Parse2DArray: require('./Parse2DArray'),
1515
ParseCSV: require('./ParseCSV'),
1616

17-
Impact: require('./impact/ParseWeltmeister'),
18-
Tiled: require('./tiled/ParseJSONTiled')
17+
Impact: require('./impact/'),
18+
Tiled: require('./tiled/')
1919

2020
};

src/tilemaps/parsers/tiled/ParseJSONTiled.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ var ParseObjectLayers = require('./ParseObjectLayers');
1313
var BuildTilesetIndex = require('./BuildTilesetIndex');
1414
var AssignTileProperties = require('./AssignTileProperties');
1515

16-
/**
17-
* @namespace Phaser.Tilemaps.Parsers.Tiled
18-
*/
19-
2016
/**
2117
* Parses a Tiled JSON object into a new MapData object.
2218
*

src/tilemaps/parsers/tiled/ParseObject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @license {@link https://opensource.org/licenses/MIT|MIT License}
55
*/
66

7-
var Pick = require('./Pick');
7+
var Pick = require('../../../utils/object/Pick');
88
var ParseGID = require('./ParseGID');
99

1010
var copyPoints = function (p) { return { x: p.x, y: p.y }; };

src/tilemaps/parsers/tiled/ParseTilesets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var ImageCollection = require('../../ImageCollection');
99
var ParseObject = require('./ParseObject');
1010

1111
/**
12-
* Tilesets & Image Collections
12+
* Tilesets and Image Collections
1313
*
1414
* @function Phaser.Tilemaps.Parsers.Tiled.ParseTilesets
1515
* @since 3.0.0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* @namespace Phaser.Tilemaps.Parsers.Tiled
9+
*/
10+
11+
module.exports = {
12+
13+
AssignTileProperties: require('./AssignTileProperties'),
14+
Base64Decode: require('./Base64Decode'),
15+
BuildTilesetIndex: require('./BuildTilesetIndex'),
16+
ParseGID: require('./ParseGID'),
17+
ParseImageLayers: require('./ParseImageLayers'),
18+
ParseJSONTiled: require('./ParseJSONTiled'),
19+
ParseObject: require('./ParseObject'),
20+
ParseObjectLayers: require('./ParseObjectLayers'),
21+
ParseTileLayers: require('./ParseTileLayers'),
22+
ParseTilesets: require('./ParseTilesets')
23+
24+
};

0 commit comments

Comments
 (0)