Ph1losopher
Lurker
Hi guys
I am trying to achieve two different actions when the user clicks on a specific area on the screen
for example in the game line runner, when you click on the right side of the screen the man jumps
but he can perform two types of jump, a quick short one and a long one, depending on how quickly you touch up after touching down on that area
for example a quick touch down and release = short jump,
and touch down and hold = long jump.
any one knows how this can be achieved
here is an extract from my code, where i capture the user input
List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
int len = touchEvents.size();
for(int i = 0; i < len; i++)
{
TouchEvent event = touchEvents.get(i);
if(event.type == TouchEvent.TOUCH_DOWN)
{
action = World.Action_Jump;
}
else if(event.type == TouchEvent.TOUCH_Up)
{
action = World.Action_LongJump;
}
}
probelm is the touch down always gets called before touch up, so this essentially
performs two jumps, in one input action, which is not something i want
i want him to do a long jump, when we touch down and hold it down
and a quick short jump when we touch down and up quickly.
Many thanks
I am trying to achieve two different actions when the user clicks on a specific area on the screen
for example in the game line runner, when you click on the right side of the screen the man jumps
but he can perform two types of jump, a quick short one and a long one, depending on how quickly you touch up after touching down on that area
for example a quick touch down and release = short jump,
and touch down and hold = long jump.
any one knows how this can be achieved
here is an extract from my code, where i capture the user input
List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
int len = touchEvents.size();
for(int i = 0; i < len; i++)
{
TouchEvent event = touchEvents.get(i);
if(event.type == TouchEvent.TOUCH_DOWN)
{
action = World.Action_Jump;
}
else if(event.type == TouchEvent.TOUCH_Up)
{
action = World.Action_LongJump;
}
}
probelm is the touch down always gets called before touch up, so this essentially
performs two jumps, in one input action, which is not something i want
i want him to do a long jump, when we touch down and hold it down
and a quick short jump when we touch down and up quickly.
Many thanks