mirror of
https://github.com/photonstorm/phaser
synced 2024-11-21 20:23:19 +00:00
Modified RandomDataGenerator.weightedPick
method to avoid sampling past the last element. Fix #6701
This commit is contained in:
parent
7c5e4dc2f6
commit
a2f47d65c1
1 changed files with 1 additions and 1 deletions
|
@ -390,7 +390,7 @@ var RandomDataGenerator = new Class({
|
||||||
*/
|
*/
|
||||||
weightedPick: function (array)
|
weightedPick: function (array)
|
||||||
{
|
{
|
||||||
return array[~~(Math.pow(this.frac(), 2) * array.length + 0.5)];
|
return array[~~(Math.pow(this.frac(), 2) * (array.length - 0.5) + 0.5)];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue