Android game development - moving your phone

First of all, sorry for the vague name. I have no other ideas about what could be placed there, but you will see it yourself when you read further.

I am a very new Java developer for android and Martian to game development, so my question is not so related to details, as it is related to theory and possibilities.

I wonder how I can develop my game, so if you hold the phone horizontally and it is tilted anyway, the object will move in this direction. I'm sure this is very common and easy to do, but what about if I wanted the maximum speed to increase and then accelerate in order to accelerate its acceleration?

I honestly have no idea about the complexity of this question, will you laugh and give me one line of code, or is it something you just can't teach.

Anyway, thanks for reading, I look forward to your answers.

+6
source share
2 answers

Check out http://mobilestrategist.blogspot.com/2010/01/android-accelerometer-and-orientation.html

This gives you what you need to do what you ask for, but as another answer suggests, you can work before you scan here. I have been writing Android for 2 years and have not yet used an accelerometer. Although, if you just want noodles with the capabilities of the device, this, as I understand it, is a good place to start.

+2
source

You can read about sensors and sensor events .

TYPE_ACCELEROMETER is perhaps what you are looking for ...

+1
source

Source: https://habr.com/ru/post/897046/


All Articles