How do I give the same X,Y position in different zoom level?

0 favourites
  • 8 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hello,

    I am making a top view small RTS when I give orders to "police units" through the Pathfinding or the MoveTo behavior : ... t.png?dl=0

    But I also have different zoom levels ont he map, managed as you can see on this screen : ... m.png?dl=0

    When I give orders at the default zoom level (which is 1, the closest level), it works fine.

    But when I give orders while being on other zoom levels, the units goes to a wrong position. The furthest I am from zoom level 1, the greater the position is wrong.

    What is the solution to give the same position although being at different zoom levels ?



  • Technically they are at the correct positions but you're scaling individual layers. If for example the police unit is on a scaled layer and the ground is not then it will look offset. Usually I use set layout scale for zooming, which scales everything together and avoids any issues like this.

  • Share you project, and i will add to it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Construct has 2 x/y values. one for each indiviual layer, changed by scale, and one for the canvas/screen.

    You can use the canvas to layer functions and layer to canvas function to convert the offset. In some cases you need to use one function inside the other.

    The mouse can also access the layer x/y by adding mouse(layer number).x

  • Thank you for your help <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I am not sure to fully understand. Does it have to do with absolute position ? As you proposed 99Instances2Go I am interested by an example of how to deal with it.

    Here is a capx : ... .capx?dl=0

    • When you click on "Platoon" button, you have a landing zone icon on your cursor. I would want this Landing Zone to be on the correct position even if I am changing the zoom scale (the layout starts at zoom = 1, use the mouse middle button to change zoom)
    • After validation the Landing Zone, an helicopter will arrive and drop an infantry platoon, when I move this platoon (by clicking on it, and then left click on its destination), I want it to move to the point I have selected, even If I am not on the initial (1) zoom scale.

    I would have a better understanding with an example

    Thanks again


  • This fixes the positions for the mouse towards scaled layers. ... .capx?dl=0

    But there is more that i would like to simplify. I might later.

  • Thanks a lot,

    I have put your example in the complete project.

    One problem remains : when dezooming, I have MarkerNOT (landing zone being black when it shouldn't) while my cursor is not overlapping any object, do you see why ?


  • Ok I have found the problem

    Thanks again for your help !

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