Results 1 to 5 of 5

Thread: Help with some code please.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    26

    Question Help with some code please.

    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.

  2. #2

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    26
    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
    This is inside a timer that moves my bullet up. It checks for collision on every movement of the bullet.

    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
    See I need to find *which* label it hit inside the if statement.

  4. #4

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    26
    Bump.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width