随着新图片从面板后面出现,不断向下移动图片框

问题描述

我正在尝试使用 C# 在 Visual Studio 上编写游戏。目的是点击正确的图片(有尼莫鱼的图片),因为它们正在下降。

到目前为止,我已经设法将文件中的图像随机添加图片框。随着时间的推移,图像会更新。

但问题是直到面板结束时图像才掉落。它们会在原处更新。

Here is a link of the program

现在我正在尝试编码,图像一直下降到面板结束,并且这些图像后面必须有新的图像。

我对编码真的很陌生,所以如果你能详细而清晰地解释它会很棒。

谢谢。

这是我的代码示例:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    PictureBox[] pic = new PictureBox[4];
    Image[] img = new Image[17];
    Random ranFoto = new Random();
    
    private void Form1_Load(object sender,EventArgs e)
    {
        panel1.Paint += new PaintEventHandler(panel1_Paint);
    }

    private void timer1_Tick(object sender,EventArgs e)
    {
        for (int i = 0; i < pic.Length; i++)
        {
            pic[i].Size = new System.Drawing.Size(140,90);
            this.pic[i].BorderStyle = BorderStyle.Fixed3D;
            pic[i].Image = img[ranFoto.Next(17)];
            panel1.Controls.Add(pic[i]);
        }
    }
    
    private void panel1_Paint(object sender,PaintEventArgs e)
    {
        pic[0] = new PictureBox();
        pic[0].Location = new System.Drawing.Point(0,0);
        pic[1] = new PictureBox();
        pic[1].Location = new System.Drawing.Point(140,0);
        pic[2] = new PictureBox();
        pic[2].Location = new System.Drawing.Point(280,0);
        pic[3] = new PictureBox();
        pic[3].Location = new System.Drawing.Point(420,0);

        img[0] = Image.FromFile("C:\\Daten\\Fotos\\1.jpg");
        ....
        img[16] = Image.FromFile("C:\\Daten\\Fotos\\17.jpg");           
    }

    private void button1_Click(object sender,EventArgs e)
    {
        timer1.Enabled = true;
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)