Hi,
You are implementing the movement in the piece itself and not in the scene... Both of them are different as they have different coordinate systems for example.
I mode some changes in your code to allow the movement of the pieces and to control where the piece if moved to.
You can get the code here:
http://www.qlands.com/other_files/Qt...0101112.tar.gz
I made changes in piece,tile and the boargui.
Basically I:
1. removed the events from piece and tile.
2. Added an type to piece and tile so I can cast them
3. Added mousepress and mouserelease to the boardgui
4. In those event I coded some bit so the piece can be moved and control when is taken and dropped
5. Each piece need a flag movable to true.
See that I dont use the event of drag and drop. If you want to use those events to set each piece to allow drops but is not really neccesary. You can also use the scene mousemove to check the current tile under the mouse while holding the piece and change its color to indicate that is allowed in that time.
Hope this helps!




Reply With Quote
Bookmarks