Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Libgdx在碰撞检测后删除对象_Java_Android_Libgdx - Fatal编程技术网

Java Libgdx在碰撞检测后删除对象

Java Libgdx在碰撞检测后删除对象,java,android,libgdx,Java,Android,Libgdx,当他们和我的鸟相撞时,我想把他们移走,但我做不到,但我不知道为什么我做不到 这是我的密码: if (Intersector.overlaps(this.birdCircle, this.enemyRectangle[i]) || Intersector.overlaps(this.birdCircle, this.enemyRectangle2[i]) || Intersector.overlaps(this.birdCircle, this.enemyRectangle3[i]) || Int

当他们和我的鸟相撞时,我想把他们移走,但我做不到,但我不知道为什么我做不到

这是我的密码:

if (Intersector.overlaps(this.birdCircle, this.enemyRectangle[i]) || Intersector.overlaps(this.birdCircle, this.enemyRectangle2[i]) || Intersector.overlaps(this.birdCircle, this.enemyRectangle3[i]) || Intersector.overlaps(this.birdCircle, this.enemyRectangle4[i]) || this.gameTime == 0.0F) {
           // this.gameState = 2;
        }

我怎样才能消灭敌人。(还有
enemyRectangle[i]=altEngel
altEngel
是一种纹理,它们不在
ArrayList
中。如果要删除libgdx中的某些内容,请使用
dispose()
方法(如果要删除的内容有)。您可以在不使用
dispose()
方法的情况下将其设置为null,从而除去引用,垃圾收集器将除去它们。

Libgdx为此有一个特殊的类-
DelayedRemovalArray
它的工作原理类似于ArrayList:

DelayedRemovalArray<> array;
如果你想要详细的答案,请写更多的信息

array.removeIndex(i);