Commit b28aabbe authored by wildfirecode's avatar wildfirecode

1

parent 17c44c38
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
<style> <style>
html, html,
body { body {
-ms-touch-action: none;
background: #888888; background: #888888;
padding: 0; padding: 0;
border: 0; border: 0;
...@@ -26,7 +25,7 @@ ...@@ -26,7 +25,7 @@
<body> <body>
<div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main" data-orientation="auto" <div style="margin: auto;width: 100%;height: 100%;" class="egret-player" data-entry-class="Main" data-orientation="auto"
data-scale-mode="showAll" data-frame-rate="60" data-content-width="750" data-content-height="1624" data-scale-mode="showAll" data-frame-rate="60" data-content-width="750" data-content-height="1624"
data-multi-fingered="2" data-show-fps="false" data-show-log="false" data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9"> data-multi-fingered="2" data-show-fps="true" data-show-log="false" data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
</div> </div>
<script src="libs/modules/egret/egret.js"></script> <script src="libs/modules/egret/egret.js"></script>
...@@ -42,16 +41,17 @@ ...@@ -42,16 +41,17 @@
<!-- <script src="default.thm.js"></script> --> <!-- <script src="default.thm.js"></script> -->
<script src="output.js"></script> <script src="output.js"></script>
<script> <script>
var __t0__ = Date.now();
var __debug__ = 0; var __debug__ = 0;
var __monkeyHandSize__ = 50; var __monkeyHandSize__ = 50;
var __boxMoveSpeed__ = 1.5; var __boxMoveSpeed__ = 1.5;
var __boxmap__ = { var __boxmap__ = {
coin: { award: 0, skin: 'resource/assets/startScene/coin.png' }, coin:{ award: 0, skin: 'resource/assets/startScene/coin.json', offset: [117, 68] },
gift: { award: 0, skin: 'resource/assets/startScene/gift.png' }, gift:{ award: 0, skin: 'resource/assets/startScene/gift.json', offset: [119, 103] },
gift2: { award: 0, skin: 'resource/assets/startScene/gift2.png' }, gift2: { award: 1, skin: 'resource/assets/startScene/gift2.json', offset: [122, 87] },
woodbox: { award: 1, skin: 'resource/assets/startScene/woodbox.json', offset: [128, 79] }, //木宝箱 woodbox: { award: 1, skin: 'resource/assets/startScene/woodbox.json', offset: [115, 80] },
silverbox: { award: 3, skin: 'resource/assets/startScene/silverbox.png' },//银宝箱 silverbox: { award: 3, skin: 'resource/assets/startScene/silverbox.json', offset: [147, 77] },
goldenbox: { award: 5, skin: 'resource/assets/startScene/goldenbox.png' },//金宝箱 goldenbox: { award: 5, skin: 'resource/assets/startScene/goldenbox.json', offset: [130, 88] }
}; };
var __bgUrl__ = 'resource/assets/startScene/bg.jpg'; var __bgUrl__ = 'resource/assets/startScene/bg.jpg';
......
declare var resPath:string; declare var resPath:string;
declare var requirelogin:Function; declare var requirelogin:Function;
declare var CFG; declare var CFG;
declare var __debug__:string; declare var __debug__:number;
declare var __t0__:number;
declare interface IBoxItem { declare interface IBoxItem {
award: number; award: number;
......
...@@ -53,11 +53,11 @@ export default class MainBase extends eui.UILayer { ...@@ -53,11 +53,11 @@ export default class MainBase extends eui.UILayer {
}) })
egret.lifecycle.onPause = () => { egret.lifecycle.onPause = () => {
egret.ticker.pause(); // egret.ticker.pause();
} }
egret.lifecycle.onResume = () => { egret.lifecycle.onResume = () => {
egret.ticker.resume(); // egret.ticker.resume();
} }
//inject the custom material parser //inject the custom material parser
......
{"file":"coin.png","frames":{
"11":{"x":0,"y":0,"w":217,"h":160,"offX":12,"offY":12,"sourceW":246,"sourceH":181},
"10":{"x":219,"y":0,"w":214,"h":159,"offX":13,"offY":14,"sourceW":246,"sourceH":181},
"09":{"x":435,"y":0,"w":210,"h":156,"offX":15,"offY":16,"sourceW":246,"sourceH":181},
"08":{"x":647,"y":0,"w":207,"h":154,"offX":16,"offY":18,"sourceW":246,"sourceH":181},
"07":{"x":647,"y":156,"w":203,"h":153,"offX":18,"offY":19,"sourceW":246,"sourceH":181},
"06":{"x":435,"y":158,"w":200,"h":153,"offX":19,"offY":19,"sourceW":246,"sourceH":181},
"05":{"x":0,"y":162,"w":196,"h":155,"offX":21,"offY":18,"sourceW":246,"sourceH":181},
"04":{"x":219,"y":161,"w":193,"h":158,"offX":22,"offY":16,"sourceW":246,"sourceH":181},
"03":{"x":637,"y":311,"w":189,"h":158,"offX":24,"offY":14,"sourceW":246,"sourceH":181},
"02":{"x":828,"y":311,"w":186,"h":160,"offX":25,"offY":12,"sourceW":246,"sourceH":181},
"01":{"x":856,"y":0,"w":109,"h":161,"offX":61,"offY":11,"sourceW":246,"sourceH":181}}}
\ No newline at end of file
{"file":"gift.png","frames":{
"09":{"x":0,"y":0,"w":208,"h":205,"offX":17,"offY":24,"sourceW":237,"sourceH":239},
"08":{"x":210,"y":0,"w":205,"h":202,"offX":18,"offY":27,"sourceW":237,"sourceH":239},
"07":{"x":210,"y":204,"w":202,"h":199,"offX":19,"offY":30,"sourceW":237,"sourceH":239},
"06":{"x":0,"y":207,"w":198,"h":197,"offX":20,"offY":32,"sourceW":237,"sourceH":239},
"05":{"x":188,"y":612,"w":195,"h":197,"offX":21,"offY":31,"sourceW":237,"sourceH":239},
"04":{"x":0,"y":811,"w":192,"h":200,"offX":22,"offY":28,"sourceW":237,"sourceH":239},
"03":{"x":200,"y":405,"w":189,"h":205,"offX":23,"offY":24,"sourceW":237,"sourceH":239},
"02":{"x":0,"y":406,"w":186,"h":207,"offX":24,"offY":21,"sourceW":237,"sourceH":239},
"01":{"x":194,"y":811,"w":152,"h":209,"offX":40,"offY":20,"sourceW":237,"sourceH":239}}}
\ No newline at end of file
{"file":"gift2.png","frames":{
"11":{"x":0,"y":0,"w":225,"h":157,"offX":8,"offY":8,"sourceW":244,"sourceH":184},
"10":{"x":227,"y":0,"w":222,"h":158,"offX":10,"offY":10,"sourceW":244,"sourceH":184},
"09":{"x":451,"y":0,"w":217,"h":158,"offX":13,"offY":13,"sourceW":244,"sourceH":184},
"08":{"x":670,"y":0,"w":213,"h":158,"offX":15,"offY":16,"sourceW":244,"sourceH":184},
"07":{"x":0,"y":159,"w":209,"h":158,"offX":17,"offY":18,"sourceW":244,"sourceH":184},
"06":{"x":211,"y":160,"w":204,"h":158,"offX":20,"offY":18,"sourceW":244,"sourceH":184},
"05":{"x":417,"y":160,"w":200,"h":158,"offX":22,"offY":16,"sourceW":244,"sourceH":184},
"04":{"x":619,"y":160,"w":196,"h":158,"offX":24,"offY":13,"sourceW":244,"sourceH":184},
"03":{"x":817,"y":160,"w":191,"h":158,"offX":27,"offY":10,"sourceW":244,"sourceH":184},
"02":{"x":0,"y":319,"w":187,"h":157,"offX":29,"offY":8,"sourceW":244,"sourceH":184},
"01":{"x":189,"y":320,"w":156,"h":157,"offX":42,"offY":7,"sourceW":244,"sourceH":184}}}
\ No newline at end of file
{"file":"goldenbox.png","frames":{
"11":{"x":0,"y":0,"w":231,"h":132,"offX":14,"offY":22,"sourceW":260,"sourceH":170},
"10":{"x":233,"y":0,"w":228,"h":128,"offX":15,"offY":24,"sourceW":260,"sourceH":170},
"09":{"x":463,"y":0,"w":224,"h":127,"offX":17,"offY":26,"sourceW":260,"sourceH":170},
"08":{"x":689,"y":0,"w":221,"h":127,"offX":19,"offY":28,"sourceW":260,"sourceH":170},
"07":{"x":463,"y":129,"w":217,"h":127,"offX":21,"offY":30,"sourceW":260,"sourceH":170},
"06":{"x":682,"y":129,"w":213,"h":127,"offX":23,"offY":30,"sourceW":260,"sourceH":170},
"05":{"x":233,"y":130,"w":209,"h":127,"offX":25,"offY":28,"sourceW":260,"sourceH":170},
"04":{"x":0,"y":134,"w":206,"h":127,"offX":27,"offY":26,"sourceW":260,"sourceH":170},
"03":{"x":444,"y":258,"w":202,"h":127,"offX":29,"offY":24,"sourceW":260,"sourceH":170},
"02":{"x":648,"y":258,"w":198,"h":127,"offX":31,"offY":22,"sourceW":260,"sourceH":170},
"01":{"x":848,"y":258,"w":163,"h":126,"offX":47,"offY":21,"sourceW":260,"sourceH":170}}}
\ No newline at end of file
{"file":"silverbox.png","frames":{
"12":{"x":588,"y":266,"w":160,"h":130,"offX":67,"offY":12,"sourceW":273,"sourceH":166},
"11":{"x":0,"y":0,"w":245,"h":131,"offX":20,"offY":13,"sourceW":273,"sourceH":166},
"10":{"x":247,"y":0,"w":241,"h":131,"offX":22,"offY":15,"sourceW":273,"sourceH":166},
"09":{"x":490,"y":0,"w":237,"h":131,"offX":24,"offY":18,"sourceW":273,"sourceH":166},
"08":{"x":729,"y":0,"w":233,"h":131,"offX":26,"offY":21,"sourceW":273,"sourceH":166},
"07":{"x":0,"y":133,"w":229,"h":131,"offX":28,"offY":23,"sourceW":273,"sourceH":166},
"06":{"x":231,"y":133,"w":225,"h":131,"offX":30,"offY":23,"sourceW":273,"sourceH":166},
"05":{"x":458,"y":133,"w":221,"h":131,"offX":32,"offY":21,"sourceW":273,"sourceH":166},
"04":{"x":681,"y":133,"w":217,"h":131,"offX":34,"offY":18,"sourceW":273,"sourceH":166},
"03":{"x":0,"y":266,"w":213,"h":131,"offX":36,"offY":15,"sourceW":273,"sourceH":166},
"02":{"x":215,"y":266,"w":209,"h":131,"offX":38,"offY":13,"sourceW":273,"sourceH":166},
"01":{"x":426,"y":266,"w":160,"h":130,"offX":67,"offY":12,"sourceW":273,"sourceH":166}}}
\ No newline at end of file
{"file":"woodbox.png","frames":{ {"file":"woodbox.png","frames":{
"01":{"x":1,"y":208,"w":151,"h":206,"offX":52,"offY":11,"sourceW":236,"sourceH":224}, "11":{"x":0,"y":0,"w":211,"h":148,"offX":9,"offY":6,"sourceW":230,"sourceH":180},
"03":{"x":210,"y":204,"w":175,"h":200,"offX":30,"offY":14,"sourceW":236,"sourceH":224}, "10":{"x":213,"y":0,"w":207,"h":148,"offX":11,"offY":8,"sourceW":230,"sourceH":180},
"02":{"x":415,"y":203,"w":171,"h":205,"offX":32,"offY":12,"sourceW":236,"sourceH":224}, "09":{"x":422,"y":0,"w":202,"h":149,"offX":14,"offY":10,"sourceW":230,"sourceH":180},
"06":{"x":811,"y":1,"w":188,"h":199,"offX":23,"offY":18,"sourceW":236,"sourceH":224}, "08":{"x":626,"y":0,"w":198,"h":149,"offX":16,"offY":13,"sourceW":230,"sourceH":180},
"07":{"x":615,"y":1,"w":194,"h":198,"offX":20,"offY":17,"sourceW":236,"sourceH":224}, "07":{"x":826,"y":0,"w":194,"h":149,"offX":18,"offY":14,"sourceW":230,"sourceH":180},
"05":{"x":615,"y":201,"w":184,"h":197,"offX":25,"offY":17,"sourceW":236,"sourceH":224}, "06":{"x":0,"y":150,"w":190,"h":149,"offX":21,"offY":14,"sourceW":230,"sourceH":180},
"04":{"x":801,"y":202,"w":180,"h":200,"offX":27,"offY":15,"sourceW":236,"sourceH":224}, "05":{"x":192,"y":150,"w":186,"h":149,"offX":23,"offY":13,"sourceW":230,"sourceH":180},
"10":{"x":1,"y":1,"w":207,"h":205,"offX":13,"offY":12,"sourceW":236,"sourceH":224}, "04":{"x":380,"y":151,"w":182,"h":149,"offX":25,"offY":10,"sourceW":230,"sourceH":180},
"09":{"x":210,"y":1,"w":203,"h":201,"offX":15,"offY":14,"sourceW":236,"sourceH":224}, "03":{"x":564,"y":151,"w":177,"h":148,"offX":28,"offY":8,"sourceW":230,"sourceH":180},
"08":{"x":415,"y":1,"w":198,"h":200,"offX":18,"offY":15,"sourceW":236,"sourceH":224}}} "02":{"x":743,"y":151,"w":173,"h":148,"offX":30,"offY":6,"sourceW":230,"sourceH":180},
\ No newline at end of file "01":{"x":0,"y":301,"w":146,"h":148,"offX":44,"offY":5,"sourceW":230,"sourceH":180}}}
\ No newline at end of file
...@@ -7,8 +7,9 @@ export default class SheetAnimation extends egret.Bitmap { ...@@ -7,8 +7,9 @@ export default class SheetAnimation extends egret.Bitmap {
onEnterFrame() { onEnterFrame() {
if (this._fpscounter == 1) { if (this._fpscounter == 1) {
let key = '0' + this._counter; let key = '0' + this._counter;
if (this._counter >= this.totalFrames) if (this._counter >= 10)
key = this._counter + ''; key = this._counter + '';
const picData = this._sheet.getTexture(key); const picData = this._sheet.getTexture(key);
this.$setBitmapData(picData); this.$setBitmapData(picData);
this.dispatchEvent(new egret.Event('frameUpdate', false, false, this._counter)); this.dispatchEvent(new egret.Event('frameUpdate', false, false, this._counter));
......
...@@ -6,20 +6,28 @@ export default class Box extends egret.Sprite { ...@@ -6,20 +6,28 @@ export default class Box extends egret.Sprite {
private START_X = 395; private START_X = 395;
private START_Y = 350; private START_Y = 350;
private END_Y = 1100; private END_Y = 1100;
private MIDDLE_Y = 700; private MIDDLE_Y = 800;
speed: number;
constructor(type) { constructor(type) {
super(); super();
this._type = type; this._type = type;
this._pic = new SheetAnimation(); this._pic = new SheetAnimation();
this.addChild(this._pic); this.addChild(this._pic);
this.speed = __boxMoveSpeed__;
} }
private _passMiddleTag: boolean;
onEnterFrame() { onEnterFrame() {
this.y += __boxMoveSpeed__; this.y += this.speed;
let distance = this.y - this.START_Y; let distance = this.y - this.START_Y;
const totalDistance = (this.MIDDLE_Y - this.START_Y); const totalDistance = (this.MIDDLE_Y - this.START_Y);
if (distance > totalDistance) if (distance > totalDistance) {
distance = totalDistance; distance = totalDistance;
}
if (this.y > this.MIDDLE_Y && !this._passMiddleTag) {
this._passMiddleTag = true;
this.dispatchEvent(new egret.Event('onPassMiddle'));
}
const scale = this.START_SCALE + (1 - this.START_SCALE) * (distance / totalDistance); const scale = this.START_SCALE + (1 - this.START_SCALE) * (distance / totalDistance);
this.scaleX = this.scaleY = scale; this.scaleX = this.scaleY = scale;
if (this.y > this.END_Y && !this._onDisappear) { if (this.y > this.END_Y && !this._onDisappear) {
...@@ -29,11 +37,14 @@ export default class Box extends egret.Sprite { ...@@ -29,11 +37,14 @@ export default class Box extends egret.Sprite {
move() { move() {
this._pic.play(); this._pic.play();
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this); if (!this._isPausing)
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
} }
private _onDisappear: boolean; private _onDisappear: boolean;
disappear() { disappear() {
if (!this._onDisappear)
this.dispatchEvent(new egret.Event('onDisappear'));
this._onDisappear = true; this._onDisappear = true;
this._pic.destroy(); this._pic.destroy();
egret.Tween.get(this).to({ alpha: 0 }, 500).call(this.destroy, this); egret.Tween.get(this).to({ alpha: 0 }, 500).call(this.destroy, this);
...@@ -44,8 +55,15 @@ export default class Box extends egret.Sprite { ...@@ -44,8 +55,15 @@ export default class Box extends egret.Sprite {
this.parent.removeChild(this); this.parent.removeChild(this);
} }
stopMove() { private _isPausing: boolean;
pause() {
this._isPausing = true;
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
}
resume() {
this._isPausing = false;
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
} }
async createBg() { async createBg() {
......
import Box from "./Box"; import Box from "./Box";
import { getBoxKeyList } from "./data/getBoxKeyList";
export default class BoxListCtrl { export default class BoxListCtrl {
private _parent: egret.Sprite; private _parent: egret.Sprite;
private _boxKeys: string[]; private _boxKeys: string[];
private _boxs: Box[];
constructor(parent: egret.Sprite) { constructor(parent: egret.Sprite) {
this._parent = parent; this._parent = parent;
this._boxs = [];
this.init(); this.init();
} }
init() { init() {
this._boxKeys = ['woodbox', 'woodbox', 'woodbox']; this._boxKeys = getBoxKeyList();
} }
private BOX_CREATE_INTERVAL = 5000; private BOX_CREATE_INTERVAL = 60 * 4;
private _timer: number; private _timer: number;
private _currentBoxIndex = 0; private _currentBoxIndex = 0;
private _frameCounter = 0;
/** 创建其他的boxs */ /** 创建其他的boxs */
createBoxs() { resume() {
setInterval(() => { this._parent.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
this._boxs.forEach(box => box.resume());
}
pause() {
this._parent.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
this._boxs.forEach(box => box.pause());
}
onEnterFrame() {
this._frameCounter++;
if (this._frameCounter > this.BOX_CREATE_INTERVAL) {
this._frameCounter = 0;
this.createBox(); this.createBox();
}, this.BOX_CREATE_INTERVAL); this._currentBoxIndex++;
if (this._currentBoxIndex >= this._boxKeys.length)
this._currentBoxIndex = 0;
}
} }
createBox() { createBox() {
if (this._currentBoxIndex >= this._boxKeys.length)
this._currentBoxIndex = this._boxKeys.length - 1;
const box = new Box(this._boxKeys[this._currentBoxIndex]); const box = new Box(this._boxKeys[this._currentBoxIndex]);
box.addEventListener('onDisappear', this.onDisappear, this);
this._parent.addChild(box); this._parent.addChild(box);
box.createBg(); box.createBg();
this._boxs.push(box);
}
onDisappear(e: egret.Event) {
const currentBox = e.target as Box;
const index = this._boxs.indexOf(currentBox);
if (index != -1)
this._boxs.splice(index, 1);
} }
reset() { reset() {
...@@ -40,10 +66,14 @@ export default class BoxListCtrl { ...@@ -40,10 +66,14 @@ export default class BoxListCtrl {
createFirstBox() { createFirstBox() {
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
const box = new Box(this._boxKeys[this._currentBoxIndex]); const box = new Box(this._boxKeys[this._currentBoxIndex]);
box.addEventListener('onDisappear', this.onDisappear, this);
this._boxs.push(box);
this._parent.addChild(box); this._parent.addChild(box);
await box.createBg(); await box.createBg();
this._currentBoxIndex++; this._currentBoxIndex++;
resolve(); resolve();
}) })
} }
get boxs() { return this._boxs }
} }
\ No newline at end of file
export default class Guide extends egret.Shape {
destroy(): any {
this.parent.removeChild(this);
}
constructor(parent: egret.Sprite) {
super();
this.graphics.beginFill(0, .7);
this.graphics.drawRect(0, 0, parent.stage.stageWidth, parent.stage.stageHeight);
this.graphics.endFill();
parent.addChild(this);
}
}
\ No newline at end of file
import StartScene from "./StartScene";
import Monkey from "./Monkey";
export default class GuideCtrl {
private _main: StartScene;
private _tag: boolean;
constructor(view: StartScene) {
this._main = view;
this.init();
if (this._tag) {
this._main.guideView.destroy();
} else {
this.start();
}
}
start(): any {
this._main.monkey.once('onStartShaking', this.onMonkeyStartShaking, this);
this._main.boxList.boxs[0].once('onPassMiddle', this.onPassMiddle, this);
}
onPassMiddle() {
this._main.boxList.pause();
this._main.once(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
}
onTouch() {
// this._main.boxList.resume();
this.setTag();
this._main.guideView.destroy();
this._main.onTouch();
this._main.addTouchEvent();
}
onMonkeyStartShaking() {
this._main.monkey.stop(Monkey.RANGE / 3)
}
private init() {
this._tag = localStorage.getItem('guide') === '1';
}
setTag() {
localStorage.setItem('guide', '1');
}
}
\ No newline at end of file
...@@ -11,7 +11,7 @@ export default class Monkey extends egret.Sprite { ...@@ -11,7 +11,7 @@ export default class Monkey extends egret.Sprite {
private len; private len;
private targetY = 70; private targetY = 70;
private targetX = 369; private targetX = 369;
private static RANGE = 60; static RANGE = 60;
private _shakeSpeed = .5; private _shakeSpeed = .5;
constructor() { constructor() {
super(); super();
...@@ -27,7 +27,7 @@ export default class Monkey extends egret.Sprite { ...@@ -27,7 +27,7 @@ export default class Monkey extends egret.Sprite {
private async start() { private async start() {
await this.createBg(); await this.createBg();
egret.Tween.get(this) egret.Tween.get(this)
.set({ scaleX: 0.1, scaleY: 0.1, alpha: .5, rotation: Monkey.RANGE / 2, 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.getBackInOut(.9)) .to({ y: this.targetY, x: this.targetX, scaleX: 1, scaleY: 1, alpha: 1 }, 1000, egret.Ease.getBackInOut(.9))
.wait(500) .wait(500)
.call(this.startShaking, this); .call(this.startShaking, this);
...@@ -35,15 +35,18 @@ export default class Monkey extends egret.Sprite { ...@@ -35,15 +35,18 @@ export default class Monkey extends egret.Sprite {
startShaking() { startShaking() {
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this); this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
this.dispatchEvent(new egret.Event('onStartShaking'));
} }
stopShaking() { stopShaking() {
this.addEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this); if (this.hasEventListener(egret.Event.ENTER_FRAME))
this.removeEventListener(egret.Event.ENTER_FRAME, this.onEnterFrame, this);
} }
reset() { stop(rotation = 0) {
this.rotation = 0; this.stopShaking();
this._dir = 1; this._dir = 1;
this.rotation = rotation;
} }
private _dir = 1; private _dir = 1;
......
...@@ -29,9 +29,9 @@ export default class Net extends egret.Sprite { ...@@ -29,9 +29,9 @@ export default class Net extends egret.Sprite {
this._pic.fps = 10; this._pic.fps = 10;
this.alpha = 0; this.alpha = 0;
egret.Tween.get(this).to({ alpha: 1 }, 500); egret.Tween.get(this).to({ alpha: 1 }, 500);
setInterval(() => { // setInterval(() => {
this.doAction() // this.doAction()
}, 5000); // }, 5000);
}, this, RES.ResourceItem.TYPE_SHEET); }, this, RES.ResourceItem.TYPE_SHEET);
} }
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ import Scene from "../views/Scene"; ...@@ -3,6 +3,8 @@ import Scene from "../views/Scene";
import BoxListCtrl from "./BoxListCtrl"; import BoxListCtrl from "./BoxListCtrl";
import Monkey from "./Monkey"; import Monkey from "./Monkey";
import Net from "./Net"; import Net from "./Net";
import Guide from "./Guide";
import GuideCtrl from "./GuideCtrl";
const { TouchEvent } = egret; const { TouchEvent } = egret;
export default class StartScene extends Scene { export default class StartScene extends Scene {
...@@ -10,22 +12,37 @@ export default class StartScene extends Scene { ...@@ -10,22 +12,37 @@ export default class StartScene extends Scene {
private _monkey: Monkey; private _monkey: Monkey;
private _shape: egret.Shape; private _shape: egret.Shape;
private _boxList: BoxListCtrl; private _boxList: BoxListCtrl;
private _guideView: Guide;
private _guideCtrl: GuideCtrl;
async start(data?) { async start(data?) {
const t1 = Date.now() - __t0__;
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);
this.getLayer(LayerTypes.bg).addChild(pic); this.getLayer(LayerTypes.bg).addChild(pic);
const t2 = Date.now() - __t0__;
console.log(`首屏(背景显示)时间:${t2 / 1000}s`);
this._boxList = new BoxListCtrl(this.getLayer(LayerTypes.box)); this._boxList = new BoxListCtrl(this.getLayer(LayerTypes.box));
await this._boxList.createFirstBox(); await this._boxList.createFirstBox();
this._boxList.createBoxs();
this._boxList.resume();
const t3 = Date.now() - __t0__;
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._guideView = new Guide(this.getLayer(LayerTypes.guide));
this._guideCtrl = new GuideCtrl(this);
const net = new Net(); const net = new Net();
this.getLayer(LayerTypes.net).addChild(net); this.getLayer(LayerTypes.net).addChild(net);
this._net = net;
if (__debug__) { if (__debug__) {
...@@ -49,6 +66,18 @@ export default class StartScene extends Scene { ...@@ -49,6 +66,18 @@ export default class StartScene extends Scene {
// }, this); // }, this);
} }
addTouchEvent() {
this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
}
removeTouchEvent() {
this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onTouch, this);
}
onTouch() {
this._net.doAction();
}
onPointUpdate(e: egret.Event) { onPointUpdate(e: egret.Event) {
const point = e.data as egret.Point; const point = e.data as egret.Point;
if (__debug__) { if (__debug__) {
...@@ -62,7 +91,7 @@ export default class StartScene extends Scene { ...@@ -62,7 +91,7 @@ export default class StartScene extends Scene {
} }
} }
async getBg() { async getBg() {
let url =__bgUrl__ let url = __bgUrl__
return new Promise((resolve) => { return new Promise((resolve) => {
RES.getResByUrl(url, (picData) => { RES.getResByUrl(url, (picData) => {
resolve(picData) resolve(picData)
...@@ -71,14 +100,21 @@ export default class StartScene extends Scene { ...@@ -71,14 +100,21 @@ export default class StartScene extends Scene {
} }
protected get layerKeys() { protected get layerKeys() {
return [LayerTypes.bg, return [
LayerTypes.kids, LayerTypes.bg,
LayerTypes.net, LayerTypes.kids,
LayerTypes.box, LayerTypes.guide,
LayerTypes.monkey, LayerTypes.net,
LayerTypes.guide] LayerTypes.box,
LayerTypes.monkey,
]
} }
protected get skinKey() { return 'Start' } protected get skinKey() { return 'Start' }
get guideView() { return this._guideView }
get monkey() { return this._monkey }
get boxList() { return this._boxList }
get net() { return this._net }
} }
enum LayerTypes { enum LayerTypes {
......
export const getBoxList = () => { export const getBoxKeyList = () => {
const list = []; const list = [];
for (const key in __boxmap__) { for (const key in __boxmap__) {
if (__boxmap__.hasOwnProperty(key)) { if (__boxmap__.hasOwnProperty(key)) {
......
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