//#region 文件引入 import { _decorator, Button, Component, Label, Node, sp, Sprite,Animation, RichText, Prefab, instantiate, tween, UIOpacity, v3, v2 } from "cc"; import UIParse from "../../Mgr_UI/UIParse"; import MathUtils from "../../ExUtils/MathUtils"; //#endregion 文件引入 const {ccclass, property,menu} = _decorator; @ccclass("EnemyTJCoin_Proxy") export default class EnemyTJCoin_Proxy extends UIParse{ //#region 节点自动生成 @property(Label) lab_num: Label = null; //#endregion 节点自动生成 private static textPool: Node[] = []; static CreateCoin(_prefab: Prefab) { if (this.textPool.length) { return this.textPool.pop(); } else { return instantiate(_prefab); } } static RecycleCoin(tNode: Node) { tNode.removeFromParent(); this.textPool.push(tNode); } onButtonClick(button:Button){ /**点击事件触发*/ switch (button) { default: ConsoleEx.Log(button); break; } } onAnimationEvent(){ EnemyTJCoin_Proxy.RecycleCoin(this.node); } PlayText(text:string){ CNodeUtils.setOpacity(this.node, 255); const tUIOpacity = this.node.getComponent(UIOpacity); // 非暴击飘字效果:保持原来的贝塞尔曲线运动 const Start = v2(MathUtils.randomRangeInt(0, 30), MathUtils.randomRangeInt(0, 30)) const End = v3(-150 + MathUtils.randomRangeInt(0, 30), -100, 0); const Min = v2(End.x * 0.3, 150 + MathUtils.randomRangeInt(0, 50)) const bezier = CNodeUtils.bezierTo(this.node, 0.5, Start, Min, End, {}); const Opacity = tween(tUIOpacity).delay(0.8).to(0.7, { opacity: 0 }); tween(this.node).parallel(bezier, Opacity).call(() => { this.onAnimationEvent(); }).start(); // const bezier = tween(this.node).delay(0.3).to(0.7,{position:v3(0,100)}); // const Opacity = tween(tUIOpacity).delay(0.3).to(0.7, { opacity: 0 }); // tween(this.node).parallel(bezier, Opacity).call(() => { // this.onAnimationEvent(); // }).start(); CNodeUtils.switchText(this.lab_num, text); } }