1

我想做一个球,到目前为止,我已经在我的圆圈上渲染了简单的纹理,并且球没有按纹理旋转。这是我到目前为止所拥有的:

    bodyDef = new BodyDef();  
    bodyDef.type = BodyType.DynamicBody;  
    bodyDef.position.set(new Vector2(240,320));  
    body = world.createBody(bodyDef);  
    CircleShape dynamicCircle = new CircleShape();  
    dynamicCircle.setRadius(15f);  
    FixtureDef fixtureDef = new FixtureDef();  
    fixtureDef.shape = dynamicCircle;  
    fixtureDef.density = 1.0f;  
    fixtureDef.friction = 0.5f;  
    fixtureDef.restitution = 0.8f;  
    body.createFixture(fixtureDef); 
    body.applyTorque(100000000);

在渲染中我有:

    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    batch.draw(texture, body.getPosition().x,body.getPosition().y);
    batch.end();
    world.step(BOX_STEP, BOX_VELOCITY_ITERATIONS, BOX_POSITION_ITERATIONS);  

有什么想法可以让纹理旋转吗?提前致谢。

4

1 回答 1

1
 batch.draw(texture, body.getPosition().x, body.getPosition().y, width/2, height/2, width, height, /*scaleX*/1, /*scaleY*/1, /*rotation*/ body.getAngle() * MathUtils.radToDegree, srcX, srcY, srcWidth, srcHeight, /*flipX*/false, /*flipY*/false);
于 2013-07-17T13:07:57.450 回答