My first usage of them is in the [icode]Display[/icode] class, creating callbacks for GLFW.
glfwSetWindowPosCallback(window, winPosCallback = GLFWWindowPosCallback((win, xPos, yPos) ->
{
Display.posX = xPos;
Display.posY = yPos;
}));
glfwSetCursorPosCallback(window, winCurPosCallback = GLFWCursorPosCallback(Mouse::glfwCursorCallback));
glfwSetScrollCallback(window, winScrollCallback = GLFWScrollCallback(Mouse::glfwScrollCallback));
glfwSetMouseButtonCallback(window, winMouseButtonCallback = GLFWMouseButtonCallback(Mouse::glfwMouseButtonCallback));
This makes code simpler, and also easy to read, because I hate writing anonymous classes and overriding the methods. When the methods we have to override is only one, it makes sense to reduce the amount of code we type and use this lambdas and method references.
The next major usage of method references are in the usage of [icode]GameTimer[/icode] class, but still, in the form of callbacks.
GameTimer timer = new GameTimer(10, TimeUtils.Unit.SECONDS);
timer.setCallback(this::timerOut);
timer.start();
There are also the [icode]Animation[/icode], and the entity classes which makes use of lambdas. Whatever you think of this, but Iâm lovinâ it!!