//以下是form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
Class1 c1 = new Class1();
PictureBox[] mypic = new PictureBox[3];
public Form1()
{
InitializeComponent();
}
public void update_image()
{
mypic = new PictureBox[3];
mypic[c1.i] = new System.Windows.Forms.PictureBox();
mypic[c1.i].Location = new Point(c1.i*34);
this.Controls.Add(mypic[c1.i]);
mypic[c1.i].Width = c1.Cd;
mypic[c1.i].Height = c1.Cd;
c1.one();
mypic[c1.i].Image = Image.FromFile("img0.png");
c1.two(); mypic[c1.i].Image = Image.FromFile("img1.png");
c1.three(); mypic[c1.i].Image = Image.FromFile("img2.png");
} private void Form1_Load(object sender, EventArgs e)
{
c1.circulate();
update_image();
}
}
}//以下是class1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace WindowsFormsApplication6
{
class Class1
{
public int[] maps = {1,2,3};
public int i;
public int Cd = 36;
public void circulate()
{
for (i=0; i < 2;i++ )
{
}
}
public void one()
{
circulate();
if(maps[i]==1)
{
}
}
public void two()
{
circulate();
if(maps[i]==2)
{
}
}
public void three()
{
circulate();
if(maps[i]==3)
{
}
}
}
}这样运行出来的窗口只是显示img2.png,其余的两图片不显示,是我的循环有问题吧??请帮我以下,本人初学,在做一个推箱子程序,这是从简单开始写的,如有帮助,万分感谢~~~么么
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
Class1 c1 = new Class1();
PictureBox[] mypic = new PictureBox[3];
public Form1()
{
InitializeComponent();
}
public void update_image()
{
mypic = new PictureBox[3];
mypic[c1.i] = new System.Windows.Forms.PictureBox();
mypic[c1.i].Location = new Point(c1.i*34);
this.Controls.Add(mypic[c1.i]);
mypic[c1.i].Width = c1.Cd;
mypic[c1.i].Height = c1.Cd;
c1.one();
mypic[c1.i].Image = Image.FromFile("img0.png");
c1.two(); mypic[c1.i].Image = Image.FromFile("img1.png");
c1.three(); mypic[c1.i].Image = Image.FromFile("img2.png");
} private void Form1_Load(object sender, EventArgs e)
{
c1.circulate();
update_image();
}
}
}//以下是class1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace WindowsFormsApplication6
{
class Class1
{
public int[] maps = {1,2,3};
public int i;
public int Cd = 36;
public void circulate()
{
for (i=0; i < 2;i++ )
{
}
}
public void one()
{
circulate();
if(maps[i]==1)
{
}
}
public void two()
{
circulate();
if(maps[i]==2)
{
}
}
public void three()
{
circulate();
if(maps[i]==3)
{
}
}
}
}这样运行出来的窗口只是显示img2.png,其余的两图片不显示,是我的循环有问题吧??请帮我以下,本人初学,在做一个推箱子程序,这是从简单开始写的,如有帮助,万分感谢~~~么么
public void circulate()
{
for (i=0; i < 2;i++ )
{
}
} 像这样的,然后再另一个类中引用,这样封装对么?
i值错误??