I am playing with a game on Android, and I have a function MoveCharacter (int direction) that moves an animated sprite when buttons are pressed
For example, when user presses up I have this code:
mControls.UpButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mLevel.mCharAnimation.FrameUp();
}
});
However, I’d like to be able to keep moving the character as long as the user keeps the button down.
Surprisingly, I have not found out how to do this in Android.
Is there some kind of onButtonDownLister?
You need to use an OnTouchListener to have separate actions for down, up, and other states.