Multitouch with screen position

F

felipe.rce

Guest
In my game you have two options, jump and attack, I do not want to put buttons on the screen, I want it to be clean, so I decided to use the touch (it's an Android game), but how would I do to make the player jump if the screen is touched on the left, and attack if it is touched on the right? (Remembering that it is for Android, different resolutions)

Sample image:
(Left screen - Jump, right screen - attack).
I can do the jump and attack, but I can't do this "precise" multitouch, how to detect this?

 
P

PandaPenguin

Guest
I'm sure you are already aware of device inputs (but let me link it anyway)

so, once you detected your touch input, check it with point_in_rectangle() to see in which half (or any rectangular area for that matter) of your screen the touch happened
 
F

felipe.rce

Guest
I'm sure you are already aware of device inputs (but let me link it anyway)

so, once you detected your touch input, check it with point_in_rectangle() to see in which half (or any rectangular area for that matter) of your screen the touch happened
Thanks.

I make a new empty project just for test this, but I don't understand... I won't work.


Code:
for (var i = 0; i < 3; i++) {
   if (device_mouse_check_button(i, mb_left)) {
      if (point_in_rectangle(device_mouse_x(i), device_mouse_y(i), 0, room_height, room_width, room_height)) {
         show_debug_message("!!!!!!!!!!!!!!!!!!!\");
      }
   }
}
It don't print the message, don't matter where I click
 
P

PandaPenguin

Guest
Code:
for (var i = 0; i < 3; i++) {
   if (device_mouse_check_button(i, mb_left)) {
      if (point_in_rectangle(device_mouse_x(i), device_mouse_y(i), 0, room_height, room_width, room_height)) {
         show_debug_message("!!!!!!!!!!!!!!!!!!!\");
      }
   }
}
I think one of your rectangle coordinates is wrong, you got two room_height there
 
F

felipe.rce

Guest
Ok, now I understand how it works xD, I will try to implement on my game, if it works (or not) I will post here
 
E

ewlf5

Guest
#rtf
There's a tutorial for this. Actually mouse_click functions aren't for multitouch devices because there can be only one (mouse) cursor.
You've got to check the tutorial called Virtual_Keys under Intermediate > Touch.
 

rIKmAN

Member
#rtf
There's a tutorial for this. Actually mouse_click functions aren't for multitouch devices because there can be only one (mouse) cursor.
You've got to check the tutorial called Virtual_Keys under Intermediate > Touch.
You can use the device_mouse_* functions for touch/multitouch.
The manual entries for those functions state that up to 5 screen touches can be detected using the functions, and states how the functions work when used on mobile.

From the manual...
Now, the device refers to the mouse number, which can be from 0 to 4 and this event is triggered when the touch screen of a mobile device is touched, so in this way you can test for up to 5 different screen touches.
or
This function returns x position of the device. If you are running this on a the HTML5 or PC and Mac modules then this value is updated constantly, as long as the device (usually a mouse) is plugged in, however for mobile devices, this will only be updated while the screen is being touched.
Device Input Manual Page
 
Top