Help with layer scale rate compensation.

Get help using Construct 2

Post » Sat Mar 14, 2015 11:27 pm

I have 2 layers, one with a scale rate of 0%, and another with a scale rate of 50%.

Now, if I zoom out, that is, set the layout scale to something like 50% does this happen?

Image

Or does this happen?

Image
B
17
S
2
Posts: 66
Reputation: 1,382

Post » Sun Mar 15, 2015 5:08 pm

I believe its the first.
Who dares wins
B
50
S
10
G
10
Posts: 1,728
Reputation: 12,867

Post » Sun Mar 15, 2015 5:16 pm

It's depending from the window/layout-size and where the center-point (scroll to) is.
When the layout-size is bigger then the window-size and you scroll to the center of the layout (or any other place, except lop-left), the first version will happen.
B
21
S
5
G
2
Posts: 175
Reputation: 3,487

Post » Sun Mar 15, 2015 9:08 pm

Great, thanks for the confirmation. I had tried placing large tiled backgrounds that filled each layer to compare, but it wasn't obvious to me what was happening.
B
17
S
2
Posts: 66
Reputation: 1,382

Post » Mon Mar 16, 2015 12:14 am

I'm going to add another question to this, relating to my first question.

So, in my game, I have a minimap. The minimap is 200x200. When the mouse is over the minimap, I get it's position on the minimap treating the topleft of the minimap as 0,0.If the mouse is on the very center of the minimap, it is at 100x100.
I call this number mouse_minimap_x and mouse_minimap_y respectively for each axis.

Then what I do, is take that number, and do mouse_minimap_x/200. This gives me a ratio. So if the mouse were in the very center of the minimap, I would get 0.5.

I call this new number the mouse_minimap_ratio_x. I take this and do mouse_minimap_ratio_x*layoutwidth. This tells me where to move the camera on the layout. Which, in this case, would be to the very center of the layout.

This all works fine normally, the problem arises when I set the layout scale to anything other than 100%. The camera is moved to the wrong position, often very far offset from where it should be.

To solve this, I tried making a new layer, with a scale rate of 0, and put the camera on that, but that changes nothing.
B
17
S
2
Posts: 66
Reputation: 1,382

Post » Mon Mar 16, 2015 10:52 am

This pops to mind ...

ratio = mouse_minimap_x/(200*layerscale)
Who dares wins
B
50
S
10
G
10
Posts: 1,728
Reputation: 12,867

Post » Mon Mar 16, 2015 9:49 pm

Yeah, I think that might have worked. It turns out that my problem was something else entirely though this time. I was using viewportleft(layer) but with the wrong layer. One that had a scale rate greater than 0. Thanks for your help though.
B
17
S
2
Posts: 66
Reputation: 1,382


Return to How do I....?

Who is online

Users browsing this forum: hsetiawan, mardavlet, Yahoo [Bot] and 23 guests