Im developing a 2d game rightnow.
Im using:
@Override
public boolean onTouchEvent(MotionEvent event) {
So basicly I want my person.X to increase while I’m holding down the screen.
It both works and don’t, first my person do move but I have to spam press the screen.
Isn’t there a way like: as long as you touch screen reapeat this code?
//Simon
Return true in the onTouchEvent method to show that you have handled the event and to continue to receive touch events (such as
MotionEvent.ACTION_MOVEandMotionEvent.ACTION_UP).If you want to keep changing the game state while a user is holding down the screen I suggest running a separate thread (you should already have one?) that will update it separately according a boolean set by a
MotionEvent.ACTION_DOWNand reset by aMotionEvent.ACTION_UP.Remember you can access the type of
MotionEventby usingMotionEvent.getAction()(in this caseevent.getAction())