• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 package com.badlogic.gdx.tests;
18 
19 import com.badlogic.gdx.Gdx;
20 import com.badlogic.gdx.graphics.GL20;
21 import com.badlogic.gdx.graphics.g2d.BitmapFont;
22 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
23 import com.badlogic.gdx.tests.utils.GdxTest;
24 
25 public class AccelerometerTest extends GdxTest {
26 	BitmapFont font;
27 	SpriteBatch batch;
28 
29 	@Override
create()30 	public void create () {
31 		font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
32 		batch = new SpriteBatch();
33 	}
34 
35 	@Override
render()36 	public void render () {
37 		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
38 		batch.begin();
39 		font.draw(batch, "accel: [" + Gdx.input.getAccelerometerX() + "," + Gdx.input.getAccelerometerY() + ","
40 			+ Gdx.input.getAccelerometerZ() + "]\n" + "orientation: " + Gdx.input.getNativeOrientation() + "\n" + "rotation: "
41 			+ Gdx.input.getRotation() + "\n" + "wh: " + Gdx.graphics.getDisplayMode() + "\n", 0, 100);
42 		batch.end();
43 	}
44 
45 	@Override
dispose()46 	public void dispose () {
47 		font.dispose();
48 		batch.dispose();
49 	}
50 }
51