Get Width and height

(Haso ) #1

Hi Guys,

I am new to Developing a game, I made a map with tiled here are the size information:
Width and height 35. And tile width and height 45. I am using libgdx, but I can not centre my cam to my map only a small portion of it is seen is there someone who can help me?

#2

This looks like a question more appropriate to the community around libgdx or the importer you’re using, this has little if anything to do with Tiled.

If you’re asking how to get the map’s dimensions from the TMX file so you can position the camera: the element contains the width (in tiles), height (in tiles), tilewidth (in pixels), and tileheight (in pixels). Read those in, multiply the two widths to get the pixel width of the map, and multiply the heights to get the total pixel height of the map. Set your camera’s position and limits accordingly. The exact way to do this depends on your camera system and coordinate system you’re using, which are most likely independent of anything in Tiled or your map file. For example, 0,0 might be in one of the corners of the map, or in the middle, or at some random point depending on how the coordinates of the whole map are set in your game. The coordinates might be in pixels, or in tiles, depending on your game.