123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { GameEvent } from "../../../data/const/EventConst";
- import { ViewZOrder } from "../../../data/const/ViewZOrder";
- import GameDataCenter from "../../../data/GameDataCenter";
- import EventMng from "../../../manager/EventMng";
- import SpineNode from "../../../utils/SpineNode";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class UIClickEft extends cc.Component {
- clickEft: SpineNode
- protected onEnable(): void {
- EventMng.on(GameEvent.ON_CLICK, this.onClick, this)
- }
- protected onDisable(): void {
- EventMng.off(GameEvent.ON_CLICK, this.onClick, this)
- }
- start() {
- cc.game.addPersistRootNode(this.node)
- this.node.zIndex = ViewZOrder.ClickEft
- let node = new SpineNode("spine", "effect_dianji01/effect_dianji01", 1, "animation", false, 1, () => {
- this.clickEft = node
- // node.spine.setCompleteListener((trackEntry: sp.spine.TrackEntry) => {
- // this.clickEft.node.active = false
- // })
- // node.active = false
- this.clickEft.spine.setCompleteListener(this.OnCompleteListener.bind(this));
- }, true)
- node.parent = this.node
- node.x = -200
- }
- onClick(event) {
- GameDataCenter.time.guideRuoTime = 0
- if (this.clickEft == null) {
- return
- }
- this.clickEft.active = true;
- this.clickEft.x = event.getLocationX()
- this.clickEft.y = event.getLocationY()
- this.clickEft.spine.setAnimation(0, "animation", false)
- }
- OnCompleteListener() {
- this.clickEft.active = false;
- }
- }
|