如何在LibGDX中正确绘制碰撞边界?

如何在LibGDX中正确绘制碰撞边界?,libgdx,Libgdx,我想做一个基本的RPG游戏,口袋妖怪看起来很像。我的问题是,我不知道如何正确地绘制游戏中的碰撞。我不知道怎么做或者为什么,但看起来它们并没有按预期进行缩放。这里我举一个例子: 它应该是这样的: 下面是代码,第一部分是父类 public类BaseScreen实现屏幕{ 受保护的Juego游戏; 保护世界; 保护演员阶段; 保护级潘塔拉; 受保护的平铺地图; 受保护的静态int宽度;//Aqíalmacenaremos la anchura en瓷砖 受保护的静态内部高度;//Aquiíalmace

我想做一个基本的RPG游戏,口袋妖怪看起来很像。我的问题是,我不知道如何正确地绘制游戏中的碰撞。我不知道怎么做或者为什么,但看起来它们并没有按预期进行缩放。这里我举一个例子: 它应该是这样的: 下面是代码,第一部分是父类

public类BaseScreen实现屏幕{
受保护的Juego游戏;
保护世界;
保护演员阶段;
保护级潘塔拉;
受保护的平铺地图;
受保护的静态int宽度;//Aqíalmacenaremos la anchura en瓷砖
受保护的静态内部高度;//Aquiíalmacenaremos la altura en瓷砖
受保护的地图属性;
受保护的资产管理器管理器;
受保护的整数波浪宽度,波浪高度,
mapWidthInTiles,mapHeightInTiles,
贴图宽度像素、贴图高度像素;
受保护的正交摄影机;
受保护的Jugador Jugador;
公共静态最终浮点单位标度=1/32f;//Nos servirápara establecer que la pantalla se divide en tiles de 32个像素
公共静态最终浮点像素CUADRO=32f;
受保护的正交平铺贴图渲染器;
受保护的ShaperEnder ShaperEnder;
受保护的瓷砖镶嵌层terrainLayer、terrainLayer 2、terrainLayer 3;
保护性大肠杆菌;
公共基本屏幕(Juego g){
game=g;
}
@凌驾
公开展览({
}
@凌驾
公共无效渲染(浮动增量){
}
@凌驾
公共空心调整大小(整型宽度、整型高度){
}
@凌驾
公共空间暂停(){
}
@凌驾
公众简历(){
} 
@凌驾
公共空间隐藏(){
}
@凌驾
公共空间处置(){
manager.dispose();
jugador.dispose();
renderer.dispose();
pantala.dispose();
}
}
第二个是扩展:

public类Mapa1扩展了BaseScreen{
私人朱伊戈朱伊戈;
公共地图A1(Juego g){
超级(g);
这个.juego=g;
ShaperEnder=新的ShaperEnder();
tileMap map=new TmxMapLoader().load(“Mapas/InteriorCasaInicialFinal.tmx”);
渲染器=新的正交平铺贴图渲染器(贴图、单位比例);
camera=新的正交摄影机(Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
camera.translate(Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight()/2);
camera.update();
MapProperties=map.getProperties();
tileWidth=properties.get(“tileWidth”,Integer.class);
tileHeight=properties.get(“tileHeight”,Integer.class);
mapWidthInTiles=properties.get(“width”,Integer.class);
mapHeightInTiles=properties.get(“height”,Integer.class);
mapWidthInPixels=mapWidthInTiles*tileWidth;
mapHeightInPixels=mapHeightInTiles*tileHeight;
jugador=新的jugador(地图,相机,280,40,地图宽度像素/20,地图高度像素/20);
System.out.println(mapWidthInTiles);//地图宽度和地图高度,地图宽度和高度
System.out.println(mapHeightInTiles);
//
//Establecemos el zoom de la cámara.0.1是塞尔卡诺1号。
宽度=((TiledMatpileLayer)map.getLayers().get(0)).getWidth();//1ºCapa锚地瓷砖宽度
高度=((TiledMatpileLayer)map.getLayers().get(0)).getHeight();//Obtenemos desde el mapa el número de tiles de alto de la 1ºCapa
系统输出打印长度(宽度);
系统输出打印LN(高度);
camera.setToOrtho(假、宽、高);//Establecemos la cámara,y le decimos cuanto tiene que ocupar.Doc:
摄像机位置x=宽度/2;
摄像机位置y=高度/2;
摄像机。位置。设置(宽度/2,高度/2,1);
MapLayers MapLayers=map.getLayers();
terrainLayer=(TiledMatpileLayer)mapLayers.get(“Suelo”);
terrainLayer2=(tiledMatpileLayer)mapLayers.get(“Cosas”);
colisiones=新的colisiones();
Colisions.checkCollision(地图,jugador);
InputMultiplexer multiplexer=新的InputMultiplexer();
多路复用器.addProcessor(新的TecladoJugador(jugador));
Gdx.input.setInputProcessor(多路复用器);
pantalla=新阶段();
pantala.setDebugAll(真);
潘塔拉·阿达卡特(朱加多);

对于(int b=0;b请尝试将您的
阶段
视口
结合使用:

正交摄影机=新正交摄影机();
照相机。设置为(假,x,y);
FitViewport=new FitViewport(x、y、摄影机);//将其更改为所需的视口
SpriteBatch批次=新SpriteBatch();
阶段s=新阶段(视口、批次);

我想我们需要查看使用您的
ShaperEnder的代码
我看不到您在哪里使用了摄像头的矩阵。您需要设置
摄像头。组合作为SpriteBatch和ShaperEnder的投影矩阵。嗨!我正在上传使用ShaperEnder的代码,谢谢您的提问!仅供参考RPG制造商的TILTSET是受版权保护的,许可证只允许他们在编辑器和游戏中使用它。@ KRythic是的!我只是使用它们,因为这是我班的一个项目,但是谢谢你们的信息!我很高兴它!考虑把它标记为有用的,让其他人知道它可以这样解决。