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
35
S
14
G
22
Posts: 919
Reputation: 15,106

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
26
S
3
G
1
Posts: 497
Reputation: 2,324

Post » Sun Jul 16, 2017 11:53 am

Well I think I understood.
Thank you!.
B
35
S
14
G
22
Posts: 919
Reputation: 15,106


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests