// Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html import { MapView } from "../kernel/battle/map/MapView"; import { ObjData } from "../kernel/battle/map/ObjData"; import { PotObj } from "../kernel/battle/map/PotObj"; import ObjBaseView from "./ObjBaseView"; const { ccclass, property } = cc._decorator; @ccclass export default class PotView extends ObjBaseView { private _effect: cc.Node; //#region life cycle init(owner: ObjData, mapView: MapView): void { this._effect = this.node.getChildByName("UI_yxz_tsfk_ph"); this._effect.removeFromParent(); mapView.effectLayer.addChild(this._effect); super.init(owner, mapView); this._img.active = false; } protected update(dt: number): void { super.update(dt); this._effect.angle = (this.owner as PotObj).angle; } onDead(): void { super.onDead(); this._effect.destroy(); } //#endregion //#region event onHit(): void { super.onHit(); let ani = this._effect.getComponent(cc.Animation); ani && !ani.getAnimationState('fx_yxz_tsfk_ph_001').isPlaying && ani.play('fx_yxz_tsfk_ph_001', 0); } protected onVisibleChange(): void { this._img.active = false; //图片一直隐藏 } protected onPositionChange(x: number, y: number): void { super.onPositionChange(x, y); this._effect.setPosition(x, y); } //#endregion }