phaser/v3/src/actions/PlaceOnCircle.js

21 lines
539 B
JavaScript
Raw Normal View History

var PlaceOnCircle = function (items, circle, startAngle, endAngle)
{
if (startAngle === undefined) { startAngle = 0; }
if (endAngle === undefined) { endAngle = 6.28; }
var angle = startAngle;
var angleStep = (endAngle - startAngle) / items.length;
for (var i = 0; i < items.length; i++)
{
items[i].x = circle.x + (circle.radius * Math.cos(angle));
items[i].y = circle.y + (circle.radius * Math.sin(angle));
angle += angleStep;
}
return items;
};
module.exports = PlaceOnCircle;