Merge pull request #6300 from EmilSV/spread_step_fix

fixed Phaser.Actions.Spread step value so the last element is equal max
This commit is contained in:
Richard Davey 2022-12-09 15:37:58 +00:00 committed by GitHub
commit d44db46253
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,8 +32,22 @@
var Spread = function (items, property, min, max, inc)
{
if (inc === undefined) { inc = false; }
if (items.length === 0) { return items; }
if (items.length === 1) // if only one item put it at the center
{
if (inc)
{
items[0][property] += (max + min) / 2;
}
else
{
items[0][property] = (max + min) / 2;
}
var step = Math.abs(max - min) / items.length;
return items;
}
var step = Math.abs(max - min) / (items.length - 1);
var i;
if (inc)