mirror of
https://github.com/photonstorm/phaser
synced 2024-12-25 04:23:30 +00:00
24 lines
463 B
JavaScript
24 lines
463 B
JavaScript
|
var GetPointsOnLine = require('../geom/line/GetPointsOnLine');
|
||
|
|
||
|
var PlaceOnLine = function (items, line)
|
||
|
{
|
||
|
var points = GetPointsOnLine(line);
|
||
|
var step = points.length / items.length;
|
||
|
var p = 0;
|
||
|
|
||
|
for (var i = 0; i < items.length; i++)
|
||
|
{
|
||
|
var item = items[i];
|
||
|
var point = points[Math.floor(p)];
|
||
|
|
||
|
item.x = point[0];
|
||
|
item.y = point[1];
|
||
|
|
||
|
p += step;
|
||
|
}
|
||
|
|
||
|
return items;
|
||
|
};
|
||
|
|
||
|
module.exports = PlaceOnLine;
|