首先,要完全理解,我向您展示了我在Unity3D中的工作:Gif
因此,我尝试使用Windows窗体在Visual Studio中使用c#.net进行重新制作。我设法产生了背景,现在我试图产生这种可以在GIF中看到的球。但是我遇到了这个问题,然后生成了图片框,背景某种程度上是灰色的,而不是透明的。 image 所以我有些东西会生成图像,因此它的眼睛,背景和轮廓。我对.net相当陌生,所以我真的不知道制作和生成(尤其是使之可拖动)的最佳方法。您有任何技巧可以使我做得更好,不仅有背景知识,请与我分享。现在的代码:
private void CreateBall()
{
balls.Add(new Ball());
Ball cBall = balls.Last();
// This makes all images to blend in one.
using (Graphics gfx = Graphics.FromImage(cBall.JoinedImage))
{
gfx.DrawImage(cBall.Flag, new Rectangle(0, 0, cBall.Flag.Width, cBall.Flag.Height));
gfx.DrawImage(cBall.Outline, new Rectangle(0, 0, cBall.Flag.Width, cBall.Flag.Height));
gfx.DrawImage(cBall.RightEye, new Rectangle((int)(cBall.Flag.Width * 0.2), (int)(cBall.Flag.Height * 0.2), (int)(cBall.Flag.Width * 0.2), (int)(cBall.Flag.Height * 0.2)));
gfx.DrawImage(cBall.LeftEye, new Rectangle((int)(cBall.Flag.Width * 0.6), (int)(cBall.Flag.Height * 0.2), (int)(cBall.Flag.Width * 0.2), (int)(cBall.Flag.Height * 0.2)));
}
PictureBox picBox = new PictureBox
{
Location = new Point(100, 100),
Size = new Size(100, 100),
TabStop = false,
SizeMode = PictureBoxSizeMode.Zoom,
BorderStyle = BorderStyle.None,
//Image = Properties.Resources.Outline_1,
Image = cBall.JoinedImage,
BackColor = Color.Transparent,
};
picBox.BackColor = Color.Transparent;
Controls.Add(picBox);
picBox.BringToFront();
}