123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- // 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 { GUIManager } from "./GUIManager";
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class GUIMediator{
- _view:fgui.GComponent;
- uiKey:number;
- data:any;
- /**
- * 内部接口
- * @param data
- */
- Show(data?:any):void{
- this.data=data;
- this.AddEvents();
- this.OnShow();
- }
- Hide():void{
- this.RemoveEvents();
- this.OnHide();
- }
- protected OnShow():void{
-
- }
- protected OnHide():void{
- }
- protected AddEvents():void{
- }
- protected RemoveEvents():void{
- }
- /**
- * 心跳
- * @param dt
- */
- Tick(dt:number):void{
- this.enterFrame();
- }
- /**
- * 关闭自己
- */
- HideSelf():void{
- GUIManager.single.Hide(this.uiKey);
- }
- /**
- * 销毁
- */
- OnDestory():void{
- }
- /**
- * 所在层次
- */
- get LayerIndex(){
- return 3;
- }
- /**
- * 下一帧需要回调的函数
- */
- private nextFrameCallHandler:Function[]=[];
- /**
- * 进入这一帧
- */
- enterFrame():void{
- this.nextFrameCallHandler.forEach(element => {
- element();
- });
- this.nextFrameCallHandler.length=0;
- }
- /**
- *
- * @param value 下一帧调用
- */
- CallNextFrame(value:Function):void{
- if(this.nextFrameCallHandler.indexOf(value)>=0){
- return;
- }
- this.nextFrameCallHandler.push(value);
- }
- }
|