phaser/v3/src/actions/PlaceOnLine.js
2017-03-29 16:04:51 +01:00

23 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;