• Advertisement
Sign in to follow this  

Libgdx TiledMapLayerTile issues

This topic is 991 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Why would this code be acting odd? Any string I hand the .containsKey() function returns true. So every tile on my layer is trying to spawn a mob, and it's causing some issues haha. I'm using the same function to check for "solid" in another class and that one works as excpected.

                String key = "spawn";
                System.out.println("Spawning mobs into memory...");
		int count = 0;
		int toSpawnCount = 0;
		System.out.println("Current Floor: " + player.getCurrentFloor() );
		System.out.println("FloorSize: " + levels[player.getCurrentFloor()].getWidth() + ", " +  levels[player.getCurrentFloor()].getHeight());
		
		for (int x = 0; x < levels[player.getCurrentFloor()].getWidth(); x++)
			for (int y = 0; y < levels[player.getCurrentFloor()].getHeight(); y++)
			{
				if (tiles.getCell(x, y) != null)
					if (tiles.getCell(x, y).getTile().getProperties().containsKey(key));
					{
					//	System.out.println("Found a tile to spawn...");
						alist.add(x);
						alist.add(y);
						count++;
					}	
				//count++;
			}
	
		System.out.println("Counted " + count + " tiles containing spawn key.");

Output

Spawning mobs into memory...
Current Floor: 0
FloorSize: 25, 25
Counted 625 tiles containing spawn key.

[attachment=28400:mapSpawn.png]

 

The "mud" tiles contain the "spawn" key, and no other tiles do. I've double and triple checked!

 

Share this post


Link to post
Share on other sites
Advertisement

Found the error! Was syntax, and I found it right after posting this as I always do.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement