location of the Body . Remember that update is called each time step is called on the world , so the visual
position of the Ball is updated with each step. The rotation of the node is similarly updated.
In the case of the class Ball , both the JavaFX representation of the two arcs and the Phys2D
representation of a circle assume that the center of the circle is at the location (0,0). However, if we look
at the Phys2D class Box and compare it to the JavaFX class Rectangle , we can see that the same
assumption was not made. While Box is centered at (0,0), the class Rectangle assumes the upper left
corner is at (0,0). So while the implementation of Wall shown in Listing 6-4 is similar to Ball , the location
of the representing Rectangle must be shifted up and to the left in order to be displayed in the correct
spot. Figure 6-2 shows the differences in the origins between Phys2D and JavaFX.
Figure 6-2. Centers of different shapes in Phys2D (left) and JavaFX (right)
Also note in the class Wall that a StaticBody was used, not a Body . A StaticBody is a special type of
Body that does not move in the world . As a result, the update method of Wall does nothing, as it will never
move. A later example will show how StaticBodies and Bodies can be mixed to create some interesting
Now that we know how this first simple example works, we can see how the function in Listing 6-5
can quickly create a more interesting effect.