Mouse.X and Touch.X

Get help using Construct 2

Post » Thu Mar 07, 2013 12:38 am

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!
B
5
Posts: 39
Reputation: 678

Post » Thu Mar 07, 2013 12:59 am

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.
Mistakes were made.
B
45
S
22
G
77
Posts: 1,200
Reputation: 44,265

Post » Thu Mar 07, 2013 3:15 am

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.
B
5
Posts: 39
Reputation: 678

Post » Thu Mar 07, 2013 4:08 am

You could also invert Is On Mobile Device and add it as a condition to your click event.
B
44
S
13
G
7
Posts: 603
Reputation: 7,916

Post » Thu Mar 07, 2013 1:15 pm

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

There are no click events either :)
B
5
Posts: 39
Reputation: 678

Post » Thu Mar 07, 2013 2:59 pm

In the touch object properties you can set 'Use mouse input' to yes. Then it will automatically work for both touch and mouse.
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,830

Post » Thu Mar 07, 2013 4:31 pm

@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.
B
5
Posts: 39
Reputation: 678

Post » Thu Mar 07, 2013 5:21 pm

@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.
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,830

Post » Thu Mar 07, 2013 6:57 pm

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.
Scirra Founder
B
373
S
218
G
84
Posts: 23,440
Reputation: 186,070

Post » Thu Mar 07, 2013 9:26 pm

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.
B
5
Posts: 39
Reputation: 678

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Jordan159, LukeW, mindragon73 and 7 guests