Mouse.X/Mouse.Y on layout scale incorrect

Get help using Construct 2

Post » Sat Oct 13, 2012 8:20 pm

Hi all

I'm trying to zoom and out in my game, but I'm running into an issue with mouse coordinates.

I'm creating two sprites, one on Mouse.X/Mouse.Y and one on Mouse.AbsoluteX/Mouse.AbsoluteY, but as the layout scales neither seem to able to track where the mouse is clicking.

Sample:
https://dl.dropbox.com/u/20830426/LayoutScaleTest.capx

I was able to fix the problem using this post from michelangelo, but according to Ashley in that thread it should be working in the first place.

Anyone know why the mouse coordinates are not working on scale?
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Sat Oct 13, 2012 9:42 pm

[quote=Manual]X
Y
Return the position of the mouse cursor in game co-ordinates. This is (0, 0) at the top left of the layout. It changes to reflect scrolling and scaling. However, if an individual layer has been scrolled, scaled or rotated, these expressions do not take that in to account - for that case, use the layer versions below.

X("layer")
Y("layer")
Return the position of the mouse cursor in game co-ordinates, with scrolling, scaling and rotation taken in to account for the given layer. The layer can be identified either by a string of its name or its zero-based index (e.g. Mouse.X(0)).[/quote]

It's like this by design and should work if you specify the layer like it says in the manual.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sat Oct 13, 2012 9:49 pm

Oh cool that works! Since the IDE just has X/Y, I assumed it was just defaulting to the current layer. It's easy to miss that you can/need to specify the layer as well for scaling to work.

Thanks Nimtrix!

edit - Just because I'm curious - Is there any reason you wouldn't want to use Mouse.X(0)? Is there any case you wouldn't want to take scaling/scrolling into account?boolean2012-10-13 21:52:07
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Sat Oct 13, 2012 11:57 pm

Well, maybe if you had zoomed in just a small part of the screen (like a minimap or something), you might want to ignore that scaling/zooming for some events. There are probably some other uses as well, it's nice to be able to do both anyways.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests