Iterating through children actors - libgdx

I created a game over window when the player loses and it looks nicely.
The problem is I’m trying to disable touch in all other actors in the group except the game over window but from some reason the touch in the window is also disabled along with all the other actors.

Here is a snippet of my code:

public void spawnGameOverWindow() {
		GameOverView gameOver = new GameOverView(skinJson, this);
		addActor(gameOver);
		slideFromLeft(gameOver, new Vector2(0 - gameOver.getWidth(), Values.SCREEN_HEIGHT/2),
				new Vector2(Values.SCREEN_WIDTH/2-gameOver.getWidth()/2, Values.SCREEN_HEIGHT/2 -     gameOver.getHeight()/2),0.3f, false);
      disableTouch(gameOver);
	}
	
	public void disableTouch(Actor exception) {
		for(Actor actor : getChildren()) {
			if(!(actor == exception))
				actor.setTouchable(Touchable.disabled);
		}
	}

I debugged it a little and something is wrong with the if condition inside the for loop. I’m trying to check if actor and exception has the same reference to the same object( which is "gameOverWindow).

What’s wrong?

It appears you are only sending the gameOver actor to your disableTouch method, and if that’s the case then it wouldn’t have access to your other actors to be able to disable touch on them.

Actors are not added to other actors, so your gameOver actor would actually not have child actors. All actors are added to the stage, so you’d want to iterate through the actors that have been added to the stage. Stage has a getActors method that returns an array of all its actors, which you could iterate through.

To detect the gameOver actor you can name all of your actors with the setName method and then in your iterator loop get the name of each actor and compare it to the name of your gameOver actor.