Right, I have a collision detection program where it checks for colision with any label on a Panel. It works great but I need to know if there's a way to find what label it collided with and get the name of it. Please help.
Printable View
Right, I have a collision detection program where it checks for colision with any label on a Panel. It works great but I need to know if there's a way to find what label it collided with and get the name of it. Please help.
Can you post the collision detection code?
This is inside a timer that moves my bullet up. It checks for collision on every movement of the bullet.Code:For Each label In Panel1.Controls
If GetType(Label).ToString = "System.Windows.Forms.Label" Then
CheckOverlap(label) ' a function elsewhere to check for collision
End If
See I need to find *which* label it hit inside the if statement.Code:Function CheckOverlap(ByVal label)
Laser.Left = PictureBox1.Left
Laser.Right = PictureBox1.Left + PictureBox1.Width
Laser.Top = PictureBox1.Top
Laser.Bottom = PictureBox1.Height + PictureBox1.Top
AlienShip.Left = label.Left
AlienShip.Right = label.Left + label.Width
AlienShip.Top = label.Top
AlienShip.Bottom = label.Height + label.Top
If Laser.Right >= AlienShip.Left And Laser.Left <= AlienShip.Right And Laser.Bottom = AlienShip.Top - 5 Or Laser.Top = AlienShip.Bottom - 5 And Laser.Right >= AlienShip.Left And Laser.Left <= AlienShip.Right Then
Laser.Top = Laser.Top - 1
LaserFired = 0
End If
End Function
Sorry, but all I can do is move you to the right forum.
Bump.