PhoneGap accelerometer ball

By | 21/11/2012

I am writing this post as part of a course called Mobiilituotekehitys (Mobile development) held by Tero Karvinen

I am using Eclipse to develop PhoneGap applications on a 64-bit Xubuntu 12.10 installed on a HP EliteBook 2560p Laptop.

Program Name



The ball rolls to either left or right according to where you tilt the phone.


Doesn’t work / alpha / beta / release

Tested on Samsung Galaxy Gio S5660 & Sony Ericsson Xperia Active



Source code

Technical information

The program checks if the phone is tilted a certain amount either clockwice or counter-clockwise and changes the balls position accordingly by looping the ball’s x’-location and adding or reducing 5. Depending which way the phone is tilted.


I used Accelerometer API and processing-1.4.1.min.js -library to do this assignment.

Leave a Reply

Your email address will not be published. Required fields are marked *