0

I'm not sure the best way to title this question, or even ask this, but essentially, I'm building a simple flappy bird clone for a friend, and decided to use windows forms rather than Unity (which I would normally use for games) because of it's simplicity. I, however, ran into the issue of transparent backgrounds of labels not working over other controls (in this case a picturebox). Using this question, I was able to find a workaround for the issue, except that the picturebox in question is the top pipe, which moves every tick.

This code is from the aforementioned question, and how I deal with the issue currently:

if (ScoreText.Bounds.IntersectsWith(PipeTop_PictureBox.Bounds))
        {
            var pos = this.PointToScreen(ScoreText.Location);
            pos = PipeTop_PictureBox.PointToClient(pos);
            ScoreText.Parent = PipeTop_PictureBox;
            ScoreText.Location = pos;
        } else
        {
            ScoreText.Parent = this;
        }

The problem is that it produces a rather clunky result whenever the label intersects with the pipe as seen here (don't mind the sprites, I haven't made the actual ones yet, so I'm using some spare sprites I have on my computer from a previous project). I was wondering if there was any sort of fix for this, or if this is as good as it would get.

Sam
  • 295
  • 4
  • 17
  • 3
    Transparency can only work when the control (Label) is __nested__ in the other control (PBox). Moving it over the Pbox won't do. And it can't overlap any other controls. The usual advice is to do all drawing yourself without any pictureboxes except one for the canvas. – TaW Mar 16 '19 at 15:13
  • 1
    @Taw Thanks so much for the advice! I'll revise the project accordingly. – Sam Mar 16 '19 at 18:31

0 Answers0