I am trying to create a sliding puzzle game and this involves swapping a puzzle piece with a blank space (in this case an invisible object) I am using extractors to determine the position of each piece then destroying them and spawning them at each others position, however they aren't spawning at the correct position. I believe this is because the extractor is giving me pixel coordinates as opposed to grid coordinates. this is making the pieces not to swap with each other but to move to different spaces. The swap is activated by clicking the blue square
There are only two pieces on the game board at the moment as I am trying to get the concept correct before finishing the board. At the moment the blank space is represented by the Red square and the puzzle piece by the blue square. The green square is a sort of control centre (my attempt to keep things neat and tidy) hopefully my code isn't difficult to understand but I'm happy to explain any questions you may have.
any help is appreciated
Game Link: https://flowlab.io/game/view/817542