GGJuanPabon
Member
I have the multitouch problem (Videogame Android). There are only 3 buttons, Right, Left and jump. But if I touch right left I can't jump, and if I jump I can't walk, . Did you have a reference video? I searched but did not find a video.
I have the following texts as a reference, but I have tried almost identical, and it does not work, sometimes my character walks and jumps walking, but when I go to jump first, and then walk, it fails.
forum.yoyogames.com/index.php?threads/how-to-enable-multi-touch-for-a-mobile-game.40234/
reddit.com/r/gamemaker/comments/4s0kvz/gml_android_noob_q_how_to_implement_multitouch/
inventati.org/estupidezartificial/web/papers/multitouch.html
I have changed my code several times, I have done things like these.
Tried 1
Tried 2
I have the following texts as a reference, but I have tried almost identical, and it does not work, sometimes my character walks and jumps walking, but when I go to jump first, and then walk, it fails.
forum.yoyogames.com/index.php?threads/how-to-enable-multi-touch-for-a-mobile-game.40234/
reddit.com/r/gamemaker/comments/4s0kvz/gml_android_noob_q_how_to_implement_multitouch/
inventati.org/estupidezartificial/web/papers/multitouch.html
I have changed my code several times, I have done things like these.
Tried 1
GML:
for(var i=0; i<2; i++) {
if (device_mouse_check_button(i, mb_left))
{
if (finger[0] < 0)
{
finger[0] = i;
}else
{
finger[1] = i;
}
}
}
if (device_mouse_check_button(finger[0], mb_left))
{
var dMouseX = device_mouse_x_to_gui(finger[0]),
dMouseY = device_mouse_y_to_gui(finger[0]);
if (dMouseX > botonLeftX && dMouseX < botonLeftX + botonsize) &&
(dMouseY > botonLeftY && dMouseY < botonLeftY + botonsize)
{
global.pressedLeft = true;
show_debug_message("FINGER 0: " + string(finger[0]));
show_debug_message("FINGER 1: " + string(finger[1]));
}else
{
global.pressedLeft = false;
finger[0] = -1
}
if (dMouseX > botonRightX && dMouseX < botonRightX + botonsize) &&
(dMouseY > botonRightY && dMouseY < botonRightY + botonsize)
{
global.pressedRight = true;
show_debug_message("FINGER 0: " + string(finger[0]));
show_debug_message("FINGER 1: " + string(finger[1]));
}
else
{
global.pressedRight = false;
finger[0] = -1
}
}else{
global.pressedLeft = false;
global.pressedRight = false;
finger[0] = -1
}
if (device_mouse_check_button_pressed(finger[1], mb_left))
{
var dMouseX = device_mouse_x_to_gui(finger[1]),
dMouseY = device_mouse_y_to_gui(finger[1]);
if (dMouseX > botonUpX && dMouseX < botonUpX + botonsize) &&
(dMouseY > botonUpY && dMouseY < botonUpY + botonsize)
{
global.pressedUp = true;
show_debug_message("FINGER 0: " + string(finger[0]));
show_debug_message("FINGER 1: " + string(finger[1]));
}
else
{
global.pressedUp = false;
}
}else
{
global.pressedUp = false;
finger[1] = -1
}
GML:
/// @description Inserte aquí la descripción
// Puede escribir su código en este editor
//show_debug_message(display_get_height());
for(var i=0; i<2; i++)
{
if (device_mouse_check_button(i, mb_left))
{
if (finger[0] < 0)
{
finger[0] = i;
fingerFinal = finger[0];
}else
if (finger[1] != i)
{
finger[0] = i;
fingerFinal = finger[0];
}else
{
finger[1] = i;
fingerFinal = finger[1];
}
}
if (device_mouse_check_button_pressed(i, mb_left))
{
if (finger[1] < 0)
{
finger[1] = i;
fingerFinal = finger[1];
}else
if (finger[0] != i)
{
finger[1] = i;
fingerFinal = finger[1];
}else
{
finger[0] = i;
fingerFinal = finger[0];
}
}
}
//==================================== ARROW =======================================//
if (device_mouse_check_button(fingerFinal, mb_left))
{
var dMouseX = device_mouse_x_to_gui(fingerFinal),
dMouseY = device_mouse_y_to_gui(fingerFinal);
if (dMouseX > botonLeftX && dMouseX < botonLeftX + botonsize) &&
(dMouseY > botonLeftY && dMouseY < botonLeftY + botonsize)
{
global.pressedLeft = true;
show_debug_message("FINGER : " + string(fingerFinal));
show_debug_message("PRESIONANDO a la Izquierda");
}else
{
global.pressedLeft = false;
}
if (dMouseX > botonRightX && dMouseX < botonRightX + botonsize) &&
(dMouseY > botonRightY && dMouseY < botonRightY + botonsize)
{
global.pressedRight = true;
show_debug_message("FINGER : " + string(fingerFinal));
show_debug_message("PRESIONANDO a la Derecha");
}
else
{
global.pressedRight = false;
}
}else
{
show_debug_message("FALSOOOOOOOOOOOOO ARROW");
global.pressedLeft = false;
global.pressedRight = false;
finger[0] = -1;
finger[1] = -1;
}
//==================================== END ARROW =======================================//
if (device_mouse_check_button_pressed(fingerFinal, mb_left))
{
show_debug_message("SOLO FUE UN TOQUE");
var dMouseX = device_mouse_x_to_gui(fingerFinal),
dMouseY = device_mouse_y_to_gui(fingerFinal);
if (dMouseX > botonUpX && dMouseX < botonUpX + botonsize) &&
(dMouseY > botonUpY && dMouseY < botonUpY + botonsize)
{
global.pressedUp = true;
show_debug_message("FINGER 0: " + string(fingerFinal));
}
else
{
global.pressedUp = false;
}
}else
{
show_debug_message("FALSOOOOOOOOOOOOO JUMP");
global.pressedUp = false;
finger[0] = -1;
finger[1] = -1;
}