Tilemap Tiletoposition() [r162]

0 favourites
  • 5 posts
From the Asset Store
Enchanted Forest & Cave 16x16 Tilemap with Environment Sprites
  • Link to .capx file (required! If link is blocked remove the http and www parts):

    app.box.com/s/i81gjuzlmgjdyozz9xbc

    Steps to reproduce:

    1. Run .capx

    2. move mouse and observe mouse.x and mouse.y in text field 1

    3. compare mouse.x and mouse.y in text field 2 using TileToPosition(mouse.x) &?:?& TileToPosition(mouse.y) over the Tilemap object.

    Observed result:

    The mouse.x and mouse.y position used in Tiletoposition() exponentially increases as you move the mouse even a pixel at a time, while the normal mouse.x and mouse.y show the correct pixel location of the curser.

    Expected result:

    Shouldn?t the Tiletoposition() give the x and y location of a certain tile center as long as the mouse is over the certain tile? OR at least show the correct layout x and y position of the mouse?

    The positiontotileX & Y do the same weird measurements

    Browsers affected:

    Chrome: yes

    Firefox: yes

    Internet Explorer:

    Operating system & service pack:

    Windows 7

    Construct 2 version:

    r162

  • I'm still learning all the finer points of Tilemap, so I'd like to understand the outcome of this, too.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Closing as not a bug. You use TileToPosition*, which converts a tile index to a layout position, but you give it a layout position instead. You probably meant to use PositionToTile* instead.

  • I think it's a bug.

    If you move your mouse over last tile in every row you will see Mouse X is between 224 and 256. But TileToPosition(mouse.X) will show 7168 and 8192.

    Even if you do TileToPosition(mouse.X)/32 - where 32 is tile width then it will be between 224.5 and 256.5.

    So using TileToPosition(mouse.X) will result mouse.X*32

    and TileToPosition(mouse.X)/32 will result mouse.X+0.5

  • shinkan, I agree. I was incorrect in how I was using the Tiletoposition*, however I believe the x/y coordinates are off and are a bug in both the Posiotiontotile* and Tiletoposition*. Ashley, can you comment on if this is a bug or not, and If I need to re-post it I will.

    Check the x and y output of Positiontotile* and Tiletoposition* and compare to window x/y positions.

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