• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android - Laggy Multiple Tap Events

D

Dan5033

Guest
I've been working on an android project for a while now and I needed an on-screen keyboard. I tried making my own after failing to find a way to make the default android keyboard to appear. That was when I realized that tapping multiple buttons continuously causes the game either not register my taps or inputting it later causing wrong input.

I've run some diagnostics. The frame rate is above 60fps, meaning the game is running fine. Discrete button taps work fine. And disabling double clicks doesn't help. I'm using Samsung S8 to run the application.

What should I do?
 
S

signal

Guest
You need to get a newer device :p

No, you should probably post your keyboard code. I was going to say it's a device_mouse_dbclick_enable() problem, but you already mentioned you've disabled it, so you're probably just overlooking something in your keyboard code.
 

Mool

Member
A friend of mine had that problem too. Are u developing a clicker game or something like that and u use more than 5 fingers?

He found no solution. May u could create a extension or someone here has a good idea.
 
D

Dan5033

Guest
My keyboard is created like the following:

Something will call to create obj_keyboard.
In the create event of obj_keyboard, it will spawn obj_key corresponding to A-Z and a backspace.
There, it will assign itself as the parent of all of the obj_keys.

In the tap event of the obj_key, the following is the code:
Code:
parent.fulltext += text;
audio_play_sound_on(obj_global.sfx_em,snd_tap,0,10);
In summary, it will edit the variable fulltext in obj_keyboard and play a click sound.
Other than that, obj_keys has a Draw event which draws itself and a Step event that checks if the parent still exists. It destroys itself otherwise.

EDIT: I forgot to say I'm using GameMaker 2 if it changes anything
 
D

Dan5033

Guest
Just in case if anyone in the future needs a solution:

Instead of using the Tap event in each of the keys, I put the following code in the Step event of the obj_keyboard:
Code:
var pressed = -1;
for (var i = 0; i <= 4; i++) {
    if (device_mouse_check_button_pressed(i,mb_left)) {
        pressed = i;
        break;
    }
}

if (pressed >= 0) {
    var xx = device_mouse_x(i);
    var yy = device_mouse_y(i);
    var key = instance_position(xx,yy,obj_keys);
    
    if (key.object_index == obj_back) {
        keyboard_string = string_delete(keyboard_string,string_length(keyboard_string),1);
    } else {
        keyboard_string += key.text;
    }   
    audio_play_sound_on(obj_global.sfx_em,snd_tap,0,10);
}
With this, only obj_keyboard is checking for collision rather than each of the obj_keys
 

rIKmAN

Member
Just in case if anyone in the future needs a solution:

Instead of using the Tap event in each of the keys, I put the following code in the Step event of the obj_keyboard:
Code:
var pressed = -1;
for (var i = 0; i <= 4; i++) {
    if (device_mouse_check_button_pressed(i,mb_left)) {
        pressed = i;
        break;
    }
}

if (pressed >= 0) {
    var xx = device_mouse_x(i);
    var yy = device_mouse_y(i);
    var key = instance_position(xx,yy,obj_keys);
   
    if (key.object_index == obj_back) {
        keyboard_string = string_delete(keyboard_string,string_length(keyboard_string),1);
    } else {
        keyboard_string += key.text;
    }  
    audio_play_sound_on(obj_global.sfx_em,snd_tap,0,10);
}
With this, only obj_keyboard is checking for collision rather than each of the obj_keys
I know you've solved this now, but I think your problem with the "Tap Event" was something to do with the timing functions:

gesture_get_double_tap_time()
gesture_get_double_tap_time()

I had issues with response speed when the events were first added, and was told they were functions just to get things up and running for beginners, so it's probably better than you are detecting them yourself manually anyway.
 
M

Matt Hawkins

Guest
Try increasing the sleep margin in the Android/Fire tab of the global game settings to about 10ms.
Also I have found with my Samsung Galaxy that multiple presses on the same X axis causes input lag. To get around this I stagger the positions of my on screen buttons.
 
Top