我必须在Greenfoot
. 这部分意味着我必须保存位置Chess
然后单击重置。
然后,我必须选择加载将棋子放回重置前的位置。
由于我不知道数组的确切大小,我知道我可以使用List
但在作业中是不允许的。
屏幕上没有显示任何内容,但没有错误消息。
假设我有一个名为Chess
.
static Actor[] allChess;
public void save() // this is the save
{
Actor[] allChess = GWorld.getAllObjects("Chess");
}
public void load() // this is the load
{
if (allChess != null)
{
for (int i=0; i < allChess.length; i++)
{
Chess ch = (Chess) allChess[i];
GWorld.addOneObject(new Chess(ch.color, ch.rank), ch.getX(), ch.getY());
}
}
}
非常感谢!