0

I have quite literally scoured the INTERNET'S DEPTHS to try to find a solution to this problem. So here's the current scenario:

  • I have a System.Windows.Forms.PictureBox that contains my main character named Character created and placed in my form. (His images cycle through via timers set to depict him moving.)
  • I have a starting paint function that creates an object (a tree) via the following code:

public void MainFormPaint(object sender, PaintEventArgs e) { e.Graphics.DrawImage(treeImage,50,50,200,200); }

...with this as public/global object creation:

System.Drawing.Image treeImage = System.Drawing.Image.FromFile(treeImageLocation);
Graphics treeObject;

I simply need the tree to be ABOVE/zIndexed ABOVE the main character. I have the collisions setup, but I can't accomplish this for the LIFE of me.

Things I've tried:

  • Deleting the on-form "Character" and creating a new PictureBox on runtime, then layering them by using the Controls.Add function (which disturbed the image's transparency, and gave it a white background)
  • I've researched into Panels and cannot for the life of me get the transparencies to work NOR image adding/layering creation...

I don't know of a solution for this particular dilemma. To be quite honest, I don't mind if this solution has a long, complex answer.

Thank you soooo much for everybody's help!

  • The form cannot paint over any controls. Painting order is strictly back-to-front and the form is always in the back. Not using a PictureBox is the basic workaround, now it simply two DrawImage() calls. – Hans Passant Aug 25 '18 at 17:44
  • Thank you @HansPassant; however, how would I get the image transparency to work correctly? Would I have to build a panel, with each image? – EskinubisPrime Aug 25 '18 at 18:03
  • There is no good way that I can think of to not make it work correctly when you use multiple DrawImage calls. – Hans Passant Aug 25 '18 at 18:06
  • Thank you very much @HansPassant. I will try to look into calling multiple DrawImage() calls! – EskinubisPrime Aug 25 '18 at 18:10

0 Answers0