Просмотр исходного кода

Merge branch 'master' of http://git.mokasz.com/zouyong/mk_framework

薛鸿潇 5 лет назад
Родитель
Сommit
d74248e5f2
2 измененных файлов с 85 добавлено и 45 удалено
  1. 82 44
      assets/script/mk/system/MKSystem.ts
  2. 3 1
      assets/script/mk/system/TipSystem.ts

+ 82 - 44
assets/script/mk/system/MKSystem.ts

@@ -25,60 +25,98 @@ import PoolSystem from "./PoolSystem";
  */
 class MKSystem {
     constructor() {
-        this.init();
+        
     }
 
     /** 工具 */
-    time: TimeUtil;
-    file: FileUtil;
-    encrypt: EncryptUtil;
-    console: LogUtil;
-    game: GameUtil;
-    loader: LoadResUtil;
-    storage: StorageUtil;
-    math: MathUtil;
+    _time: TimeUtil;
+    public get time():TimeUtil{
+        return this._time || new TimeUtil();
+    }
+    _file: FileUtil;
+    public get file():FileUtil{
+        return this._file || new FileUtil();
+    }
+    _encrypt: EncryptUtil;
+    public get encrypt():EncryptUtil{
+        return this._encrypt || new EncryptUtil();
+    }
+    _console: LogUtil;
+    public get console():LogUtil{
+        return this._console || new LogUtil();
+    }
+    _game: GameUtil;
+    public get game():GameUtil{
+        return this._game || new GameUtil();
+    }
+    _loader: LoadResUtil;
+    public get loader():LoadResUtil{
+        return this._loader || new LoadResUtil();
+    }
+    _storage: StorageUtil;
+    public get storage():StorageUtil{
+        return this._storage || new StorageUtil();
+    }
+    _math: MathUtil;
+    public get math():MathUtil{
+        return this._math || new MathUtil();
+    }
 
     /** SDK */
-    bugly: BuglySDK;
+    _bugly: BuglySDK;
+    public get bugly():BuglySDK{
+        return this._bugly || new BuglySDK();
+    }
 
 
     /** 系统管理 */
-    data: DataSystem;
-    ad: AdSystem;
-    jsb: JsbSystem;
-    http: HttpSystem;
-    audio: AudioSystem;
-    timer: TimerSystem;
-    event: EventSystem;
-    pool:PoolSystem;
+    _data: DataSystem;
+    public get data():DataSystem{
+        return this._data || new DataSystem();
+    }
+    _ad: AdSystem;
+    public get ad():AdSystem{
+        return this._ad || new AdSystem(ATSDKMgr.getInstance());
+    }
+    _jsb: JsbSystem;
+    public get jsb():JsbSystem{
+        return this._jsb || new JsbSystem();
+    }
+    _http: HttpSystem;
+    public get http():HttpSystem{
+        return this._http || new HttpSystem();
+    }
+    _audio: AudioSystem;
+    public get audio():AudioSystem{
+        return this._audio || new AudioSystem();
+    }
+    _timer: TimerSystem;
+    public get timer():TimerSystem{
+        return this._timer || new TimerSystem();
+    }
+    _event: EventSystem;
+    public get event():EventSystem{
+        return this._event || new EventSystem();
+    }
+    _pool:PoolSystem;
+    public get pool():PoolSystem{
+        return this._pool || new PoolSystem();
+    }
 
     /** 挂载在MainScene的界面上,不需要new */
-    ui: UISystem;
-    tip:TipSystem;
-
-    init() {
-        //工具
-        this.time = new TimeUtil();
-        this.file = new FileUtil();
-        this.encrypt = new EncryptUtil();
-        this.console = new LogUtil();
-        this.game = new GameUtil();
-        this.loader = new LoadResUtil();
-        this.storage = new StorageUtil();
-        this.math = new MathUtil();
-
-        //sdk
-        this.bugly = new BuglySDK();
-
-        //system
-        this.data = new DataSystem();
-        this.http = new HttpSystem();
-        this.audio = new AudioSystem();
-        this.ad = new AdSystem(ATSDKMgr.getInstance());
-        this.jsb = new JsbSystem();
-        this.timer = new TimerSystem();
-        this.event = new EventSystem();
-        this.pool = new PoolSystem();
+    _ui: UISystem;
+    public get ui():UISystem{
+        return this._ui || new UISystem();
+    }
+    public set ui(v:UISystem){
+        this._ui = v;
+    }
+    _tip:TipSystem;
+    public get tip():TipSystem{
+        return this._tip || new TipSystem();
+    }
+    public set tip(v:TipSystem){
+        this._tip = v;
     }
 }
 

+ 3 - 1
assets/script/mk/system/TipSystem.ts

@@ -38,7 +38,9 @@ export default class TipSystem extends cc.Component {
 
     public async pop(str: string) {
         let node = await mk.pool.getPrefab("game/prefab/tips");
-        node.getChildByName("bg")
+        let bg = node.getChildByName("bg");
+        let lbl = node.getChildByName("lbl");
+        bg.getComponent(cc.Sprite)
         console.log(node);
     }