我正在Gridworld设计一个俄罗斯方块游戏。下面是产生错误的方法。它是Block类的一种方法,它是Actors的集合,可以在其上调用move和rotate方法。
myBlocks
是BlockSections的ArrayList。
public boolean canMoveDown() {
Grid<Actor> g = myBlocks.get(0).getGrid();
for (BlockSection b : myBlocks) {
Location l = b.getLocation().getAdjacentLocation(180); // Error occurs here
System.out.print(l);
Actor bs = g.get(l);
// Checks if a section of the block is at the bottom of grid,
// and then whether, if there is a block below, if it is not
// part of the current block floating down.
if (b.getLocation().getRow() == 19 || (bs != null && myBlocks.indexOf(bs) == -1))
return false;
}
return true;
}
}
}
我尝试插入一个print语句以确保Location不为null(它不应该是,因为所有正在检查的BlockSections都在网格中)并且它确认该值不为null。但是,继续生成错误。帮助
由于