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

  • 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.

  • What failed exactly? Please describe in a little more detail. Show print screens of you code, too, if possible.

  • Just set text to distance ( objectA.X, objectA.Y, objectB.X, objectB.Y)

    That probably straightest way to show how far 2 object are.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • Sometime it happen to me too . Text object can be tricky to deal with.

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