Procedurally Generated Maps won't render in libGDX

Started by
2 comments, last by macmanmatty 4 years, 10 months ago
Hello I'm trying to make procedurally generated maps using libGDX my tiled map won't render just displays an empty screen with all of my sprites on it. . But if I load a tiled map I made in the Tiled program it renders fine. The texture region exists and is gotten from a texture atlas.
 
Below is how make my tiled map in game. I have multiple layers one for each terrain kind that are drawn one on top of each other and then bit masked.
 

private void fillInTiles(){ // fills in all of the tiled map tiles to empty base tiles
TiledMapTileLayer layer= new TiledMapTileLayer(xSize, ySize, 32, 32); 
layer.setName("layer"+mapLayers.size());
for(int countx=0; countx<xSize; countx++) {
for (int county = 0; county < ySize; county++) { Cell cell = new Cell(); TextureRegion region=assetts.getRegionByName("dirt.0.255.0", "assetts.atlas");
cell.setTile( new StaticTiledMapTile(region));

layer.setCell(countx, county, cell);

}
}
tiledMap.getLayers().add(layer);
}

 

 
 
 
 
 
 
Hello I'm trying to make procedurally generated maps using libGDX my tiled map won't render just displays an empty screen with all of my sprites on it. . But if I load a tiled map I made in the Tiled program it renders fine. The texture region exists and is gotten from a texture atlas.
 
Below is how make my tiled map in game. I have multiple layers one for each terrain kind that are drawn one on top of each other and then bit masked.
 
 

private void fillInTiles(){ // fills in all of the tiled map tiles to empty base tiles
TiledMapTileLayer layer= new TiledMapTileLayer(xSize, ySize, 32, 32); 
layer.setName("layer"+mapLayers.size());
for(int countx=0; countx<xSize; countx++) {
for (int county = 0; county < ySize; county++) { Cell cell = new Cell(); TextureRegion region=assetts.getRegionByName("dirt.0.255.0", "assetts.atlas");
cell.setTile( new StaticTiledMapTile(region));

layer.setCell(countx, county, cell);

}
}
tiledMap.getLayers().add(layer);
}
 
Advertisement

Good code formatting will go a long way to getting a coherent response.


private void fillInTiles(){
	TiledMapTileLayer layer = new TiledMapTileLayer(xSize, ySize, 32, 32); 
	layer.setName("layer"+mapLayers.size());

	for(int countx = 0; countx < xSize; countx++) {
		for(int county = 0; county < ySize; county++) {
			Cell cell = new Cell();
			TextureRegion region=assetts.getRegionByName("dirt.0.255.0", "assetts.atlas");
			cell.setTile(new StaticTiledMapTile(region));
			layer.setCell(countx, county, cell);
		}
	}
	tiledMap.getLayers().add(layer);
}
  • Are mapLayers and tiledMap.getLayers() the same thing? If not, what is mapLayers supposed to be?
  • How is the screen empty, if it has all your sprites on it?
  • Could you post a screenshot?
  • Could you show the map-loading code that does work?
  • Is the misspelling of assets as "assetts" intentional?
  • Have you verified you do have a region called "dirt.0.255.0" in the asset "assetts.atlas"?
  • Can you show us the source of the method assetts.getRegionByName(), if that is your code? Or, what libGDX class is that an instance of?
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.

I solved my problem turns out   the 3rd  .tmx map saver extension  can't save maps created  created in libgdx only  the tiled program . I'm going to write my own map saving code.  Now

This topic is closed to new replies.

Advertisement