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

0 favourites
  • 8 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Hello,

    I am making a top view small RTS when I give orders to "police units" through the Pathfinding or the MoveTo behavior : https://www.dropbox.com/s/12uj3szkq95qn ... t.png?dl=0

    But I also have different zoom levels ont he map, managed as you can see on this screen : https://www.dropbox.com/s/pjx0anxtfqums ... 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 ?

    Thanks,

    Mogador

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Share you project, and i will add to it.

  • 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 : https://www.dropbox.com/s/vz1dpl8gq8427 ... .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

    Mogador

  • This fixes the positions for the mouse towards scaled layers.

    https://www.dropbox.com/s/x9vroaer8tmcx ... .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 ?https://www.dropbox.com/s/3y94n3d0kz86kma/PIB_ZoomProblem_2.capx?dl=0

    Mogador

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