有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

使用Jbox2d(java)中的图像

我试图使图像移动,而不是jbox2d中的几何形状。 我看不到图像

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) 个答案

  1. # 1 楼答案

    JBox2D基于Box2D引擎,这是一个物理引擎,与视觉无关。你必须自己在程序的主循环中绘制图像,这种方法通常被称为render()