virtual keys not working on touchscreen
#1
Posted 03 May 2012 - 12:44 PM
I found code online for creating virtual keys.
My main object moves up, down, left, right using arrow keys in its keyboard events.
I made an invisible object with this codes:
step event:
global.vkup = YoYo_AddVirtualKey(400, view_yview+320, 64, 64, vk_up );
YoYo_ShowVirtualKey( global.vkup );
global.vkright = YoYo_AddVirtualKey( 464, view_yview+340, 64, 64, vk_right );
YoYo_ShowVirtualKey( global.vkright );
global.vkdown = YoYo_AddVirtualKey( 400, view_yview+364, 64, 64, vk_down );
YoYo_ShowVirtualKey( global.vkdown );
global.vkleft = YoYo_AddVirtualKey( 336, view_yview+340, 64, 64, vk_left );
YoYo_ShowVirtualKey( global.vkleft );
Draw event:
draw_sprite(spr_Up,-1,400, view_yview+320);
draw_sprite(spr_Right,-1,464, view_yview+340);
draw_sprite(spr_Down,-1,400, view_yview+364);
draw_sprite(spr_Left,-1,336, view_yview+340);
The problem is that the arrows appear on screen, but touching them has no effect.
I have struggled with this problem for a whole week.
Thank you.
NB: I asked this question in the html forum but got no reply. Don’t know how to remove the topic from there to avoid double post.
#2
Posted 03 May 2012 - 12:55 PM
Some touch screens don't send a click when you tap the screen; you have to double-tap or press a button.
#3
Posted 03 May 2012 - 03:29 PM
Thank you for your reply.Does it work if you click the virtual keys with a mouse?
Some touch screens don't send a click when you tap the screen; you have to double-tap or press a button.
No reaction to mouse either. I think something wrong with the code but can't figure what. Any ideas?
#5
Posted 04 May 2012 - 01:19 PM
global.vkup = YoYo_AddVirtualKey(400, 320, 64, 64, vk_up ); global.vkright = YoYo_AddVirtualKey( 464, 340, 64, 64, vk_right ); global.vkdown = YoYo_AddVirtualKey( 400, 364, 64, 64, vk_down ); global.vkleft = YoYo_AddVirtualKey( 336, 340, 64, 64, vk_left );
#6
Posted 04 May 2012 - 06:56 PM
the virtual keys are defined as having an absolute position on the SCREEN not in the view. So, if your viewport is, for example, 640*480, then you should defien your virtual keys as being within that area, NOT using the relative coordinates as you are using just now. So, your code should probably be :
global.vkup = YoYo_AddVirtualKey(400, 320, 64, 64, vk_up ); global.vkright = YoYo_AddVirtualKey( 464, 340, 64, 64, vk_right ); global.vkdown = YoYo_AddVirtualKey( 400, 364, 64, 64, vk_down ); global.vkleft = YoYo_AddVirtualKey( 336, 340, 64, 64, vk_left );
It works now. Your explanation has solved my problem.
Thank you.
You deserve +5.
#7
Posted 03 July 2012 - 05:53 PM
i used the same code, but, the buttons not show with a moviment of the views...
they are static
#8
Posted 28 November 2012 - 07:03 AM
I think the drawing part of the keys needs to be written differently.hi, i'm with a problem with that
i used the same code, but, the buttons not show with a moviment of the views...
they are static
ie: virtual key: global.vkup = YoYo_AddVirtualKey(400, 320, 64, 64, vk_up );
draw: draw_sprite(spr_Up,-1,400, view_yview+320);
#9
Posted 28 November 2012 - 07:13 AM
PS: This functionaility has changed since the topic was made!!!
#10
Posted 28 November 2012 - 07:32 AM
Oh, didn't know that!No that's not it. They need to be drawn in the Draw GUI event with an ABSOLUTE value. They are no longer relative to the view, but rather static based on the screen/canvas size.
PS: This functionaility has changed since the topic was made!!!
Because i haven't worked with views for quite some time, but when i did some months ago, it worked fine.
#11
Posted 28 November 2012 - 07:36 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











