How do I determine the number of the distance of 2 instances

Get help using Construct 2

Post » Sat May 23, 2015 3:51 pm

How do I determine the number of the distance of 2 instances? I want to know how much apart are they in pixels.

I tried:
create a Variable

every Tick
-set Text to Variable

every Tick
-set Variable to distance ( objectA.X, objectA.Y, objectB.X, objectB.Y)

... failed.
B
9
S
2
Posts: 12
Reputation: 601

Post » Sat May 23, 2015 4:16 pm

What failed exactly? Please describe in a little more detail. Show print screens of you code, too, if possible.
B
13
S
5
G
4
Posts: 139
Reputation: 2,586

Post » Sat May 23, 2015 5:42 pm

Just set text to distance ( objectA.X, objectA.Y, objectB.X, objectB.Y)
That probably straightest way to show how far 2 object are.
ImageImage
B
111
S
51
G
24
Posts: 787
Reputation: 23,394

Post » Sun May 24, 2015 6:33 am

@crypticblonde
Sorry for not being clear. The Text wasn't showing on the screen when I wrote the event like that. When I turn off set Variable to Distance the Text appears back on.

@alextro
It works!!!! Thank you very much. :)

EDIT: Actually, the event I wrote original works too. The reason why it wasn't showing on the screen was because I have:

On start of layout:
Text set font size to 36 pt.

For some reason when I have that on, the Text don't show up on screen, unless I turn off set Variable to Distance.
B
9
S
2
Posts: 12
Reputation: 601

Post » Sun May 24, 2015 11:55 am

The text object will show "Text" by default and at 36pt, it might just show it fine. But when you set it to show the distance, that could be 100.45 or something which will wrap the text, therefore you won't see it. Just resize the text object on the layout.
B
15
S
5
G
7
Posts: 876
Reputation: 5,650

Post » Sun May 24, 2015 2:44 pm

Sometime it happen to me too ;) . Text object can be tricky to deal with.
ImageImage
B
111
S
51
G
24
Posts: 787
Reputation: 23,394


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 28 guests