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

游戏道具(全屏炸弹)

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