Help with tiled maps and missing classes

Anything libgdx related goes here!

Help with tiled maps and missing classes

Postby Toreth » Mon Mar 11, 2013 10:14 pm

I just downloaded Libgdx yesterday and I'm trying to figure it out, so please excuse me if this is a silly question or has an obvious answer that I'm missing. I'm trying to load a TMX map following the examples that I've seen online which make use of TiledLoader, TileAtlas, TiledMap, and TileMapRenderer. Eclipse can't find any of those classes, nor do the namespaces that they're in seem to exist. Instead, Eclipse has TmxMapLoader, TextureAtlas, etc. Have those classes been removed from Libgdx? If so, where should I go to figure out what classes no longer exist, since searches on google pull up sites like http://libgdx.l33tlabs.org/docs/api/com ... derer.html which don't say anything about the class being deprecated.
Toreth
 
Posts: 11
Joined: Mon Mar 11, 2013 10:03 pm

Re: Help with tiled maps and missing classes

Postby BurningHand » Mon Mar 11, 2013 11:22 pm

This should help you get started with the new maps api:

https://code.google.com/p/libgdx/wiki/GraphicsTileMaps
IRC: nexsoftware / mobidevelop; GitHub: MobiDevelop;
BurningHand
 
Posts: 2264
Joined: Mon Oct 25, 2010 4:35 am

Re: Help with tiled maps and missing classes

Postby TomPCuddy » Tue Mar 12, 2013 8:43 pm

I am assuming that the new api is only in the daily builds?

How often does a new version build come out?

Thanks :)
TomPCuddy
 
Posts: 1
Joined: Tue Mar 12, 2013 8:41 pm

Re: Help with tiled maps and missing classes

Postby dave77 » Wed Mar 13, 2013 5:30 pm

The new tiledmaps api just came out recently, if you are using an older version of libgdx the classes you are looking for would be in
com.badlogic.gdx.graphics.g2d.tiled
dave77
 
Posts: 103
Joined: Tue Jan 15, 2013 4:40 pm

Re: Help with tiled maps and missing classes

Postby AngelusWeb » Wed Mar 20, 2013 5:20 am

BurningHand wrote:This should help you get started with the new maps api:

https://code.google.com/p/libgdx/wiki/GraphicsTileMaps


Quick question -- what is the equivalent of a TileAtlas now?
AngelusWeb
 
Posts: 345
Joined: Fri Jul 20, 2012 8:19 pm

Re: Help with tiled maps and missing classes

Postby BurningHand » Wed Mar 20, 2013 1:36 pm

AngelusWeb wrote:
BurningHand wrote:This should help you get started with the new maps api:

https://code.google.com/p/libgdx/wiki/GraphicsTileMaps


Quick question -- what is the equivalent of a TileAtlas now?


TiledMapTileSet is the closest equivalent of TIleAtlas.]
IRC: nexsoftware / mobidevelop; GitHub: MobiDevelop;
BurningHand
 
Posts: 2264
Joined: Mon Oct 25, 2010 4:35 am

Re: Help with tiled maps and missing classes

Postby AngelusWeb » Sat Mar 23, 2013 2:35 am

BurningHand wrote:
AngelusWeb wrote:
BurningHand wrote:This should help you get started with the new maps api:

https://code.google.com/p/libgdx/wiki/GraphicsTileMaps


Quick question -- what is the equivalent of a TileAtlas now?


TiledMapTileSet is the closest equivalent of TIleAtlas.]


Do I need to get a hold of the TiledMapTileSet that is auto-created by the map I load, in order to use SetCell?

I need to be able to modify the contents of a given cell in the game world.

Before:
map.layers.get(1).tiles[y][x] = 0;

But all I had to do was set an index to change it. Now, I'd need more than a number to use SetCell, right? I'd need an actual Cell from the TiledMapTileSet.

How is this normally done?
AngelusWeb
 
Posts: 345
Joined: Fri Jul 20, 2012 8:19 pm

Re: Help with tiled maps and missing classes

Postby BurningHand » Sat Mar 23, 2013 4:51 am

Cells don't come from the tileset, they come from the layer. A cell may be null if there was never a tile assigned to it, in which case all you have to to is instantiate a cell, give it a tile and set it on the map. The tile may be obtained from the tilesets collection of the tiledmap. Here's what that might look like:

Code: Select all
TiledMap map = loadMap();
TiledMapTile tile = map.getTileSets().getTile(1);
((TiledMapTileLayer) map.getLayers().get(1)).getCell(x,y).setTile(tile);


Of course, you can cache any of these objects to reduce the number of calls later.
IRC: nexsoftware / mobidevelop; GitHub: MobiDevelop;
BurningHand
 
Posts: 2264
Joined: Mon Oct 25, 2010 4:35 am

Re: Help with tiled maps and missing classes

Postby AngelusWeb » Fri Jul 19, 2013 5:03 am

Is there a demo (official or otherwise) that puts all this together?

When I first discovered LibGDX, I found a tutorial online that was in the same ballpark as the game I was trying to make (in my case, a 2-d tile scrolling RPG type game).

Now that everything's been overhauled, I'm completely disoriented again. I have printed out all the stuff in the maps/tiled/tiles folders, but that's when it hit me that this is going to take a while to figure out.

If there's a demo or tutorial for all this, I'm all ears!

Thanks,

Matthew
AngelusWeb
 
Posts: 345
Joined: Fri Jul 20, 2012 8:19 pm

Re: Help with tiled maps and missing classes

Postby AngelusWeb » Sat Jul 20, 2013 10:32 pm

BurningHand wrote:Cells don't come from the tileset, they come from the layer. A cell may be null if there was never a tile assigned to it, in which case all you have to to is instantiate a cell, give it a tile and set it on the map. The tile may be obtained from the tilesets collection of the tiledmap. Here's what that might look like:

Code: Select all
TiledMap map = loadMap();
TiledMapTile tile = map.getTileSets().getTile(1);
((TiledMapTileLayer) map.getLayers().get(1)).getCell(x,y).setTile(tile);


Of course, you can cache any of these objects to reduce the number of calls later.


Let's see if I'm getting this.

The code you gave me would keep the same ID for a given "square" in the game world, but it would use a different tile?

I'm looking to actually modify what is in that cell -- such as

((TiledMapTileLayer) map.getLayers().get(1)).setCell(x,y,tile);

Would that work? Or is that basically the same thing?
AngelusWeb
 
Posts: 345
Joined: Fri Jul 20, 2012 8:19 pm


Return to Libgdx

Who is online

Users browsing this forum: A Forum Member, Beryl, Bing [Bot], Eamonn, evilentity, Google [Bot], slebed and 10 guests