Jump to content


Photo

So how does YoYo_Mouse... actually work?


  • Please log in to reply
5 replies to this topic

#1 King Tetiro

King Tetiro

    King of Orenna

  • GMC Member
  • 2187 posts
  • Version:GM8

Posted 27 March 2012 - 12:32 PM

I got the most recent version of GMStudio today and started reading the Help file for information on how the YoYo_Mouse functions work. But I failed to find anything about them.

So how does the YoYo_Mouse functions actually work?

All I know is that they allow for multi touch. Could someone educate me on these functions?
I'd really appreciate it as we're looking towards the porting of The New Dawn.
  • 0

#2 NAL

NAL

    凸ʕಠᴥಠʔ凸

  • YoYo Games Staff
  • 686 posts
  • Version:GM:Studio

Posted 27 March 2012 - 01:17 PM

They're identical to their non-YoYo counterparts, other than having an additional argument: device.

When you touch your mobile's screen, that will register as device 0. If you touch with another finger while still touching with the first, the second will be device 1. Using these functions, you can check positions, downstates etc of up to five fingers.

So for example, with a simple for loop, you can check whether an enemy with object index oEnemy is being tapped on by any of up to five presses, and destroy it if it is:

for(i=0;i<=4;i+=1)
{
    if YoYo_MouseCheckButtonPressed(i,mb_left)
    {
        p=collision_point(YoYo_MouseX(i),YoYo_MouseY(i),
                          oEnemy,0,0)
        
        if p>-1
        {
            with(p) instance_destroy()
        }
    }
}

Edited by NAL, 27 March 2012 - 01:18 PM.

  • 1

#3 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 27 March 2012 - 02:37 PM

For a slightly less cluttered version..


for(device=0;device<=4;device+=1){
 if (YoYo_MouseCheckButton(device,mb_left)){   
   //stuff to do if screen touched goes HERE! //of course, device can be changed to any variable if you want!
 }
}


  • 0

#4 King Tetiro

King Tetiro

    King of Orenna

  • GMC Member
  • 2187 posts
  • Version:GM8

Posted 27 March 2012 - 03:37 PM

Ah that makes sense. Though what happens if you only want single touch?
  • 0

#5 TerraFriedSheep

TerraFriedSheep

    GMC Member

  • GMC Member
  • 2825 posts
  • Version:GM:Studio

Posted 27 March 2012 - 03:55 PM

When you touch your mobile's screen, that will register as device 0. If you touch with another finger while still touching with the first, the second will be device 1.


What happens if you then remove the first finger before the second? Does device 1 become 0, or does the next touch become 0, and then the following 2, if 1 is still pressed?
  • 0

#6 NAL

NAL

    凸ʕಠᴥಠʔ凸

  • YoYo Games Staff
  • 686 posts
  • Version:GM:Studio

Posted 27 March 2012 - 09:14 PM

Ah that makes sense. Though what happens if you only want single touch?

Just use device 0, or simpler, use GM's standard in-built mouse functions. Every mouse function should work with the first touch fine.

What happens if you then remove the first finger before the second? Does device 1 become 0, or does the next touch become 0, and then the following 2, if 1 is still pressed?


Device 1 will remain Device 1 rather than revert to 0, etc.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users