Mouse.X and Touch.X

0 favourites
  • 10 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hello,

    I have an ambition to move the object to my mouse position Mouse.Y every tick so it effectively moves up and down with mouse movements.

    I also want to repeat this for touch.Y.

    However I can't think of way to disable mouse if on ipad etc.

    I can't use the behaviour of the touch object as mouse because no clicking is involved. Just movement.

    Can anyone think of a smart way to do this?

    Cheers!

  • Why do you need to disable mouse on ipad? Since the ipad doesn't have mouse input, those actions will be effectively disabled and not run.

  • No, for some reason Mouse.X & Y causes issues on the ipad. I fixed it with the below:

    (Touch) Is In Touch >> Set Y to touch.Y

    (System) If mouseY != mouse.Y >> Set Y to mouse.Y

                                     Set mouseY to mouse.Y

    This means that every tick, the touch won't be interfered with any computation of a mouse co-ordinate of 0. It seems a null mouse co-ordinate is interpreted as 0.

  • You could also invert Is On Mobile Device and add it as a condition to your click event.

  • Is On Mobile Device shouldn't really be used for this since laptops are also touch enabled nowadays.

    There are no click events either :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • In the touch object properties you can set 'Use mouse input' to yes. Then it will automatically work for both touch and mouse.

  • thehen

    Unfortunately, that's only when clicking is involed. You have to click and drag to emulate a touch swipe. In terms of just moving the x/y position without a click is missing.

  • aceofpack Ah of course, I see what you mean. You won't be able to set a variable on mouse move either as some touch devices move the cursor on touch. An interesting dilemma.

  • See touch controls and a trick to detect input method. I think your best bet is to make a title screen, and to set the control method depending on whether the user touched or clicked the title screen.

  • It's cool, thanks for the help guys - I've solved this with:

    (Touch) Is In Touch >> Set Y to touch.Y

    (System) If mouseY != mouse.Y >> Set Y to mouse.Y

                                     Set mouseY to mouse.Y

    Where mouseY is a global variable.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)