Commit 26bf25a0 authored by 谌继荃's avatar 谌继荃

游戏道具(全屏炸弹)

parent 91210898
......@@ -42,7 +42,6 @@ export default class MovableManager extends FYGE.EventDispatcher {
this.checkHitEnemy();
this.checkHitByBullet();
this.checkHitByEnemy();
// window.addEventListener("Boom", this.checkAll);
// console.log('移动对象的数量:', this._movableList.length)
};
......@@ -68,7 +67,7 @@ export default class MovableManager extends FYGE.EventDispatcher {
private addScore() {
this.Score += 10;
console.log("this.Score", this.Score);
// console.log("this.Score", this.Score);
scoreClass.change(this.Score);
}
......@@ -90,11 +89,11 @@ export default class MovableManager extends FYGE.EventDispatcher {
// console.log("x", x);
// console.log("y", y);
if (x < 0) {
console.log("x < 0");
// console.log("x < 0");
this.hero.x = 0;
} else if (x > wW - dx) {
console.log("x > wW");
// console.log("x > wW");
this.hero.x = wW - dx;
}
......@@ -106,7 +105,7 @@ export default class MovableManager extends FYGE.EventDispatcher {
}
/**
* 鼠标点到的差值 移动要减去这个差值,不然会瞬间偏移
* 鼠标点到的差值
* @type {{x: number, y: number}}
*/
mouseDP = { x: 0, y: 0 };
......@@ -120,22 +119,20 @@ export default class MovableManager extends FYGE.EventDispatcher {
case FYGE.MouseEvent.MOUSE_DOWN:
this.mouseDP.x = e.localX - this.hero.x;
this.mouseDP.y = e.localY - this.hero.y;
console.log("MOUSE_DOWN");
console.log("mouseDP", this.mouseDP);
// console.log("MOUSE_DOWN");
// console.log("mouseDP", this.mouseDP);
break;
case FYGE.MouseEvent.MOUSE_UP:
console.log("MOUSE_UP");
// console.log("MOUSE_UP");
case FYGE.MouseEvent.MOUSE_MOVE:
console.log("MOUSE_MOVE");
// console.log("MOUSE_MOVE");
const px = e.localX - this.mouseDP.x;
const py = e.localY - this.mouseDP.y;
console.log("px", px);
console.log("py", py);
// this.hero.position.set(px, py);
// console.log("px", px);
// console.log("py", py);
this.judgeEdge();
break;
}
......@@ -175,10 +172,9 @@ export default class MovableManager extends FYGE.EventDispatcher {
}
checkAll() {
console.log(" this._movableList", this._movableList);
const enemyAllList = this._movableList.filter((i) => i instanceof Enemy);
enemyAllList.forEach((item) => {
this.remove(item);
enemyAllList.forEach((enemy) => {
this.remove(enemy);
console.log("全屏爆炸");
});
}
......@@ -231,10 +227,6 @@ export default class MovableManager extends FYGE.EventDispatcher {
return;
}
}
// setTimeout(() => {
// this.checkAll();
// }, 3000);
}
private step() {
......
......@@ -34,9 +34,14 @@ export function addGame(stage: FYGE.Stage) {
this.pause = true;
dragDropManager.remove(hero);
pause.destroy(stage);
boom.destroy(stage);
enemyFactory.destroy();
movableManager.destroy();
}
function boomAll() {
movableManager.checkAll();
}
movableManager.addEventListener("gameover", onGamOver);
stage.addEventListener("Boom", boomAll);
}
let BoomText;
export default class Boom {
private _stage: FYGE.Stage;
constructor(stage: FYGE.Stage) {
this._stage = stage;
BoomText = new FYGE.TextField();
BoomText.text = "爆炸";
BoomText.text = "全屏炸弹";
BoomText.fillColor = "#000000";
BoomText.size = 50;
BoomText.x = 50;
BoomText.x = 20;
BoomText.y = 130;
stage.addChildAt(BoomText, stage.children.length - 1);
......@@ -15,8 +17,7 @@ export default class Boom {
Boom() {
console.log("爆炸");
// 目前点击一次不能点击了
window.dispatchEvent(new Event("Boom"));
this._stage.dispatchEvent("Boom");
}
reset() {}
......
......@@ -14,7 +14,7 @@ export default class Score {
change(changeScore) {
score = changeScore;
scoreText.text = `当前分数:${score}`;
console.log("change---scoreText.text", scoreText.text);
// console.log("change---scoreText.text", scoreText.text);
}
reset() {}
......
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