code: public static void centerActor(final Actor actor, final Stage stage) {
          if (actor != null && stage != null) {
              actor.setPosition((int) (stage.getWidth() / 2f - actor.getWidth() / 2f),
                      (int) (stage.getHeight() / 2f - actor.getHeight() / 2f));
          }
      }
docs: Null-safe position update.
  
  @param actor will be centered on the given stage according to their sizes. Can be null.
  @param stage can be null.