Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. Apps That Know Where They Are > Time for action—seeing gravity and accelerat...

Time for action—seeing gravity and acceleration on our phones

Okay, let's look at acceleration in three dimensions on our phones using the AccelerometerSensor component.

All you need in Design is a label to show results. Center it, and make it fill parent. Also big enough to see as you swing the phone back and forth through the air (carefully, carefully, of course).

Your design should look something like the following screenshot. I used a horizontal arrangement 15 pixels high to space the text down a bit and make it look neat and made the centered text 32 in size.

From the Sensors drawer, drag out an AccelerometerSensor and drop on the virtual phone screen.

Time for action—seeing gravity and acceleration on our phones

Move over to the Blocks Editor. Pull out (from the My Blocks/AccelerometerSensor1 drawer) the AccelerometerSensor1.AccelerationChanged frame block.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint