简体   繁体   English

Libgdx地图更改

[英]Libgdx map changing

Im making an rpg game for a FSE project in my computer science class, and I need to change the map in my game. 我在计算机科学课上为FSE项目制作了一个rpg游戏,我需要在游戏中更改地图。 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. 唯一的问题是我可以通过加载新地图来更改地图,但是出于某些原因,libgdx仍会记住上一张地图中的box2d Hitbox。 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 我尝试了多种方法,例如dispose和尝试在类的不同部分制作新地图

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


}

谢谢,我弄清楚了,通过将所有主体添加到ArrayList中,然后可以使用world.distroyBody将其删除,这实际上可以正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM