Smart phones and tablets contain several kinds of “sensors” to sense information about their environment. For example, an accelerometer provides information about movement of the phone (or tablet) – letting us know the speed and direction of travel in x, y and z coordinates (three dimensions).
The orientation sensor tells us if the phone is tilted to the left or right, or up or down (or flipped over). App Inventor provides a simple to use interface to the orientation sensor. We can use this to control a sprite or ball on the screen – by tilting our phone, we can make graphic items move around on the screen!
Sample source code that you can download is at the bottom of this post!
After going through this tutorial, you now know enough to create your own interactive smart phone game!
Before we get started, please review these earlier tutorials:
- How to Create a Bouncing Ball Animation in App Inventor 2
- Using ImageSprites for Animated App Inventor Graphics
- Controlling the sprite animation with the finger on your screen