2012-11-10 17 views
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; 
+1

JBox2D基於Box2D引擎,它是一個物理引擎,與視覺效果無關。您必須自己在程序的主循環中繪製圖像,這種方法通常稱爲render()。 – Flawyte

+0

我建議你在你的問題中接受有用的答案,這樣你下次可能會從社區獲得更多幫助。 – Flawyte

+0

是的,我正在這樣做,其工作表示感謝 –

回答

2

JBox2D是基於Box2D的引擎,這是一個物理引擎,沒有相對的東西視覺。您必須自己在程序的主循環中繪製圖像,這種方法通常稱爲render()