点击它,我正在按一下按钮,继承我的代码:
button1.location = new Point(new Random().Next(10, 385), new Random().Next(10, 385));
Run Code Online (Sandbox Code Playgroud)
但这似乎只是在对角线上移动按钮.请帮忙.谢谢
我正在为我的游戏创建一个关卡设计师,你可以在用户控件上绘制平铺.为了跟踪瓷砖,我做了一个int []:
public int[,] Tiles = new int[35, 35];
Run Code Online (Sandbox Code Playgroud)
因为编辑屏幕是560px乘560px,35个16x16块.Tiles [x,y] .Id将给出tile的id.
Id将是图块的ID.无论何时放置瓷砖,都会在空白处记录:
public void Draw(int x, int y, int bid)
{
//draw code here
Program.form.Tiles[x, y].Id = bid;
}
Run Code Online (Sandbox Code Playgroud)
无论何时单击,都会调用void:
//In the MouseClick void:
Draw(e.X / 16, e.Y / 16, 1);
Run Code Online (Sandbox Code Playgroud)
0是可用的块ID,但例如使用1.
每当我去保存它,(我保存到.txt文件)它应该写下tile的id:
for (int x = 0; x < 35; x++)
{
for (int y = 0; y < 35; y++)
{
//Write code here
MessageBox.Show(Tiles[x, y].Id.ToString());
}
}
Run Code Online (Sandbox Code Playgroud)
我只是让它在消息框中显示Id来查看,并且它总是给出'0',即使你在某个x,y tile上编辑了一个definatley不是0的blockid.有谁知道这是为什么?谢谢.顺便说一句,在'Program'类中,在STAThread之上,我把:
public Form1 form;
Run Code Online (Sandbox Code Playgroud)
然后:
form = new …Run Code Online (Sandbox Code Playgroud)