Mouse.X/Mouse.Y on layout scale incorrect

0 favourites
  • 4 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • 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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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)).

    It's like this by design and should work if you specify the layer like it says in the manual.

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

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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)