Virtual keys issues:

When compiling using latest BETA version, YYC android, I get an error whenever the app tries to destroy a virtual key:

#####################################
FATAL ERROR in
action number 1
of Other Event: Room End
for object objCountit:

virtual_key_delete argument 1 incorrect type (5) expecting a Number (YYGI32)


The code handling virtual keys below:


Code:
if (argument0 == 3) {
//room start:
for (i=1;i<=4;i+=1;) {
exe=(i+1)*110;
global.knapptard[i]=virtual_key_add(exe,y,exe+100,y+100,key[i]);
}
}
else if (argument0 == 4) {
//ROOM END
for (ibm=1;ibm<=4;ibm+=1;) {
virtual_key_delete(global.knapptard[ibm]);
}
}
What's causing this problem? How do I solve it?

Thanks!
 

jo-thijs

Member
The error is saying that for some index of global.knapptard[...], the array contains the value "undefined" by the time this piece is executed:
Code:
for (ibm=1;ibm<=4;ibm+=1;) {
virtual_key_delete(global.knapptard[ibm]);
}
I don't know if virtual_key_add can reurn the value "undefined".
Can you show us every piece of code that does something with globl.knapptard?
 

acidemic

Member
I have the same problem with both 1.4.1767 and with latest Early Access version 1.99.505. This problem started to appear since some spring/summer 2016 GMS versions.

And the same error in Windows YYC:


___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Alarm Event for alarm 0
for object obj_pause_btn_play:

virtual_key_delete argument 1 incorrect type (5) expecting a Number (YYGI32)
############################################################################################
--------------------------------------------------------------------------------------------
called from - gml_Script_script_touch_switch_off (line 11)
called from - gml_Script_script_pause_off (line 102)
called from - gml_Object_obj_pause_btn_play_Alarm_0 (line 3)
 
Last edited:

jo-thijs

Member
@acidemic, it doesn't happen for me.
Can you show us the exact code you're using and can you use show_message to show the returned values of virtual_key_add?
 

acidemic

Member
Actually this bug is already in the YoYo Bugs database as I reported it in the beginning of August 2016:
http://bugs.yoyogames.com/view.php?id=23089

Please note bug appears only on YYC (Android YYC, Windows YYC... didn't test on other export modules), and not on regular Android or Windows export.

On YYC export module show_message says "undefined", but on regular windows export it says "1".

Also "virtual_key_show" function creates the same bug.

That's the simplest way to reproduce it:

 
Last edited:

acidemic

Member
The only solution I have at the moment is NOT OT USE virtual keys at all. In my game I changed virtual keys to objects. I created my own touch controller which checks if virtual button object was touched by one of the 5 virtual mice (multitouch).

Code:
/// MY TOUCH CONTROLLER FOR ONSCREEN "LEFT", "RIGHT", "DOWN" keys.
if (global.touch_screen == true)
{
    var i=0;
    var touch_left_pressed = false;
    var touch_right_pressed = false;
    var touch_down_pressed = false;
  
    for (i=0;i<=4; i++) // Checks for all 5 virtual mice
    {
        if (device_mouse_check_button(i, mb_left))
         { 
            if position_meeting (device_mouse_x(i), device_mouse_y(i), obj_touch_left)
            {
                script_controller_left(); // Same code performs Keyboard Left event
                touch_left_pressed = true;
                global.touch_left_pressed = true;
                with(obj_touch_left) {script_touch_mouse_press();} // This code will affect virtual button left object appearance
            }
            else if position_meeting (device_mouse_x(i), device_mouse_y(i), obj_touch_right)
            {
                script_controller_right(); // Same code performs Keyboard Right event
                touch_right_pressed = true;
                global.touch_right_pressed = true;
                with(obj_touch_right){script_touch_mouse_press();} // This code will affect virtual button right object appearance
            }
            else if position_meeting (device_mouse_x(i), device_mouse_y(i), obj_touch_down)
            {
                script_controller_down(); // Same code performs Keyboard Down event
                touch_down_pressed = true;
                global.touch_down_pressed = true;
                with(obj_touch_down){script_touch_mouse_press();}  // This code will affect virtual button down object appearance
            }
         }
    }
  
// Code below performs "release" of the virtual button objects
    if (touch_left_pressed == false && global.touch_left_pressed == true)
    {
        script_touch_mouse_release();
        global.touch_left_pressed = false;
    }
  
    if (touch_right_pressed == false && global.touch_right_pressed == true)
    {
        script_touch_mouse_release();
        global.touch_right_pressed = false;
    }
  
    if (touch_down_pressed == false && global.touch_down_pressed == true)
    {
        script_touch_mouse_release();
        global.touch_down_pressed = false;
    }
}
 

jo-thijs

Member
Ok, I just tested it again and it does happen for me as well now.
I light have tested it on the wrong target before.
 
Top