Hi Thor,
In the example, we're centering the text at the midpoint of the
playing field, which is a Rectangle2D. You could use the exact same
logic to position the text at the center of your own rectangle.
The line you're interested in is:
// Get the field center point
var fCenter = MyFirstGame.getFieldBox().getCenter();
If you need the text to move with the rectangle, you would add your
text object to the object which draws the rectangle.
- Brett