How do I make mouse work properly when changing layout scale

Get help using Construct 2

Post » Mon Jun 09, 2014 12:13 am

I got this problem, basically in my game you can drag stuff around, here's an example with LayoutScale set to 1.0 (red dot is the mouse cursor position):
Image

And now, when i zoom to LayoutScale to 1.1+ (in the snapshot its 1.5) the mouse cursor is not aligned with the object it's interacting with:
Image

Is there a way to fix the mouse position, keeping the ability to change layout scale?
B
66
S
22
G
4
Posts: 360
Reputation: 6,584

Post » Mon Jun 09, 2014 12:26 am

PS: i use the every tick - set position to mousex, y to keep the object smoothly dragged, otherwise the object is in the correct spot also when layout scale is 1.5
B
66
S
22
G
4
Posts: 360
Reputation: 6,584

Post » Mon Jun 09, 2014 12:53 am

I've read about this:

layer.canvasToLayerX(x)
layer.canvasToLayerY(y)

I suppose this can fix the mouse problem, how can i apply them?
B
66
S
22
G
4
Posts: 360
Reputation: 6,584

Post » Mon Jun 09, 2014 1:10 am

Ok, i've just solved the mystery, needed to add the layer name after mouse.x, y so it keeps mouse in sync with the scales.
B
66
S
22
G
4
Posts: 360
Reputation: 6,584

Post » Mon Aug 11, 2014 6:33 am

can you put a capx on the solution? i might need it sometime :)
B
22
S
6
Posts: 244
Reputation: 2,710


Return to How do I....?

Who is online

Users browsing this forum: irina and 5 guests