Skip to content
Snippets Groups Projects
Commit 360a6c9d authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

feat: #fe clean up clue addition

parent 5cc1c6e6
Branches
Tags
No related merge requests found
...@@ -367,20 +367,7 @@ function gameStart(scene) { ...@@ -367,20 +367,7 @@ function gameStart(scene) {
function dispatchEnemy(scene) { function dispatchEnemy(scene) {
backend.post("GetImage", {}).then(function (response) { backend.post("GetImage", {}).then(function (response) {
let e = new Foe(scene, response.data); new Foe(scene, response.data);
scene.textures.addBase64(`WORD-${response.data.id}`, response.data.image);
scene.textures.once(
"addtexture",
function () {
e.run((v) => {
setTimeout(() => {
dispatchEnemy(scene);
}, Math.floor(Math.random() * 10000 + 3000));
});
},
scene,
);
}); });
} }
......
...@@ -6,9 +6,24 @@ class Foe { ...@@ -6,9 +6,24 @@ class Foe {
this.scene = scene; this.scene = scene;
this.scene.foes.push(this); this.scene.foes.push(this);
this.word = word; this.word = word;
this.addClue();
this.run();
} }
run(callback) { addClue() {
this.scene.textures.addBase64(this.word.id, this.word.image);
this.scene.textures.once(
"addtexture",
this.addClueSprite.bind(this),
this.scene,
);
}
addClueSprite() {
this.scene.add.sprite(400, 300, this.word.id);
}
run() {
let me = this; let me = this;
let randomEnemyType = enemies[Math.floor(Math.random() * 4 + 0)]; let randomEnemyType = enemies[Math.floor(Math.random() * 4 + 0)];
...@@ -19,7 +34,6 @@ class Foe { ...@@ -19,7 +34,6 @@ class Foe {
scale = 3; scale = 3;
} }
let flag = this.scene.add.sprite(400, 300, `WORD-${this.word.id}`);
let enemy = this.scene.physics.add let enemy = this.scene.physics.add
.sprite(-100, this.scene.cameras.main.height - 100, randomEnemyType) .sprite(-100, this.scene.cameras.main.height - 100, randomEnemyType)
.setScale(scale) .setScale(scale)
...@@ -60,7 +74,6 @@ class Foe { ...@@ -60,7 +74,6 @@ class Foe {
duration: 2000, duration: 2000,
onComplete: function () { onComplete: function () {
nemico.destroy(); nemico.destroy();
callback(me);
}, },
}); });
}, 3000); }, 3000);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment