Hey leute,
ich habe in einem projekt eine Textur mit einem Array 4mal gezeichenet.
nun will ich das wenn eine kollision statt findet die Texture welche kollidiert ist nicht mehr gezeichnet wird. Das problem bei mir ist das bei der Kollision dann alle 4 Texturen verschwinden.
meine Frage wäre wie man nur die Texture welche kollidiert ist verschwinden lässt.
Es muss sich nicht unbedingt auf mein code beziehen.
Hier sind ei Paar teile vom code: (sind vielleicht sehr unklar da ich nurdas wichtige genommen habe. hoffe das reicht)
ich habe in einem projekt eine Textur mit einem Array 4mal gezeichenet.
nun will ich das wenn eine kollision statt findet die Texture welche kollidiert ist nicht mehr gezeichnet wird. Das problem bei mir ist das bei der Kollision dann alle 4 Texturen verschwinden.
meine Frage wäre wie man nur die Texture welche kollidiert ist verschwinden lässt.
Es muss sich nicht unbedingt auf mein code beziehen.
Hier sind ei Paar teile vom code: (sind vielleicht sehr unklar da ich nurdas wichtige genommen habe. hoffe das reicht)
Code:
Texture cup; // die Texturen
int numberOfCup = 4;
float[] cup_PositionX = new float[numberOfCup];
float[] cup_PositionY = new float[numberOfCup];
float DistanceBetweenCup = Gdx.graphics.getWidth() / 2;
//Position der Bäume
public void create_Cups() {
for (int i = 0; i < numberOfCup; i++) {
cup_PositionX[i] = Gdx.graphics.getWidth() - cup.getWidth() / 2 + Gdx.graphics.getWidth() / 8 + i * DistanceBetweenCup;
cup_PositionY[i] = (float) (randomCup_Position.nextFloat() * Gdx.graphics.getWidth() / 1.1);
}
//bewegung der Becher
for (int i = 0; i < numberOfCup; i++) {
if (cup_PositionX[i] < -Gdx.graphics.getWidth()) {
if (durchläufe < 99) {
cup_PositionY[i] = (float) (randomCup_Position.nextFloat() * Gdx.graphics.getHeight() / 1.1);
cup_PositionX[i] += numberOfCup * DistanceBetweenCup;
if (cup_PositionY[i] > Gdx.graphics.getHeight() - cup.getHeight() / 2) {
cup_PositionY[i] = Gdx.graphics.getHeight() - cup.getHeight() / 2;
}
} else {
cup_PositionX[i] = -2000;
}
} else {
cup_PositionX[i] -= wall_Velocity;
}
batch.draw(cup, cup_PositionX[i], cup_PositionY[i], cup.getWidth() / 2, cup.getHeight() / 2);
}
//Kollision von becher und ball
for (int i = 0; i < numberOfCup; i++) {
becherKollision[i] = new Rectangle(cup_PositionX[i] + cup.getWidth() / 8, cup_PositionY[i], cup.getWidth() / 4, cup.getHeight() / 2);
//shapeRenderer.rect(cup_PositionX[i] + cup.getWidth() / 8, cup_PositionY[i], cup.getWidth() / 4, cup.getHeight() / 2);
// pongCircle.set(Spiel_ballX + Spiel_ball.getWidth() / 8, Spiel_ballY + Spiel_ball.getHeight() / 8, Spiel_ball.getWidth() / 8);
if (Intersector.overlaps(pongCircle, becherKollision[i]) && rend > saveRend + cup.getHeight() / 10) {
cup_Counter++;
saveRend = rend;
Gdx.app.log("punkte", String.valueOf(cup_Counter));
collision = true;
}
}