0
我想讓圖像在jbox2d中移動而不是幾何形狀。 我看不到圖像。使用Jbox2d中的圖像(java)
BodyDef bodyDef =new BodyDef();
bodyDef.position.set(100,100);
bodyDef.type=BodyType.DYNAMIC;
//texture=TextureLoader.getTexture("PNG",ResourceLoader.getResourceAsStream("resources/small.png"));
BufferedImage img = null;
try {
img = ImageIO.read(new File("resources/small.png"));
} catch (IOException e) {
}
bodyDef.userData=img;
JBox2D基於Box2D引擎,它是一個物理引擎,與視覺效果無關。您必須自己在程序的主循環中繪製圖像,這種方法通常稱爲render()。 – Flawyte
我建議你在你的問題中接受有用的答案,這樣你下次可能會從社區獲得更多幫助。 – Flawyte
是的,我正在這樣做,其工作表示感謝 –