Commit 1c89e887 authored by wildfirecode's avatar wildfirecode

1

parent 86132dab
This diff is collapsed.
......@@ -46,19 +46,19 @@ function launchWithCustomModule(customModule) {
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 1000, maxScore: 200 });
engine.globalEvent.dispatchEvent('recycling-start', { time: 2, maxScore: 2 });
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 200);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('recycling-start', { time: 2 });
setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 8, maxScore: 2 });
// const d = engine.gameStage.sceneContainer.getChildAt(0);
// }, 1000 * 10);
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 1000 * 10);
});
engine.globalEvent.addEventListener('recycling-time-update', (e) => {
// console.log(e.type, e.data);
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('recycling-score-update', (e) => {
console.log(e.type, e.data);
......
......@@ -241,11 +241,10 @@
this.conveyor1 = conveyor1;
};
Conveyors.prototype.setDefault = function () {
this.clear();
this.score = 0;
this.conveyorsPool.push(this.conveyor0);
this.conveyorsPool.push(this.conveyor1);
var allConfigs = shuffle(this.GarbageConfig);
var allConfigs = shuffle(this.GarbageConfig.concat([]));
for (var i = 0; i < GarbageConfig.config.length; i++) {
allConfigs[i].idx = i;
allConfigs[i].isRight = false;
......@@ -420,16 +419,19 @@
view.y = e.stageY - target.texture.height / 2;
view.type = target['type'];
view.name = target['name'];
this.wrapper.once(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
};
Conveyors.prototype.onStageMouseMove = function (e) {
console.log('onStageMouseMove');
var view = this._currentDragView;
view.x = e.stageX - view.texture.width / 2;
view.y = e.stageY - view.texture.height / 2;
};
Conveyors.prototype.onStageMouseUp = function (e) {
var _this = this;
console.log('onStageMouseUp');
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
if (!this._currentDragView)
return;
......@@ -453,6 +455,8 @@
});
};
Conveyors.prototype.clear = function () {
this.conveyor0.x = 0;
this.conveyor1.x = 764;
this.conveyorsPool.forEach(function (i) {
i.clear();
});
......@@ -461,6 +465,11 @@
this.stores = [];
};
Conveyors.prototype.timeout = function () {
if (this._currentDragView) {
removeChild(this._currentDragView);
}
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
this.gameOver();
};
Conveyors.prototype.checkHitRect = function () {
......@@ -772,10 +781,10 @@
};
GameView.prototype.configConveyors = function () {
var conveyor0 = new Conveyor();
conveyor0.x = 0;
var conveyor1 = new Conveyor();
this.addChild(conveyor0);
this.addChild(conveyor1);
conveyor0.x = 0;
conveyor1.x = 764;
this.conveyors = new Conveyors(this);
this.conveyors.initData(conveyor0, conveyor1);
......@@ -811,6 +820,10 @@
setGuide();
_a.label = 2;
case 2:
this.conveyors.clear();
return [4, this.countdown.startCountDown()];
case 3:
_a.sent();
this.startGame();
engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(),
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -36,7 +36,6 @@ export default class Conveyors extends engine.Sprite {
}
private setDefault() {
this.clear();
this.score = 0;
......@@ -44,7 +43,7 @@ export default class Conveyors extends engine.Sprite {
this.conveyorsPool.push(this.conveyor1);
// 本局游戏的20种垃圾
const allConfigs = shuffle(this.GarbageConfig);
const allConfigs = shuffle(this.GarbageConfig.concat([]));
for (let i = 0; i < GarbageConfig.config.length; i++) {
allConfigs[i].idx = i;
......@@ -233,7 +232,7 @@ export default class Conveyors extends engine.Sprite {
private _currentDragView: engine.Sprite;
private _currentTarget: engine.Sprite;
onDown_garbage(e: engine.MouseEvent) {
if(this._currentDragView){
if (this._currentDragView) {
removeChild(this._currentDragView)
}
const target: engine.Sprite = e.target;
......@@ -246,17 +245,20 @@ export default class Conveyors extends engine.Sprite {
view.y = e.stageY - target.texture.height / 2;
view.type = target['type'];
view.name = target['name'];
this.wrapper.once(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this)
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this)
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this)
}
onStageMouseMove(e: engine.MouseEvent) {
console.log('onStageMouseMove')
const view = this._currentDragView;
view.x = e.stageX - view.texture.width / 2;
view.y = e.stageY - view.texture.height / 2;
}
onStageMouseUp(e: engine.MouseEvent) {
console.log('onStageMouseUp')
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this)
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this)
if (!this._currentDragView) return;
const result: GarbageTypes = this.checkHitRect();
......@@ -281,7 +283,9 @@ export default class Conveyors extends engine.Sprite {
});
}
private clear() {
clear() {
this.conveyor0.x = 0;
this.conveyor1.x = 764;
this.conveyorsPool.forEach(i => {
i.clear();
});
......@@ -291,6 +295,11 @@ export default class Conveyors extends engine.Sprite {
}
timeout() {
if (this._currentDragView) {
removeChild(this._currentDragView)
}
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this)
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this)
this.gameOver();
}
......
......@@ -91,11 +91,10 @@ export default class GameView extends engine.Container {
private configConveyors() {
const conveyor0 = new Conveyor();
conveyor0.x = 0;
const conveyor1 = new Conveyor();
this.addChild(conveyor0);
this.addChild(conveyor1);
conveyor0.x = 0;
conveyor1.x = 764;
this.conveyors = new Conveyors(this);
this.conveyors.initData(conveyor0, conveyor1)
......@@ -126,7 +125,9 @@ export default class GameView extends engine.Container {
setGuide();
}
// await this.countdown.startCountDown();
this.conveyors.clear()
await this.countdown.startCountDown();
this.startGame();
......
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