Hello
I’m trying to create a sliding puzzle made of 8 painted squares and 1 white.
Each time that there is a pointerdown on a painted square, it switches its position with the white square’s.
On the first pointerdown event it works but that’s it, it is not working if I tap again.
This is my code:
var pos1 = symbol.nodes.image1.position(); // This is a part of the puzzle position
var bPos = symbol.nodes.image9.position(); // this is the blank square position
symbol.nodes.image1.on(“pointerdown”, (e) => {
symbol.nodes.image2.position(bPos);
symbol.nodes.image9.position(pos1);
});
I don’t understand why it doesn’t set the new position if I tap again.
Or if there is something to do with the layermode ?
I would like to be able to switch position everytime I tap on the object.
Also, I would like to switch position only if the image is next to the blank square (like next to the left, right, top or bottom)
I think that I have to use trigger Region but I am not sure and I don’t know how.
You can have a look at the project Tintin Puzzle.zpp (363.5 KB)
If someone would have the kindness and time to help me, I would be very grateful.
Thank you very much.