Integrating the current code
Until now, we have successfully created examples about displaying a translucent depth image on a background image (Chapter 3, Rendering the Player), drawing linetrails of the two hands (Chapter 4, Skeletal Motion and Face Tracking), and determining a simple holding gesture (Chapter 5, Designing a Touchable User Interface) of UI interaction. These can just be used in the Fruit Ninja game to display the player and emulate his/her blade paths. The most basic UI components of our game are the restart and exit buttons. We will use the holding gesture to check if the player clicks on either of the two buttons.
We use an image with two buttons (restart and exit) drawn at the top-left and top-right corners of the background. We will use the holding gesture to trigger the buttons. The image is shown as follows:
Integrating existing elements in a scene
Now let's start.
The following global variables are copied and altered from the examples in Chapter 3...