我需要知道所有数组类的变量移动是否为真
public boolean move,move2;
public ArrayList<DownBlocks> getBlocks() {
return blocks;
}
public ArrayList<DownBlocks> getDones() {
return dones;
}
@Override
public void render(float delta) {
for (DownBlocks downBlocks:getBlocks()){
if (!downBlocks.move){move=false;} }
如果move
中的任何一个为假,则此代码可以使downblocks.moves
为假,但当它们都不为假时,我想使它为真
答案 0 :(得分:1)
使用此设置:
move = downBlocks.move && downBlocks.move1 && downBlocks.move2;
move
仅在所有downBlocks.move???
为真时才为真,否则为假。
答案 1 :(得分:1)
您可以尝试以下方法:
move = downblocks.moves1 && downblocks.moves2 && ... && downblocks.movesN;
答案 2 :(得分:1)
尝试一下:
move = true;
for (DownBlocks downBlocks:getBlocks()){
move = (move && downBlocks.move)
if (!move) {break};
}