Reputation: 31
Im making an rpg game for a FSE project in my computer science class, and I need to change the map in my game. The only problem is that I can change the map by loading in a new map, however for some reason libgdx still remembers the box2d hitboxes from the previous map. I call the method change map after the 1st level has been completed. I don't get an error though
I have tried multiple methods such as dispose and trying to make the new map in different parts of the class
public void ChangeMap(){
map.dispose();
map = new TmxMapLoader().load("Assets/Maps/World map1.tmx"); //load the new map
renderer.setMap(map);
worldcreator = new WorldCreator(world, map);
}
Upvotes: 2
Views: 404
Reputation: 31
Thanks I figured it out, By adding all the bodies to an ArrayList I could then remove them using world.distroyBody, this actually worked
Upvotes: 1