Tilemap Tiletoposition() [r162]

Bugs will be moved here once resolved.

Post » Wed Feb 19, 2014 4:29 am

Link to .capx file (required! If link is blocked remove the http and www parts):
https://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:
Shouldnt 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
    
Zetar2014-02-19 04:36:39
B
193
S
6
G
7
Posts: 213
Reputation: 10,203

Post » Wed Feb 19, 2014 4:42 am

I'm still learning all the finer points of Tilemap, so I'd like to understand the outcome of this, too.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
142
S
24
G
8
Posts: 793
Reputation: 15,157

Post » Thu Feb 20, 2014 5:04 pm

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.
Scirra Founder
B
402
S
238
G
89
Posts: 24,613
Reputation: 195,993

Post » Thu Feb 20, 2014 5:49 pm

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
B
158
S
67
G
43
Posts: 2,603
Reputation: 36,003

Post » Fri Feb 21, 2014 12:28 am

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.
B
193
S
6
G
7
Posts: 213
Reputation: 10,203


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest