zouyong 5 years ago
parent
commit
826b084ce0
2 changed files with 27 additions and 42 deletions
  1. 17 34
      assets/script/mk/system/MKSystem.ts
  2. 10 8
      assets/script/mk/system/TipSystem.ts

+ 17 - 34
assets/script/mk/system/MKSystem.ts

@@ -31,93 +31,76 @@ class MKSystem {
     /** 工具 */
     private _time: TimeUtil;
     public get time(): TimeUtil {
-        if (!this._time) this._time = new TimeUtil();
-        return this._time;
+        return this._time || (this._time = new TimeUtil());
     }
     private _file: FileUtil;
     public get file(): FileUtil {
-        if(!this._file) this._file = new FileUtil();
-        return this._file;
+        return this._file || (this._file = new FileUtil());
     }
     private _encrypt: EncryptUtil;
     public get encrypt(): EncryptUtil {
-        if(!this._encrypt) this._encrypt = new EncryptUtil();
-        return this._encrypt;
+        return this._encrypt || (this._encrypt = new EncryptUtil());
     }
     private _console: LogUtil;
     public get console(): LogUtil {
-        if(!this._console) this._console = new LogUtil();
-        return this._console;
+        return this._console || (this._console = new LogUtil());
     }
     private _game: GameUtil;
     public get game(): GameUtil {
-        if(!this._game) this._game = new GameUtil();
-        return this._game;
+        return this._game || (this._game = new GameUtil());
     }
     private _loader: LoadResUtil;
     public get loader(): LoadResUtil {
-        if(!this._loader) this._loader = new LoadResUtil();
-        return this._loader;
+        return this._loader || (this._loader = new LoadResUtil());
     }
     private _storage: StorageUtil;
     public get storage(): StorageUtil {
-        if(!this._storage) this._storage = new StorageUtil();
-        return this._storage;
+        return this._storage || (this._storage = new StorageUtil());
     }
     private _math: MathUtil;
     public get math(): MathUtil {
-        if(!this._math) this._math = new MathUtil();
-        return this._math;
+        return this._math || (this._math = new MathUtil());
     }
 
     /** SDK */
     private _bugly: BuglySDK;
     public get bugly(): BuglySDK {
-        if(!this._bugly) this._bugly = new BuglySDK();
-        return this._bugly;
+        return this._bugly || (this._bugly = new BuglySDK());
     }
 
 
     /** 系统管理 */
     private _data: DataSystem;
     public get data(): DataSystem {
-        if(!this._data) this._data = new DataSystem();
-        return this._data;
+        return this._data || (this._data = new DataSystem());
     }
     private _ad: AdSystem;
     public get ad(): AdSystem {
-        if(!this._ad) this._ad = new AdSystem(ATSDKMgr.getInstance());
-        return this._ad;
+        return this._ad || (this._ad = new AdSystem(ATSDKMgr.getInstance()));
     }
     private _jsb: JsbSystem;
     public get jsb(): JsbSystem {
-        if(!this._jsb) this._jsb = new JsbSystem();
-        return this._jsb;
+        return this._jsb || (this._jsb = new JsbSystem());
     }
     private _http: HttpSystem;
     public get http(): HttpSystem {
-        if(!this._http) this._http = new HttpSystem();
-        return this._http;
+        return this._http || (this._http = new HttpSystem());
     }
     private _audio: AudioSystem;
     public get audio(): AudioSystem {
-        if(!this._audio) this._audio = new AudioSystem();
-        return this._audio;
+        return this._audio || (this._audio = new AudioSystem());
     }
     private _timer: TimerSystem;
     public get timer(): TimerSystem {
-        if(!this._timer) this._timer = new TimerSystem();
-        return this._timer;
+        return this._timer || (this._timer = new TimerSystem());
     }
     private _event: EventSystem;
     public get event(): EventSystem {
-        if(!this._event) this._event = new EventSystem();
-        return this._event;
+        return this._event || (this._event = new EventSystem());
     }
     private _pool: PoolSystem;
     public get pool(): PoolSystem {
-        if(!this._pool) this._pool = new PoolSystem();
-        return this._pool;
+        return this._pool || (this._pool = new PoolSystem());
     }
 
     /** 挂载在MainScene的界面上,不需要new */

+ 10 - 8
assets/script/mk/system/TipSystem.ts

@@ -18,10 +18,10 @@ export default class TipSystem extends cc.Component {
     tar_y: number = 100;
     @property({ type: cc.Integer, displayName: "背景透明度" })
     bg_opacity: number = 40;
-    @property({ type: cc.Color, displayName: "背景颜色" })
-    bg_color: cc.Color = new cc.Color(200, 200, 200);
-    @property({ type: cc.Color, displayName: "文本颜色" })
-    tip_color: cc.Color = new cc.Color(255, 255, 255);
+    @property({ displayName: "背景颜色" })
+    bg_color = new cc.Color(200, 200, 200);
+    @property({ displayName: "文本颜色" })
+    tip_color = new cc.Color(255, 255, 255);
     @property({ type: cc.Integer, displayName: "文本字体" })
     tip_size: number = 40;
 
@@ -38,10 +38,12 @@ export default class TipSystem extends cc.Component {
 
     public async pop(str: string) {
         let node = await mk.pool.getPrefab("game/prefab/tips");
-        let bg = node.getChildByName("bg");
-        let lbl = node.getChildByName("lbl");
-        bg.getComponent(cc.Sprite)
-        console.log(node);
+        let node_bg = node.getChildByName("bg");
+        let node_lbl = node.getChildByName("lbl");
+        let bg = node_bg.getComponent(cc.Sprite);
+        let lbl = node_lbl.getComponent(cc.Label);
+        node_bg.opacity = this.bg_opacity;
+        // node_bg.color = 
     }