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

Get help using Construct 2

Post » Fri Jul 21, 2017 1:45 pm

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
B
6
S
2
Posts: 32
Reputation: 575

Post » Fri Jul 21, 2017 3:41 pm

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.
B
46
S
16
G
78
Posts: 2,166
Reputation: 46,349

Post » Fri Jul 21, 2017 4:42 pm

Share you project, and i will add to it.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Jul 22, 2017 10:35 am

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
B
11
S
2
G
1
Posts: 44
Reputation: 730

Post » Mon Jul 24, 2017 3:50 pm

Thank you for your help :)

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
B
6
S
2
Posts: 32
Reputation: 575

Post » Mon Jul 24, 2017 7:00 pm

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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Jul 24, 2017 10:57 pm

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
B
6
S
2
Posts: 32
Reputation: 575

Post » Tue Jul 25, 2017 5:55 pm

Ok I have found the problem
Thanks again for your help !
B
6
S
2
Posts: 32
Reputation: 575


Return to How do I....?

Who is online

Users browsing this forum: AllanR, Artcadev, asdtricky and 12 guests