Newbie looking for help

Hello people
I need to create a game called Portal Stacker for a project I am working on and I ran into some problems creating polygons, adding them to a body and making them rotate on the screen along with the body and I want to know if the problem is with my body/fixture settings, or with the drawn polygon and how to make it rotate. The idea is that the poly will fall and rotate. this is the code :

Code: Select all

public BouncyBall(float posX, float posY, int radius, Color color){
        this.posX = posX;
        this.posY = posY;
        this.radius = radius;
        this.color = color;
        node = create();
    }
   
private Node create(){
    final Vec2[] vertices = {
       new Vec2((float) -10, (float) 20),
       new Vec2((float) -10, (float) 0),
       new Vec2((float) 0, (float) -30),
       new Vec2((float) 10, (float) 0),
       new Vec2((float) 10, (float) 10) };
       
    //Create an UI for the poly - JavaFX code
       
       poly.getPoints().addAll(new Double[]{
         -10.0, 20.0,
         -10.0, 0.0,
         0.0, -30.0,
         10.0, 0.0,
         10.0, 10.0
        }); 
        poly.setFill(color); //set look and feel
 
        /**
         * Set poly position on JavaFX scene. We need to convert JBox2D coordinates
         * to JavaFX coordinates which are in pixels.
         */
        poly.setLayoutX(Utility.toPixelPosX(posX));
        poly.setLayoutY(Utility.toPixelPosY(posY));
       
        //Create an JBox2D body defination for the poly.
        BodyDef bd = new BodyDef();
        bd.type = BodyType.DYNAMIC;
        bd.position.set(posX, posY);
                     
        PolygonShape cs = new PolygonShape();
        cs.set(vertices, 5);
         
        // Create a fixture
        FixtureDef fd = new FixtureDef();
        fd.shape = cs;
        fd.density = 1.0f;
        //fd.friction = 0.3f;       
        //fd.restitution = 0.05f;
       
         /* Virtual invisible JBox2D body of the poly. Bodies have velocity and position.
        * Forces, torques, and impulses can be applied to these bodies.
        */
        Body body = Utility.world.createBody(bd);
        body.createFixture(fd);
        poly.setUserData(body);
       
        return poly;
}


This is how the small example looks like: http://rapidshare.com/files/3165684497/ ... allApp.jar
Notice the poly drops, bounces around a bit like it should and it looks like the body topples over, but for the life of me I can't make the drawn poly also rotate with it. Any help would be appreciated.
Thanks.

Original thread: https://box2d.org/forum/viewtopic.php?t=9312