Spaces:
Build error
Build error
File size: 1,407 Bytes
670a607 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import Base from '../base/Base.js';
import { Line } from '../utils/Geoms.js'
const Linear = Phaser.Math.Linear;
class Los extends Base {
constructor(scene, config) {
super(scene, config);
this.type = 'rexSpinnerLos';
}
buildShapes() {
for (var i = 0; i < 12; i++) {
this.addShape(new Line());
}
}
updateShapes() {
var centerX = this.centerX;
var centerY = this.centerY;
var isSizeChanged = this.isSizeChanged;
var radius = this.radius;
var startRadius = radius / 2;
var lineWidth = Math.ceil(radius / 20);
var shapes = this.getShapes();
for (var i = 0, cnt = shapes.length; i < cnt; i++) {
var line = shapes[i];
var t = i / cnt;
var angle = Math.PI * 2 * t;
var alpha = Linear(0.25, 1, (1 - this.value + t) % 1);
line.lineStyle(lineWidth, this.color, alpha);
if (isSizeChanged) {
line
.setP0(
centerX + Math.cos(angle) * startRadius,
centerY + Math.sin(angle) * startRadius
)
.setP1(
centerX + Math.cos(angle) * radius,
centerY + Math.sin(angle) * radius
)
}
}
}
}
export default Los; |