我正在使用Java libgdx在俄罗斯方块克隆上工作,但我陷入了困境,如何使用矩形宽度40,每个框的高度40继承所有我的代码
public ArrayList<DownBlocks> getBlocks() {
return blocks;
}
public ArrayList<DownBlocks> getDones() {
return dones;
}
private ArrayList<DownBlocks> blocks;
private ArrayList<DownBlocks> dones;
@Override
public void show() {
blocks=new ArrayList<DownBlocks>();
dones=new ArrayList<DownBlocks>();
create();
}
@Override
public void render(float delta) {
if (stop||!stopdown){
t=t+1;
if (t>40){create();t=0;}
outer: for(int i = 0; i < blocks.size(); ++i)
{
for(int j = 0; j < getDones().size(); ++j)
{
if(blocks.get(i).y == getDones().get(j).y + 40&&
blocks.get(i).x == getDones().get(j).x)
{
continue outer;
}else stop=false;
}
}
}
public void create(){
getDones().addAll(getBlocks());
getBlocks().clear();
blocks.add(new DownBlocks(game, this, 240, 680, 40, 40,n,1));
blocks.add(new DownBlocks(game, this, 200, 640, 40, 40,n,2));
blocks.add(new DownBlocks(game, this, 200, 680, 40, 40,n,3));}
DownBlocks评估:
public DownBlocks(MyGdxGame game, Gamescreen gamescreen, int x, int y, int width, int hight,int s,int local) {
texture=new Texture("badlogic.jpg");
this.y=y;
this.s=s;
this.local=local;
this.x=x;
this.width=width;
this.height=hight;
this.game=game;
this.gamescreen=gamescreen;
rotate=true;
}
public void render(){
game.batch.begin();
game.batch.draw(texture,x, y,width,height);
game.batch.end();
f=f+1;
if (y<=0){stopdown=false;}
else if (y>0){stopdown=true;}
if (f >= 40) {
if (y>0&&!gamescreen.stop&&gamescreen.stopdown){
y = y - 40;f=0;}
}
}}
我已经尝试过为Dones Array的每个对象使用for循环,但是我无法想象for循环