Hi everyone, I'm new to forum and I searched a lot before asking here.
I have this situation: a chessboard with two groups of sprites, the 16 Whites and the 16 Blacks. The aim of this chessboard is only putting the pieces on the board and study the moves, freely moving the pieces on the board without constraints for the actual permitted movement of each pieces (like in the real chessboard when you don't know the rules you can move every piece wherever you want, ignoring for instance that the Pown can move only one cell at once). So it's quite easy, I managed to set Touch Down, Touch up and Drag for every Sprite and also they perfectly snap to the grid so all is fine but... of course I would like that a captured piece could automatically go in the side area. The desired behaviour would be:
for each black sprite, when it takes the place of a white one, that white sprite will go to the side area and viceversa. I can't use the collide function because when you drag a pieces you certainly will touch all the sprites in your path. So I obtained this desired behaviour coding each of the 32 sprites capturing each of the 16 opponents (when the black rock touch up, if its coordinates are equal to the white bishop, then the black rock snap to the position and the white bishop goes to the side area and so on for each sprite).
What I ask you is: is there a way to change my code in DRY (don't repeat yourself)? thank you!!!!
Romina from Italy