Building a physics world from level data
Physics for levels can be hardcoded in the source code with terrible consequences for maintenance purposes, but I am sure that you have already heard about the data-driven approach that suggests a solution.
Most level editors include mechanisms to attach physics data to the final level file and one of them, Tiled, is familiar to you from Chapter 8, User Interfaces with Scene2D. It supplies a layers system where you can define geometric shapes and some metadata for their properties.
As all the data is parsed by the map, you can create a generic physics populator for your games so the process of applying them to static bodies becomes almost automatic.
The juice of this recipe is concentrated into ...