Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27081

Dynamic picturebox problem?

$
0
0
I'm making a game with pictureboxes. Basically, the idea is, I can drop food with the e button, and I dynamically create a picturebox with this code:

Code:

        Dim food As New PictureBox

        Me.Controls.Add(poop1)
        food.Width = 32
        food.Height = 32
        food.Image = My.Resources.poop
        food.Top = character.Top
        food.Left = character.Left

        food.Parent = background
        food.BackColor = Color.Transparent

        food.BringToFront()
        food.SendToBack()

Well, I want to walk over it and hit e, and make it go invisible. What I tried doing was doing this in keydown:

Code:

If e.keycode = Keys.E Then
      If food.Top = character.Top and food.Left = character.Left Then

              food.Visible = False

      End If
End If

And that doesn't work. Any ideas?

Viewing all articles
Browse latest Browse all 27081


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>