I need Orientation Sensor trigger values

Put your problem here if it does not fit any of the other categories.

I need Orientation Sensor trigger values

Postby Cumatru » Mon Mar 28, 2011 6:58 pm

I've made a Pac Man game which uses the directional keys to move the player around the maze.
Unfortunately i don't have a device and the simulator doesn't allows to simulate sensors and i can't calibrate my game, so i need some common values that are used to trigger movement to right/left and up/down.
Cumatru
Junior Developer
Junior Developer
 
Posts: 11
Joined: Sat Mar 12, 2011 4:19 am

Top

Re: I need Orientation Sensor trigger values

Postby raj_J2ME » Tue Mar 29, 2011 7:07 am

I think that you can use OrientationEventListener, ( or OrientationListener Which is right now deprecated ) which is Helper class for receiving notifications from the SensorManager when the orientation of the device has changed.

Please have a look over:
http://developer.android.com/reference/android/view/OrientationListener.html
Thanks with Regards,
Raj - The Kernel
raj_J2ME
Master Developer
Master Developer
 
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,

Re: I need Orientation Sensor trigger values

Postby Cumatru » Tue Mar 29, 2011 3:31 pm

Code: Select all
public abstract void  onOrientationChanged  (int orientation)


This methods returns only an integer ranging from 0 to 359.
I think this is to little information. I can't to anything with this.
Maybe i can make it move to left or right using this value, like this:

Code: Select all
orientation > 10 && orientation < 25    -> move to right
orientation > 335 && orientation < 349 -> move to left


But what about up and down ?
This is all i can think of by reading the method description.
Am i missing something ?
Cumatru
Junior Developer
Junior Developer
 
Posts: 11
Joined: Sat Mar 12, 2011 4:19 am

Re: I need Orientation Sensor trigger values

Postby raj_J2ME » Tue Mar 29, 2011 6:56 pm

Hi,

The method onOrientationChanged(int orientation) will be called when the orientation of the device has changed. orientation parameter is in degrees, ranging from 0 to 359. orientation is 0 degrees when the device is oriented in its natural position, 90 degrees when its left side is at the top, 180 degrees when it is upside down, and 270 degrees when its right side is to the top. ORIENTATION_UNKNOWN is returned when the device is close to flat and the orientation cannot be determined... :)

Please check the link below:
http://android-er.blogspot.com/2010/08/orientationeventlistener-detect.html
Thanks with Regards,
Raj - The Kernel
raj_J2ME
Master Developer
Master Developer
 
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 21 guests