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
No related branches found
No related tags found
No related merge requests found
......@@ -367,20 +367,7 @@ function gameStart(scene) {
function dispatchEnemy(scene) {
backend.post("GetImage", {}).then(function (response) {
let e = 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,
);
new Foe(scene, response.data);
});
}
......
......@@ -6,9 +6,24 @@ class Foe {
this.scene = scene;
this.scene.foes.push(this);
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 randomEnemyType = enemies[Math.floor(Math.random() * 4 + 0)];
......@@ -19,7 +34,6 @@ class Foe {
scale = 3;
}
let flag = this.scene.add.sprite(400, 300, `WORD-${this.word.id}`);
let enemy = this.scene.physics.add
.sprite(-100, this.scene.cameras.main.height - 100, randomEnemyType)
.setScale(scale)
......@@ -60,7 +74,6 @@ class Foe {
duration: 2000,
onComplete: function () {
nemico.destroy();
callback(me);
},
});
}, 3000);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment