Skip to content

Commit 1b5da31

Browse files
committed
RandomDataGenerator.weightedPick has been tweaked slightly to allow for a more even distribution of weights. It still favors the earlier array elements, but will accurately include 'distance' elements as well (thanks @gingerbeardman phaserjs#1751)
1 parent 87ac0b8 commit 1b5da31

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ Version 2.4 - "Katar" - in dev
376376
* P2.enableBody now checks if an anchor exists on target object before attempting to set its value (thanks @standardgaussian #1885)
377377
* Debug.currentAlpha wasn't being used to set the alpha of the Debug context at all (was always set to 1) but now updates the alpha of the Debug context before anything is rendered to it (thanks @wayfu #1888)
378378
* If the device is detected as a Windows Phone the renderer is automatically set to use Canvas, even if WebGL or AUTO was requested (thanks @ramarro123 #1706)
379+
* RandomDataGenerator.weightedPick has been tweaked slightly to allow for a more even distribution of weights. It still favors the earlier array elements, but will accurately include 'distance' elements as well (thanks @gingerbeardman #1751)
379380

380381
### Bug Fixes
381382

@@ -427,6 +428,7 @@ Version 2.4 - "Katar" - in dev
427428
* Device.windowsPhone should now correctly identify Windows Phone 8.1 devices, which also think they are iOS and Androids. If you find a device that gets around this check please send us its ua string! (thanks @jounii #1496)
428429
* Rope.segments used the wrong vertices property, causing a runtime error.
429430
* Debug.ropeSegments didn't take the scale of the Rope object into consideration, causing incorrect debug rendering.
431+
* If a Sound was muted, or had its volume changed while it was still decoding (i.e. before it started playback) then the mute and/or volume were ignored and the sound would play anyway (thanks @brianbunch #1872)
430432

431433
### Deprecated
432434

src/math/RandomDataGenerator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ Phaser.RandomDataGenerator.prototype = {
270270
*/
271271
weightedPick: function (ary) {
272272

273-
return ary[~~(Math.pow(this.frac(), 2) * (ary.length - 1))];
273+
return ary[~~(Math.pow(this.frac(), 2) * (ary.length - 1) + 0.5)];
274274

275275
},
276276

0 commit comments

Comments
 (0)