Click here to Skip to main content
15,882,464 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi gays
how do I get the collision event of two buttons in the form
for create simple game in c#

What I have tried:

Updated 17-Nov-23 8:10am

Assuming you don't rotate, the buttons represent "rectangles" (top, left, width, height) you can test for "intersection"; i.e. a collision while moving.

Rectangle.IntersectsWith(Rectangle) Method (System.Drawing) | Microsoft Learn[^]
Share this answer
Maciej Los 20-Nov-23 12:32pm    
Here is the great step-by-step guide regarding collision of objects using C#
An Ultimate Guide To Build C# Game Programming | Simplilearn[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900