Hello Guest

Author Topic: 2d toolkit help  (Read 3611 times)

adam

  • Newbie
  • *
  • Posts: 8
    • View Profile
2d toolkit help
« on: March 19, 2014, 02:29:58 pm »
Hi have recently purchased this 2d2k toolkit and finding it great so far. Have generated a tile map, painted tiles and made a camera that moves and zooms around the tilemap.

The next step for us is to place buildings onto the tilemap as we are hoping to create a city builder game. We are now completely lost and if anyone has any tutorials or anything that can help us do this that would be great.

We are currently trying to place a building onto the tilemap and have it lock onto the tiles as it moves.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2d toolkit help
« Reply #1 on: March 20, 2014, 11:43:32 am »
To make the sprite snap to a tile -

1. Make sure the anchor on the sprite is set the same as the tile map sprite collection. i.e. if you position the sprite at (0,0,0) it should be perfectly over the the bottom left tile.

2. Work out the size of 1 tile. Vector3 tileSize = tilemap.GetTilePosition(1, 1) - tilemap.GetTilePosition(0,0);

3. You can position your sprite at any tile by either using tile map.GetTilePosition(x, y) or... you can also snap it to the closest tile by snapping it to the closest tileSize multiple, eg. if you're doing this by mouse cursor, etc.