我在编写游戏时遇到了问题。逻辑已准备就绪,即按钮随机生成 6 个点。(下图)必须使其有图像,而不是出现带有“目标”字样的按钮。按钮是通过定时器编写的,代码如下:
{
isHit = false;
btn_click.Enabled = true;
btn_click.BackColor = System.Drawing.Color.Transparent;
locationNum = rnd.Next(1, 7);
switch (locationNum)
{
case 1:
btn_click.Left = 186;
btn_click.Top = 297;
break;
case 2:
btn_click.Left = 43;
btn_click.Top = 327;
break;
case 3:
btn_click.Left = 325;
btn_click.Top = 333;
break;
case 4:
btn_click.Left = 60;
btn_click.Top = 402;
break;
case 5:
btn_click.Left = 309;
btn_click.Top = 406;
break;
case 6:
btn_click.Left = 187;
btn_click.Top = 450;
break;
default:
break;
}
}