# distance between the object and cursor

Get help using Construct 2

### » Mon Jul 30, 2012 9:13 am

how to measure the distance between the object and the cursor only in X? desirable that the object was a point of "0" (the origin point)
B
11
S
1
Posts: 36
Reputation: 1,701

### » Mon Jul 30, 2012 9:38 am

What about maths ?

Object.X - Mouse.X
(or the opposite, depends on what exactly you're wanting to do)
New to Construct ? Where to start

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,786

### » Mon Jul 30, 2012 9:46 am

The "Distance" function will work fine too:
distance(x1, y1, x2, y2)

or in your case, something like this:
distance(Object.X, Object.Y, Mouse.X, Mouse.Y)
B
38
S
13
G
9
Posts: 151
Reputation: 8,427

### » Mon Jul 30, 2012 9:48 am

@CodeMasterMike: He only wanted the "X" distance.
New to Construct ? Where to start

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,786

### » Mon Jul 30, 2012 9:49 am

[QUOTE=Kyatric] @CodeMasterMike: He only wanted the "X" distance.[/QUOTE]
Oh, I missed that part, sorry.
B
38
S
13
G
9
Posts: 151
Reputation: 8,427

### » Mon Jul 30, 2012 9:56 am

I have a ball, which should turn left or right, depending on whether - left or right of the cursor on the ball. How can I do?
B
11
S
1
Posts: 36
Reputation: 1,701

### » Mon Jul 30, 2012 10:31 am

@RACR2:
Try something like
Cursor.X < Ball.X
-- Go right
Else
-- Go left
B
20
S
5
G
4
Posts: 51
Reputation: 4,139

### » Mon Jul 30, 2012 10:34 am

[QUOTE=basti] @RACR2:
Try something like
Cursor.X < Ball.X
-- Go right
Else
-- Go left[/QUOTE] how to set the direction of rotation of an object?
B
11
S
1
Posts: 36
Reputation: 1,701

### » Mon Jul 30, 2012 10:42 am

oops, already knew ^^"
B
11
S
1
Posts: 36
Reputation: 1,701

Return to How do I....?

### Who is online

Users browsing this forum: Muini, Yahoo [Bot] and 14 guests