Hello,Â
I am trying to control the movement of the player in the game by hand movements. When a person moves his hand to the right the robot goes on moving to the right until we pass another movement to stop. And the same for the rest.
So, I wrote a method and it gets called when the gesture is done.
public void moveRight(){
final float gameTime = sSystemRegistry.timeSystem.getGameTime();
final float halfWidth = ButtonConstants.MOVEMENT_SLIDER_BAR_WIDTH / 2.0f;
final float center = ButtonConstants.MOVEMENT_SLIDER_X + halfWidth;
final float offset = ButtonConstants.MOVEMENT_SLIDER_REGION_WIDTH - center;
float magnitudeRamp = Math.abs(offset) > halfWidth ? 1.0f : (Math.abs(offset) / halfWidth);
final float magnitude = magnitudeRamp * Utils.sign(offset) * SLIDER_FILTER * mMovementSensitivity;
mDirectionalPad.press(gameTime, magnitude, 0.0f);
       //mDirectionalPad.press(gameTime,1.0f,0.0f);
}
To test if its working I created a dummy button and when we press it this method get called.
 testButton.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
input = BaseObject.sSystemRegistry.inputGameInterface;
if (event.getAction() == MotionEvent.ACTION_DOWN){
  input.moveRight();
  }else if(event.getAction() == MotionEvent.ACTION_UP){
  input.release();
  }
But it isn't working.Â
Any help is appreciated!Â
Thank you.Â