Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shohan4556/8579eaefa94f331e20f9a05b99764d2f to your computer and use it in GitHub Desktop.
Save shohan4556/8579eaefa94f331e20f9a05b99764d2f to your computer and use it in GitHub Desktop.
//box3
const box3 = this.add.container(startX / 2 - 100, 350).setDepth(20);
square = this.add.sprite(0, 0, "square").setOrigin(0.5).setScale(0.5);
number = this.add.text(40, -50, 3, { color: 0xffff });
item = this.add.image(0, 0, this.levelData[index].boxs[0]).setOrigin(0.5);
box3.add(square);
box3.add(number);
box3.add(item);
box3.setSize(128, 128);
box3.setInteractive();
box3.on(
"pointerdown",
this.checkWinLoss.bind(this, {
clicked: 3,
answer: this.levelData[index].answer,
})
);
//--------------------//
checkWinLoss(data, pointer, localX, localY) {
console.log("check win loss ", data);
}
shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment