觉醒时刻
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
juexingshike/assets/FrameWork/Base/FMComponentExtend.ts

71 lines
1.9 KiB

1 week ago
/*
* @Author: YeeChan
* @Date: 2020-12-23 11:46:50
* @Description:
*/
/****************************************************
* cc.Component initView_custom __onInit_custom
*****************************************************/
export default abstract class FMComponentExtend extends cc.Component {
//标记
protected __isInit_custom: boolean = false;
//回调
protected _listenerCallView_custom: FMListener;
//各个节点自定义事件
//@ts-ignore
protected abstract EventEnumView_custom: { [key: string]: string; } = {}
//初始方法
protected abstract initView_custom(): void;
protected onLoad() {
this.__onInit_custom();
}
/**
* onload中执行的属性
*/
protected __onInit_custom() {
if (!this.__isInit_custom) {
this.__isInit_custom = true;
this.initView_custom();
}
}
/**
*
* @param listener
*/
public onListenerEventView_custom(listener: FMListener) {
this._listenerCallView_custom = listener;
}
/**
* ((Event,Node,Data) )
* @param event @EventEnumView_custom
* @param data
*/
protected emitListenerEvent_custom(event: string, data?: any, data2?: any) {
//console.log("发送 " + event)
if (this._listenerCallView_custom) {
callFM_custom(this._listenerCallView_custom, event, this, data, data2);
}
}
/**
* view
*/
public isActiveView_custom(): boolean {
if (cc.isValid(this, true) && this.node.activeInHierarchy) { //没有被销毁 && 在场景中是激活的
return true;
}
return false;
}
//当该组件被销毁时调用
protected onDestroy(): void {
}
}