Game Development Reference
In-Depth Information
The rendering of the game world takes place in the render() method. The
SpriteBatch class offers two methods called begin() and end() . These
methods are used to start and end a new batch of drawing commands. Before
any drawing command can be executed, it is mandatory to call begin() . In
renderTestObjects() , we loop through all the sprites by accessing the previously
stored reference to WorldController and calling the Sprite class' draw() method
to draw it. After all drawing commands have been executed, we end the batch with
the corresponding call to end() , which is just as mandatory as begin() .
All done! You can now run the game to try it out. One of the sprites should be
constantly rotating around its center point, which tells us that this must be the
currently selected sprite.
Here is a screenshot of the game with the rendered test sprites running on Windows:
Adding the game world's debug controls
During development, having debug controls built into an application to be able to
directly manipulate certain behaviors can be a very powerful feature. Debug controls
are what gamers usually call game cheats, although this is a very elastic term. What
is certain is that it will make your life as a developer a lot easier and more fun too.
Just be sure to remove or disable all debug controls before publishing your game as
long as you do not intend them to be available to the user.
 
Search WWH ::




Custom Search