简体   繁体   English

如何在Slick2D中使用JBox2D调试绘图?

[英]How to use JBox2D debug-draw in Slick2D?

JBox2D , the Java port of the Box2D physics engine, features an extensible module for creating debug drawing of shapes. JBox2D是Box2D物理引擎的Java端口,它具有一个可扩展的模块,用于创建形状的调试图。 How can I use this with the Slick2D game library? 如何在Slick2D游戏库中使用它?

Using the JBox2D DebugDraw class for Slick2D it is simple to add debug drawing. 通过将JBox2D DebugDraw类用于Slick2D,可以很容易地添加调试图。 Put the below code in your init method: 将以下代码放入您的init方法中:

Slick2DJBox2DDebugDraw debugDraw = new Slick2DJBox2DDebugDraw(gameContainer);
debugDraw.setFlags(DebugDraw.e_shapeBit);
world.setDebugDraw(debugDraw); // Where world is your JBox2D world

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

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