(Libgdx learning) compass (compass)

Source: Internet
Author: User
Tags libgdx

Package com. example. groupactiontest; import com. badlogic. gdx. applicationListener; import com. badlogic. gdx. gdx; import com. badlogic. gdx. input. keys; import com. badlogic. gdx. input. peripheral; import com. badlogic. gdx. graphics. GL10; public class MyGame implements ApplicationListener {@ Overridepublic void create () {// System. out. println ("available:" + Gdx. input. isPeripheralAvailable (Peripheral. accelerometer); // System. out. println ("Gdx. input. getNativeOrientation (): "+ Gdx. input. getNativeOrientation (); System. out. println ("Peripheral. compass available: "+ Gdx. input. isPeripheralAvailable (Peripheral. compass); float azimuth = Gdx. input. getAzimuth (); float pitch = Gdx. input. getPitch (); float rool = Gdx. input. getRoll (); System. out. println (azimuth + "," + pitch + "," + rool) ;}@ Overridepublic void dispose () {// TODO Auto-generated method stub} @ Overridepublic void pause () {// TODO Auto-generated method stub} @ Overridepublic void render () {Gdx. gl. glClear (GL10.GL _ COLOR_BUFFER_BIT); // return the value of gravity acceleration at a certain point. out. println ("x:" + Gdx. input. getAccelerometerX () + "y:" + Gdx. input. getAccelerometerY () + "z:" + Gdx. input. getAccelerometerZ ();} @ Overridepublic void resize (int arg0, int arg1) {// TODO Auto-generated method stub} @ Overridepublic void resume () {// TODO Auto-generated method stub }}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.