Jump to content
  • Advertisement
macmanmatty

Java Procedurally Generated Maps won't render in libGDX

Recommended Posts

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);
}
 

Share this post


Link to post
Share on other sites
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?
Edited by Wyrframe
adding a question

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!