mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Added PlaceOnEllipse action and added to Group
This commit is contained in:
parent
5f04a659e0
commit
9eb723cfc2
4 changed files with 32 additions and 1 deletions
23
v3/src/actions/PlaceOnEllipse.js
Normal file
23
v3/src/actions/PlaceOnEllipse.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle)
|
||||
{
|
||||
if (startAngle === undefined) { startAngle = 0; }
|
||||
if (endAngle === undefined) { endAngle = 6.28; }
|
||||
|
||||
var angle = startAngle;
|
||||
var angleStep = (endAngle - startAngle) / items.length;
|
||||
|
||||
var a = ellipse.width / 2;
|
||||
var b = ellipse.height / 2;
|
||||
|
||||
for (var i = 0; i < items.length; i++)
|
||||
{
|
||||
items[i].x = ellipse.x + a * Math.cos(angle);
|
||||
items[i].y = ellipse.y + b * Math.sin(angle);
|
||||
|
||||
angle += angleStep;
|
||||
}
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
module.exports = PlaceOnEllipse;
|
|
@ -11,6 +11,7 @@ module.exports = {
|
|||
IncXY: require('./IncXY'),
|
||||
IncY: require('./IncY'),
|
||||
PlaceOnCircle: require('./PlaceOnCircle'),
|
||||
PlaceOnEllipse: require('./PlaceOnEllipse'),
|
||||
PlaceOnLine: require('./PlaceOnLine'),
|
||||
PlaceOnRectangle: require('./PlaceOnRectangle'),
|
||||
PlaceOnTriangle: require('./PlaceOnTriangle'),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var CHECKSUM = {
|
||||
build: '5d97e130-7716-11e7-8b1c-25a8a89333fb'
|
||||
build: '9aad2b50-7718-11e7-a802-eddafadf9983'
|
||||
};
|
||||
module.exports = CHECKSUM;
|
|
@ -284,6 +284,13 @@ var Group = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
placeOnEllipse: function (ellipse, startAngle, endAngle)
|
||||
{
|
||||
Actions.PlaceOnEllipse(this.children.entries, ellipse, startAngle, endAngle);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
placeOnLine: function (line)
|
||||
{
|
||||
Actions.PlaceOnLine(this.children.entries, line);
|
||||
|
|
Loading…
Reference in a new issue