Tilemap - changing scale returns wrong PositionToTile

0 favourites
  • 6 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • Problem Description

    When the layout/layer scale is different from 1 the PositionToTile expression returns wrong tile index.

    Attach a Capx

    [attachment=0:3gziwkgh][/attachment:3gziwkgh]

    Description of Capx

    A tilemap that is drawn when the mouse is pressed.

    Steps to Reproduce Bug

    • 1 - Preview the capx
    • 2 - Click and Drag to draw tiles
    • 3 - Observe results
    • 4 - Disable first event and repeat steps 1 to 3 Observed Result The mouse position and the tile positions do not match when the layout/layer scale is changed. Expected Result Mouse and tile positions should match. Affected Browsers
      • Chrome: YES
      • FireFox: YES
      • Internet Explorer: not tested

    Operating System and Service Pack

    Windows 7 32bits

    Construct 2 Version ID

    r179

  • Use MouseX(0) and MouseY(0) (or MouseX("Layer 0") and MouseY("Layer 0")) instead of MouseX and MouseY. This is not a bug, this is a feature.

  • is right - you need to pass a layer parameter to the expressions for scaling to be taken in to account.

  • While this makes sense for a single layer scaled, I don't think it's an expected behavior for changing the layout scale.

    The MouseX and MouseY should return layout coordinates scaled according to the layout, as the manual states:

    [quote:2hlb0m9u]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.

    As the manual describes, the specified layer positions MouseX(0) should be only used when a single layer has a different scaling than the others, otherwise MouseX should cover it.

    So it doesn't seems to be a problem with tilemap's PositionToTile, but the MouseX and MouseY not accounting for layout scaling.

    Ashley Shouldn't it account for?

  • Maybe have it default to whatever layer 0 is.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh, you're right - the X and Y expressions were supposed to take in to account the layout scale, but the code was wrong. It should be fixed in the next build for both Touch and Mouse, and layout scale and angle, if you don't pass a layer.

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