金币飞往目标位置
createStarEffect(cNode, count, goldNum) {
let icon = cc.find("Canvas/homeUI/top/starGroup/starIcon");
let cWpos = cNode.parent.convertToWorldSpaceAR(cNode.position);
let cNpos = this.node.convertToNodeSpaceAR(cWpos);
let tWpos = icon.parent.convertToWorldSpaceAR(icon.position);
let tNpos = this.node.convertToNodeSpaceAR(tWpos)
let moveSpeed = 1000;
let random1 = 200;
if (count >= 30) {
count = 30;
};
let standingTime = 0.2;
for (let i = 0; i < count; i++) {
let dircetion = Math.random() > 0.5 ? 1 : -1;
let random_x = Math.floor(Math.random() * (random1 * dircetion) + cNpos.x);
let random_y = Math.floor(Math.random() * (random1 * dircetion) + cNpos.y);
let distance = cNpos.sub(tNpos).mag();
if (this.newStarEffectNodePool.size() > 0) {
let node = this.newStarEffectNodePool.get();
node.parent = this.node;
node.position = cNpos;
cc.tween(node)
.to(standingTime, { position: cc.v2(random_x, random_y) })
.call(() => {
cc.tween(node)
.to(distance / moveSpeed + i / 50, { position: tNpos }, { easing: "sineIn" })
.call(() => {
if (i == count - 1) {
this.gameRules.updateStarLabel(goldNum);
};
this.onNodeKill(node);
})
.start();
})
.start();
};
};
},