即时通讯做投币机游戏,其一个简单的,基本上它会滚在picurebox图像分成一个随机图像。使用此代码投币机游戏C#图像值
PictureBox[] PictureboxArray = new PictureBox[5];
5个picureboxes使用这行代码
PictureboxArray[0] = pbxK;
PictureboxArray[1] = pbxQueen;
PictureboxArray[2] = pbxKing;
PictureboxArray[3] = pbxJoker;
PictureboxArray[4] = pbxAce;
图像被赋予类似的
Image[] Rollimage = new Image[5];
Rollimage[0] = Properties.Resources.K;
Rollimage[1] = Properties.Resources.Queen;
Rollimage[2] = Properties.Resources.King;
Rollimage[3] = Properties.Resources.Joker;
Rollimage[4] = Properties.Resources.Ace;
和图片框的INTIAL图像分配被分配像
pbxK.Image = Rollimage[0];
pbxQueen.Image = Rollimage[1];
pbxKing.Image = Rollimage[2];
pbxJoker.Image = Rollimage[3];
pbxAce.Image = Rollimage[4];
用于图像滚动的实际代码如下
for (int i = 0; i <= 4; i++)
{
if (PictureboxArray[i].Enabled == true)
{
Roll[i] = Rnd.Next(0, 4);
}
PictureboxImage(PictureboxArray[i], Roll[i]);
}
RND是一个新的随机
Random Rnd = new Random();
辊在一个int用于保存辊
int[] Roll = new int[5];
一切的索引工作正常,图片滚动不同图像的每一秒时间,因为我预定义了,现在是什么即时试图做的是转让本
int[] PictureValues = new int[]{100, 225, 550, 775, 1000};
到图像
Image[] Rollimage = new Image[5];
这意味着其是Properties.Resources.K;
具有100 实际值等,第一辊图像是有办法做到这一点?
你只是想改变他们被访问的名字吗? – Jacobr365
有点困惑问题是什么。您想要将值与数组中的每个索引关联,并且您有一个包含值的并行数组。所以..对于'RollImage [i]'你有'PictureValues [i]'的值你是否真的想把值赋给图像对象,这样你就没有两个独立的数组了? –
我试图简单地做的是,在图像停止滚动后,程序检查图片框中的图像,然后检查该图像的值,然后将其添加到总的EG,如果它是'Rollimage [0] = Properties.Resource .K'然后它的值为100从'int [] PictureValues = new int [] {100,225,550,775,1000};' – ZainHikary