Commit 69ed4eda authored by wildfirecode's avatar wildfirecode

1

parent 8ccbd567
......@@ -115,16 +115,26 @@ export default class MainBase extends eui.UILayer {
}
}
_firstBgLoaded = false;
loadFirstScreen() {
this.loadFirstBG((bitmap: egret.Bitmap) => {
const t = Date.now() - window['__startTime__'];
console.log(`首屏显示时间:${t}ms`);
layers.addFirstBackground(bitmap);
this._firstBgLoaded = true;
this.check();
});
}
loadFirstBG(callback) {
const onImageLoaded = (e: egret.Event) => {
const imageLoader: egret.ImageLoader = e.currentTarget;
const bitmapData: egret.BitmapData = imageLoader.data;
const texture = new egret.Texture();
texture._setBitmapData(bitmapData);
const bitmap = new egret.Bitmap(texture);
layers.addFirstBackground(bitmap);
callback(bitmap);
}
const imageLoader = new egret.ImageLoader();
imageLoader.once(egret.Event.COMPLETE, onImageLoaded, this);
const url = getResPath() + "resource/assets/startScene/bg.jpg"
......@@ -158,13 +168,25 @@ export default class MainBase extends eui.UILayer {
})
}
/**
* 创建场景界面
* Create scene interface
*/
_startSceneReady = false;
protected createGameScene() {
SceneCtrl.instance.change(ModuleTypes.START_SCENE, null, () => {
this._startSceneReady = true;
this.check();
});
}
check() {
if (this._startSceneReady && this._firstBgLoaded) {
layers.removeFirstBackground();
SceneCtrl.instance.change(ModuleTypes.START_SCENE);
const t = Date.now() - window['__startTime__'];
console.log(`start scene显示时间:${t}ms`);
//开始场景图集和开始场景背景全部加载完成并显示
}
}
}
\ No newline at end of file
......@@ -14,21 +14,21 @@ export default class SceneCtrl {
this._parent = parent;
}
change(type: ModuleTypes, data?) {
change(type: ModuleTypes, data?, onComplete?: Function) {
const cls = this._sceneClassMap[type];
const scene: Scene = new cls();
if (!window['development']) {
Loading.instace.show();
RES.getResByUrl(`${scene.skinKey.toLowerCase()}_json`, (sheet: egret.SpriteSheet) => {
Loading.instace.hide();
this.showAfterLoadAtlas(scene, data);
this.showAfterLoadAtlas(scene, data, onComplete);
}, this, RES.ResourceItem.TYPE_SHEET);
} else {
this.showAfterLoadAtlas(scene, data);
this.showAfterLoadAtlas(scene, data, onComplete);
}
}
showAfterLoadAtlas(scene: Scene, data) {
showAfterLoadAtlas(scene: Scene, data, onComplete: Function) {
if (this._currentScene) {
this._currentScene.destroy();
this._parent.removeChild(this._currentScene);
......@@ -36,6 +36,7 @@ export default class SceneCtrl {
scene.loadSkin();
scene.start();
this.addToStage(scene);
onComplete && onComplete();
}
addMask() {
......
......@@ -15,16 +15,21 @@ class Layers extends eui.UILayer {
this.addChild(this._topLayer);
}
_removeTag: number;
_bg: egret.Bitmap;
addFirstBackground(bitmap: egret.Bitmap): any {
if (!this._removeTag) {
this._bg = bitmap;
this._bottomLayer.addChild(bitmap);
}
}
removeFirstBackground(): any {
// if (this._bg)
// this._bottomLayer.removeChild(this._bg);
// this._bg = null;
this._removeTag = 1;
if (this._bg) {
this._bottomLayer.removeChild(this._bg);
this._bg = null;
}
}
get topLayer() { return this._topLayer }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment