0

I have two pictureboxes, one of which can be controlled by the player of the game with the arrowkeys. However, I have encountered an issue when the player picturebox moves past another picturebox on the form.

Before walking in front

enter image description here

Whilst walking past

enter image description here

I would like the player box to pass in front of the burger, with the burger remaining visible behind the player (as you would expect)

Thanks.

001
  • 13,291
  • 5
  • 35
  • 66
  • 1
    You can set the background color of the picture box to transparent and make the picture have a transparent background. – Sweeper Feb 21 '18 at 18:58
  • Addition to @Sweeper comment. I think what you're looking for is AllowsTransparency="True" Background="Transparent" – Mindaugas Nakrošis Feb 21 '18 at 19:00
  • __No__ transparency support for __overlapping__ controls. Better draw the images in a Paint event! – TaW Feb 21 '18 at 21:15

2 Answers2

0

That looks like game development, so my usual Disclaimer first: Windows Form is not the right way to do game development.

Stuff like simple Turnbased games with single or Hotseat Multiplayer is doable. Think of Solitaire as the upper bound of possibility. But for anything beyond that, you really should be looking into the proper way.

For the .NET Framework the XNA Framework is designated for game programming. But I think we are supposed to use the .NET Core for anything new. Wich has 3 ways of Programming games.

As for fixing your issue without a complete rewrite: Windows Forms does have some support for Transparency. But that one needs some knowledge of the drawing code and has cases when it does not work properly. As i said, Windows Forms was not designed for Game Development. Or even in a time when transparency was a commong "thing" when making Desktop applications. WPF has much better support for Transparency here, but even it is not the ideal tool for games. Mid to longterm you will not get around using a proper way or live with a lot of things you take for granted.

Christopher
  • 9,634
  • 2
  • 17
  • 31
  • Thanks for the reply - a lot of useful info there I've taken in. Unfortunately this particular project is for a school assignment and I have no choice but to use Windows Form :( Thanks again for the reply – bconnor Feb 21 '18 at 19:28
0

You could make your image have an alpha background

alpha meaning transparent or clear background there is a free software called gimp thats good

Heres a video https://youtu.be/xLSoF3dhrEY