const {ccclass, property} = cc._decorator;
@ccclass
export default class Prog extends cc.Component {
@property(cc.Sprite)
SpriteProg : cc.Sprite = null;
@property(cc.Node)
NodePoint : cc.Node = null;
// LIFE-CYCLE CALLBACKS:
onLoad () {}
start () {
this.refreshParticle();
this.schedule(()=>{
this.SpriteProg.fillRange -= 0.05;
if(this.SpriteProg.fillRange < 0){
this.SpriteProg.fillRange = 1;
}
this.refreshParticle();
},0.5)
}
refreshParticle() {
let W = this.SpriteProg.node.width / 2 - 2
let H = this.SpriteProg.node.height / 2 - 2
let A = Math.atan(H / W)
let x = 0;
let y = 0;
let PI = Math.PI;
let cur_fill = 1 - this.SpriteProg.fillRange;
let a = PI * 2 * cur_fill;
if (PI*2-A <= a || a <= A) {
x = W
y = -W * Math.tan(a)
}
else if (A < a && a < PI - A) {
x = H / Math.tan(a)
y = -H
}
else if (PI-A <= a && a <= PI+A) {
x = -W
y = W * Math.tan(a)
}
else if (PI+A < a && a < PI*2-A) {
x = -H / Math.tan(a)
y = H
}
this.NodePoint.x = this.SpriteProg.node.x + x - 1;
this.NodePoint.y = this.SpriteProg.node.y + y;
}
update (dt) {
}
}