I create a small game that involves the grab gesture in leap motion. Basically, the leap motion captures the real-time movement of the user’s hand. When the hand grabs the bouncing ball inside the square, a lot of small balls will spread into all directions.
I first create a bouncing ball that moves inside a limited square. It will change the direction once it bumps into the boundaries.
Then I work on the small balls. I use ArrayList because the number of the balls is uncertain. Based on the previous exercises, those small balls will disappear when they go out of the screen.
In order to add more fun, I make the small balls change color if they go out of the designated boundaries. While they are inside the square, all the balls are filled in black. When they float out of the square, they will randomly change to different colors.
After I have prepared both the target ball and the small balls, I start to use LeapMotion library to combine them with grab gestures. It detects the grab gesture, and at the same time the distance between the middle finger and the target ball should be less than a certain distance. In this way, the program can more accurately decide whether the user has grabbed the target ball.
Below is the demo of this simple game: