mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 21:53:59 +00:00
Updated setScore handling
This commit is contained in:
parent
f3a46f55e5
commit
0557ee071b
2 changed files with 35 additions and 7 deletions
|
@ -2,6 +2,13 @@
|
|||
|
||||
## Version 3.16.0 - Ishikawa - in development
|
||||
|
||||
### Facebook Instant Games Updates and Fixes
|
||||
|
||||
* The `loadPlayerPhoto` function in the Instant Games plugin now listens for the updated Loader event correctly, causing the `photocomplete` event to fire properly.
|
||||
* `Leaderboard.setScore` now emits the LeaderboardScore object with the `setscore` event, as the documentation said it did.
|
||||
* `Leaderboard.getPlayerScore` now only populates the `playerScore` property if the entry isn't `null`.
|
||||
* If the `setScore` or `getPlayerScore` calls fail, it will return `null` as the score instance, instead of causing a run-time error.
|
||||
|
||||
### New Features
|
||||
|
||||
* The data object being sent to the Dynamic Bitmap Text callback now has a new property `parent`, which is a reference to the Bitmap Text instance that owns the data object (thanks ornyth)
|
||||
|
@ -29,7 +36,6 @@
|
|||
|
||||
### Bug Fixes
|
||||
|
||||
* The `loadPlayerPhoto` function in the Instant Games plugin now listens for the updated Loader event correctly, causing the `photocomplete` event to fire properly.
|
||||
* The Rectangle Shape object wouldn't render if it didn't have a stroke, or any other objects on the display list (thanks mliko)
|
||||
* When using a font string instead of setting `fontFamily`, `fontSize` and `fontStyle` in either `Text.setStyle` or `setFont`, the style properties wouldn't get set. This isn't a problem while creating the text object, only if modifying it later (thanks @DotTheGreat)
|
||||
* Disabling camera bounds and then moving the camera to an area in a Tilemap that did not have any tile information would throw an `Uncaught Reference error` as it tried to access tiles that did not exist (thanks @Siyalatas)
|
||||
|
|
|
@ -139,7 +139,9 @@ var Leaderboard = new Class({
|
|||
*
|
||||
* The data is requested in an async call, so the result isn't available immediately.
|
||||
*
|
||||
* When the call completes this Leaderboard will emit the `setscore` event along with the score, any extra data and the name of the Leaderboard.
|
||||
* When the call completes this Leaderboard will emit the `setscore` event along with the LeaderboardScore object and the name of the Leaderboard.
|
||||
*
|
||||
* If the save fails the event will send `null` as the score value.
|
||||
*
|
||||
* @method Phaser.FacebookInstantGamesPlugin.Leaderboard#setScore
|
||||
* @since 3.13.0
|
||||
|
@ -157,7 +159,18 @@ var Leaderboard = new Class({
|
|||
|
||||
this.ref.setScoreAsync(score, data).then(function (entry)
|
||||
{
|
||||
_this.emit('setscore', entry.getScore(), entry.getExtraData(), _this.name);
|
||||
if (entry)
|
||||
{
|
||||
var score = LeaderboardScore(entry);
|
||||
|
||||
_this.playerScore = score;
|
||||
|
||||
_this.emit('setscore', score, _this.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
_this.emit('setscore', null, _this.name);
|
||||
}
|
||||
|
||||
}).catch(function (e)
|
||||
{
|
||||
|
@ -173,6 +186,8 @@ var Leaderboard = new Class({
|
|||
* The data is requested in an async call, so the result isn't available immediately.
|
||||
*
|
||||
* When the call completes this Leaderboard will emit the `getplayerscore` event along with the score and the name of the Leaderboard.
|
||||
*
|
||||
* If the player has not yet saved a score, the event will send `null` as the score value, and `playerScore` will be set to `null` as well.
|
||||
*
|
||||
* @method Phaser.FacebookInstantGamesPlugin.Leaderboard#getPlayerScore
|
||||
* @since 3.13.0
|
||||
|
@ -185,11 +200,18 @@ var Leaderboard = new Class({
|
|||
|
||||
this.ref.getPlayerEntryAsync().then(function (entry)
|
||||
{
|
||||
var score = LeaderboardScore(entry);
|
||||
if (entry)
|
||||
{
|
||||
var score = LeaderboardScore(entry);
|
||||
|
||||
_this.playerScore = score;
|
||||
|
||||
_this.emit('getplayerscore', score, _this.name);
|
||||
_this.playerScore = score;
|
||||
|
||||
_this.emit('getplayerscore', score, _this.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
_this.emit('getplayerscore', null, _this.name);
|
||||
}
|
||||
|
||||
}).catch(function (e)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue