Mouse down between two pieces of a puzzle

前端 未结 3 818
时光说笑
时光说笑 2021-01-28 18:30

I am building a puzzle game in winforms, and i want to recognize the mousedown over any piece, and move it with the mousemove. The issue is that when i touch the transparent par

3条回答
  •  日久生厌
    2021-01-28 18:51

    In general, keep a list of all your puzzle piece controls, sorted top down. When you get a mouse down event on one piece, check the transparency at that point, if it it not transparent handle the event on that piece. If it is transparent forward the event to the next piece down in your list (directly calling the event handler is probably the easiest way). Keep doing this until you either find a non transparent point, or run out of pieces.

    UPDATE Here is a link to a project showing an example of how to do this in pure GDI. https://drive.google.com/file/d/0B42fIyGTLNv3WlJwNGVRN2txTGs/edit?usp=sharing

提交回复
热议问题