Commit e704987b authored by wildfirecode's avatar wildfirecode

1

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