Is there a way to drag the sprite between fixed locations on a canvas.
As on a chessboard how you might want to drag a pawn from c4 to c6 or if you have a bunch of stepping stones you want to move the sprite between through dragging?
Is there a way to drag the sprite between fixed locations on a canvas.
As on a chessboard how you might want to drag a pawn from c4 to c6 or if you have a bunch of stepping stones you want to move the sprite between through dragging?
So first you might want to have an list of the x and y coordinates of all your cells. Then when the user clicks on a cell, get its coordinates from the list and move it there. Otherwise, when you click on any part of a canvas, you get its x and y coordinates, which you can use to shift the sprite.
This makes sense in the context of a click style action, no?
As in, sprite is in point A I click it and then click point B it can grab the coordinates of point B and move to point B.
What if I wanted to use the drag feature e.g. I have a square with the corners A, B, C, D my sprite is at A. I can drag it towards B or C or D. Is there a way of having it realize the way you’re dragging it and then centre it on one of these corner points based on the drag?
This demo I made should get you started: