Problem with tilemap

Discussion and feedback on Construct 2

Post » Sun Jul 16, 2017 11:00 am

Hi, does anyone know why the sprite does not move by tiles?
That is, the sprite should be placed on the tile in which the mouse is located at each moment.

I think I'm not wrong.


Image

https://www.dropbox.com/s/4itc14gqvidu8zc/testPositionToTile.capx?dl=0
B
30
S
13
G
21
Posts: 838
Reputation: 14,656

Post » Sun Jul 16, 2017 11:49 am

At the moment you set the Sprite at the position in tiles not in pixels. You have to convert it back in pixels like:

Sprite | Set position to Tilemap.TileToPositionX(Tilemap.PositionToTileX(mouse.x),......

Or you could use snap:
Sprite | Set postion to Tilemap.SnapX(mouse.X),.....
B
24
S
3
G
1
Posts: 454
Reputation: 2,171

Post » Sun Jul 16, 2017 11:53 am

Well I think I understood.
Thank you!.
B
30
S
13
G
21
Posts: 838
Reputation: 14,656


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests