3

I'm programming my first Android Game ever and I'm trying to figure out the best way to handle inputs.

Should I handle inputs outright or put them in a queue of some sort and handle them with an updateInputs() method?

Also, where should I put the code for handling inputs? Should it be inside my SurfaceView object or inside of the thread that handles drawing and physics?

Thanks!

1 Answer 1

1

I would put them in a queue but execute them right away, incase the processing takes longer then expected you can keep track of what the user has done. As for handling the imputs, i would put it in the surface view, but thats just my general opinion. Im sure there are better ways.

Good luck, I would like to play your game when you finish

Sign up to request clarification or add additional context in comments.

3 Comments

So if I do use a queue what exactly do you mean when you say execute them right away?
Also, looking at the JetBoy sample from Google the doKeyDown event is inside of the thread rather than the view. Is this a better idea then putting it in the view?
As soon as there is some action inside a queue, it should executed. Inside the view you handle the event, but your right spawning a thread to handle it would make it more robust. Just make sure that the threads dont conflict with each other.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.