mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
Update Point.js
This commit is contained in:
parent
14b16fb583
commit
1d1e47d68d
1 changed files with 6 additions and 4 deletions
|
@ -470,20 +470,22 @@ Phaser.Point.centroid = function (points, out) {
|
|||
throw new Error("Phaser.Point. Parameter 'points' must be an array")
|
||||
}
|
||||
|
||||
if (points.length < 1) {
|
||||
var pointslength = points.length;
|
||||
|
||||
if (pointslength < 1) {
|
||||
throw new Error("Phaser.Point. Parameter 'points' array must not be empty")
|
||||
}
|
||||
|
||||
if (points.length === 1) {
|
||||
if (pointslength === 1) {
|
||||
out.copyFrom(points[0]);
|
||||
return out;
|
||||
}
|
||||
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
for (var i = 0; i < pointslength; i++) {
|
||||
Phaser.Point.add(out, points[i], out);
|
||||
}
|
||||
|
||||
out.divide(points.length, points.length);
|
||||
out.divide(pointslength, pointslength);
|
||||
|
||||
return out;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue