Commit e704987b authored by wildfirecode's avatar wildfirecode

1

parent 5b1928a3
...@@ -80,6 +80,7 @@ export default class MainBase extends eui.UILayer { ...@@ -80,6 +80,7 @@ export default class MainBase extends eui.UILayer {
this.registerModules(); this.registerModules();
this.getData(); this.getData();
RES.setMaxLoadingThread(10);
this.runGame().catch(e => { this.runGame().catch(e => {
console.log(e); console.log(e);
}) })
......
...@@ -29,6 +29,8 @@ export default class SheetAnimation extends egret.Bitmap { ...@@ -29,6 +29,8 @@ export default class SheetAnimation extends egret.Bitmap {
this.totalFrames = this.getTotalFrames() - 1; this.totalFrames = this.getTotalFrames() - 1;
} }
get sheet(){return this._sheet}
private getTotalFrames() { private getTotalFrames() {
let counter = 0; let counter = 0;
for (const key in this._sheet._textureMap) { for (const key in this._sheet._textureMap) {
......
...@@ -85,6 +85,23 @@ export default class Box extends egret.Sprite { ...@@ -85,6 +85,23 @@ export default class Box extends egret.Sprite {
}); });
} }
async createFirstBg() {
let url = this.boxData.skin;
return new Promise((resolve) => {
RES.getResByUrl(url, (sheet: egret.SpriteSheet) => {
this._pic.sheet = sheet;
this._pic.fps = 10;
this.x = this.START_X;
this.y = this.START_Y
this.scaleX = this.scaleY = this.START_SCALE;
this.move();
this.anchorOffsetX = this.boxData.offset[0];
this.anchorOffsetY = this.boxData.offset[1];
resolve(this);
}, this, RES.ResourceItem.TYPE_SHEET);
});
}
private _vyStart = 25; private _vyStart = 25;
private _vy: number; private _vy: number;
private _gy: number; private _gy: number;
......
import Box from "./Box"; import Box from "./Box";
import { getBoxKeyList } from "./data/getBoxKeyList"; import { getBoxKeyList } from "./data/getBoxKeyList";
export default class BoxListCtrl { export default class BoxListCtrl extends egret.EventDispatcher {
private _parent: egret.Sprite; private _parent: egret.Sprite;
private _boxKeys: string[]; private _boxKeys: string[];
private _boxs: Box[]; private _boxs: Box[];
private _boxSpeed: number; private _boxSpeed: number;
constructor(parent: egret.Sprite) { constructor(parent: egret.Sprite) {
super();
this._parent = parent; this._parent = parent;
this._boxs = []; this._boxs = [];
this.init(); this.init();
...@@ -75,8 +76,9 @@ export default class BoxListCtrl { ...@@ -75,8 +76,9 @@ export default class BoxListCtrl {
box.addEventListener('onDisappear', this.onDisappear, this); box.addEventListener('onDisappear', this.onDisappear, this);
this._boxs.push(box); this._boxs.push(box);
this._parent.addChild(box); this._parent.addChild(box);
await box.createBg();
this._currentBoxIndex++; this._currentBoxIndex++;
await box.createFirstBg();
this.dispatchEvent(new egret.Event(egret.Event.COMPLETE));
resolve(); resolve();
}) })
} }
......
import StartScene from "./StartScene"; import StartScene from "./StartScene";
import Monkey from "./Monkey"; import Monkey from "./Monkey";
export default class GuideCtrl { export default class GuideCtrl extends egret.EventDispatcher {
private _main: StartScene; private _main: StartScene;
private _tag: boolean; private _tag: boolean;
private _guideTop: egret.Sprite; private _guideTop: egret.Sprite;
constructor(view: StartScene) { constructor(view: StartScene) {
super();
this._main = view; this._main = view;
this.init(); this.init();
}
start() {
if (this._tag) { if (this._tag) {
this._main.guideView.destroy(); this._main.guideView.destroy();
this._main.addTouchEvent(); this._main.addTouchEvent();
} else { this.doComplete();
this.start(); }
else {
this.startGuide();
} }
} }
start(): any { private startGuide() {
this._guideTop = new egret.Sprite();
this._main.topLay.addChild(this._guideTop);
this._main.monkey.once('onStartShaking', this.onMonkeyStartShaking, this); this._main.monkey.once('onStartShaking', this.onMonkeyStartShaking, this);
this._main.boxListCtrl.boxs[0].once('onPassMiddle', this.onPassMiddle, this); this._main.boxListCtrl.boxs[0].once('onPassMiddle', this.onPassMiddle, this);
this._main.boxListCtrl.updateSpeed(__boxMoveSpeed__ * 4); this._main.boxListCtrl.updateSpeed(__boxMoveSpeed__ * 10);
} }
onPassMiddle() { onPassMiddle() {
...@@ -29,14 +37,21 @@ export default class GuideCtrl { ...@@ -29,14 +37,21 @@ export default class GuideCtrl {
tips; tips;
async addGuide() { async addGuide() {
this._guideTop = new egret.Sprite();
this._main.topLay.addChild(this._guideTop);
const hand = await RES.getResAsync('guide_hand_png'); const hand = await RES.getResAsync('guide_hand_png');
const tips = await RES.getResAsync('guide_tips_png'); const tips = await RES.getResAsync('guide_tips_png');
const guide_dialog = await RES.getResAsync('guide_dialog_png'); const guide_dialog = await RES.getResAsync('guide_dialog_png');
this.doComplete();
await this.showtipsAni(tips); await this.showtipsAni(tips);
await this.showhandAni(hand); await this.showhandAni(hand);
await this.showguideAni(guide_dialog); await this.showguideAni(guide_dialog);
}
private doComplete() {
this.dispatchEvent(new egret.Event(egret.Event.COMPLETE));
}
enableInteract() {
if (!this._tag)
this._main.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this); this._main.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
} }
...@@ -83,7 +98,6 @@ export default class GuideCtrl { ...@@ -83,7 +98,6 @@ export default class GuideCtrl {
this._main.guideView.destroy(); this._main.guideView.destroy();
egret.Tween.get(this._guideTop).to({ alpha: 0 }, 200).call(() => { egret.Tween.get(this._guideTop).to({ alpha: 0 }, 200).call(() => {
this._main.topLay.removeChild(this._guideTop); this._main.topLay.removeChild(this._guideTop);
this._guideTop = null;
}, this); }, this);
this._main.doAction(); this._main.doAction();
this._main.addTouchEvent(); this._main.addTouchEvent();
......
...@@ -24,6 +24,7 @@ export default class Monkey extends egret.Sprite { ...@@ -24,6 +24,7 @@ export default class Monkey extends egret.Sprite {
private async start() { private async start() {
await this.createBg(); await this.createBg();
this.dispatchEvent(new egret.Event(egret.Event.COMPLETE));
egret.Tween.get(this) egret.Tween.get(this)
.set({ scaleX: 0.1, scaleY: 0.1, alpha: .5, rotation: Monkey.RANGE / 3, x: 750 + 100 }) .set({ scaleX: 0.1, scaleY: 0.1, alpha: .5, rotation: Monkey.RANGE / 3, x: 750 + 100 })
.to({ y: this.targetY, x: this.targetX, scaleX: 1, scaleY: 1, alpha: 1 }, 1000, egret.Ease.getBackOut(.9)) .to({ y: this.targetY, x: this.targetX, scaleX: 1, scaleY: 1, alpha: 1 }, 1000, egret.Ease.getBackOut(.9))
......
...@@ -11,6 +11,7 @@ export default class Net extends egret.Sprite { ...@@ -11,6 +11,7 @@ export default class Net extends egret.Sprite {
} }
doAction() { doAction() {
if (!this._pic.sheet) return;
this._pic.play(); this._pic.play();
this._pic.addEventListener('frameUpdate', this.onEnterFrame, this); this._pic.addEventListener('frameUpdate', this.onEnterFrame, this);
} }
...@@ -32,6 +33,7 @@ export default class Net extends egret.Sprite { ...@@ -32,6 +33,7 @@ export default class Net extends egret.Sprite {
// setInterval(() => { // setInterval(() => {
// this.doAction() // this.doAction()
// }, 5000); // }, 5000);
this.dispatchEvent(new egret.Event(egret.Event.COMPLETE));
}, this, RES.ResourceItem.TYPE_SHEET); }, this, RES.ResourceItem.TYPE_SHEET);
} }
} }
\ No newline at end of file
...@@ -28,46 +28,60 @@ export default class StartScene extends Scene { ...@@ -28,46 +28,60 @@ export default class StartScene extends Scene {
private _guideCtrl: GuideCtrl; private _guideCtrl: GuideCtrl;
static NET_RANGE = 200; static NET_RANGE = 200;
private _debug: debug; private _debug: debug;
private _keyResCounter = 0;
async start(data?) { async start(data?) {
this.addUI(); this.initUI();
const t1 = Date.now() - __t0__; const t1 = Date.now() - __t0__; console.log(`startScene添加到stage:${t1 / 1000}s`)
console.log(`startScene添加到stage:${t1 / 1000}s`)
const picData: any = await this.getBg(); const picData: any = await this.getBg();
const pic = new egret.Bitmap(picData); const pic = new egret.Bitmap(picData);
egret.Tween.get(pic).set({ alpha: 0 }).to({ alpha: 1 }, 500); egret.Tween.get(pic).set({ alpha: 0 }).to({ alpha: 1 }, 200);
this.getLayer(LayerTypes.bg).addChild(pic); this.getLayer(LayerTypes.bg).addChild(pic);
const t2 = Date.now() - __t0__; const t2 = Date.now() - __t0__; console.log(`首屏(背景显示)时间:${t2 / 1000}s`);
console.log(`首屏(背景显示)时间:${t2 / 1000}s`);
this.getLayer(LayerTypes.ui).visible=true; this.getLayer(LayerTypes.ui).visible = true;
this._boxListCtrl = new BoxListCtrl(this.getLayer(LayerTypes.box)); this._boxListCtrl = new BoxListCtrl(this.getLayer(LayerTypes.box));
await this._boxListCtrl.createFirstBox(); await this._boxListCtrl.createFirstBox();
this._boxListCtrl.resume(); this._boxListCtrl.resume();
const t3 = Date.now() - __t0__; this.canInteract();
console.log(`关键利益点时间:${t3 / 1000}s`);
const monkey = new Monkey(); const monkey = new Monkey();
this.getLayer(LayerTypes.monkey).addChild(monkey); this.getLayer(LayerTypes.monkey).addChild(monkey);
monkey.addEventListener('pointUpdate', this.onPointUpdate, this) monkey.addEventListener('pointUpdate', this.onPointUpdate, this)
this._monkey = monkey; this._monkey = monkey;
this._keyResCounter++;
monkey.addEventListener(egret.Event.COMPLETE, this.checkKeyResource, this);
this._guideView = new Guide(this.getLayer(LayerTypes.guide)); this._guideView = new Guide(this.getLayer(LayerTypes.guide));
this._guideCtrl = new GuideCtrl(this); this._guideCtrl = new GuideCtrl(this);
this._keyResCounter++;
this._guideCtrl.addEventListener(egret.Event.COMPLETE, this.checkKeyResource, this);
this._guideCtrl.start();
this._guideCtrl.enableInteract();
const net = new Net(); const net = new Net();
this.getLayer(LayerTypes.net).addChild(net); this.getLayer(LayerTypes.net).addChild(net);
this._net = net; this._net = net;
this._keyResCounter++;
this.getLayer(LayerTypes.bg).touchEnabled = true; net.addEventListener(egret.Event.COMPLETE, this.checkKeyResource, this);
if (__debug__) { if (__debug__) {
this._debug = new debug(this.getLayer(LayerTypes.top)); this._debug = new debug(this.getLayer(LayerTypes.top));
} }
} }
canInteract() {
this.getLayer(LayerTypes.bg).touchEnabled = true;
const t = Date.now() - __t0__; console.log(`可交互时间:${t / 1000}s`);
}
checkKeyResource() {
this._keyResCounter--;
if (this._keyResCounter != 0) return;
const t = Date.now() - __t0__; console.log(`关键元素完全时间:${t / 1000}s`);
}
addTouchEvent() { addTouchEvent() {
this.getLayer(LayerTypes.bg).addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this); this.getLayer(LayerTypes.bg).addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
} }
...@@ -233,7 +247,7 @@ export default class StartScene extends Scene { ...@@ -233,7 +247,7 @@ export default class StartScene extends Scene {
}); });
} }
addUI() { initUI() {
const uiLayer = this.getLayer(LayerTypes.ui); const uiLayer = this.getLayer(LayerTypes.ui);
uiLayer.addChild(this['ruleBtn']); uiLayer.addChild(this['ruleBtn']);
uiLayer.addChild(this['optionBtn']); uiLayer.addChild(this['optionBtn']);
...@@ -241,7 +255,7 @@ export default class StartScene extends Scene { ...@@ -241,7 +255,7 @@ export default class StartScene extends Scene {
this['optionBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_optionBtn, this); this['optionBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_optionBtn, this);
uiLayer.addChild(new Tips()); uiLayer.addChild(new Tips());
uiLayer.addChild(new DeclareTextTips()); uiLayer.addChild(new DeclareTextTips());
uiLayer.visible=false; uiLayer.visible = false;
} }
onTap_ruleBtn(e: egret.Event) { onTap_ruleBtn(e: egret.Event) {
...@@ -255,6 +269,7 @@ export default class StartScene extends Scene { ...@@ -255,6 +269,7 @@ export default class StartScene extends Scene {
protected get layerKeys() { protected get layerKeys() {
return [ return [
LayerTypes.bg, LayerTypes.bg,
LayerTypes.river,
LayerTypes.kids, LayerTypes.kids,
LayerTypes.ui, LayerTypes.ui,
LayerTypes.guide, LayerTypes.guide,
......
enum LayerTypes { enum LayerTypes {
bg, kids, box, net, monkey, guide, top,ui bg, kids, box, net, monkey, guide, top,ui,river
} }
export default LayerTypes export default LayerTypes
\ No newline at end of file
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