0

I am flipping one of the object in my libGDX project. At the same time I want to flip its shape rendering circle also. How can I do it? here is my code for shaperenderer:

    shapeRenderer.setProjectionMatrix(camera.projection);
    shapeRenderer.setTransformMatrix(camera.view);
    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
   if (obsObj.isSpider())
            circle(shapeRenderer, ob.getCollisionCircle());
shapeRenderer.end();

and circle method is:

private void circle(ShapeRenderer renderer, Circle circle) {
    shapeRenderer.circle(circle.x, circle.y, circle.radius, 100);
}

I am flipping sprite object like this..

obsSprite.setFlip(true,false);
Niranjana
  • 514
  • 5
  • 23
  • Without a bit of explanatory code it will be hard to answer this... How exactly are you flipping the object and how are you drawing it with the ShapeRenderer? You have different ways of solving, either by manually also flipping the values used in the ShapeRenderer or if applicable you could even flip the whole ShapeRenderer by manipulating the matrices it uses. – florianbaethge Dec 14 '16 at 13:04
  • Code included in the question.Thank you. – Niranjana Dec 15 '16 at 04:43

2 Answers2

0

Instead of using circle/Rectangle shape rendering,I tried shape rendering with polygons. It worked well for rotation and flipping.

Niranjana
  • 514
  • 5
  • 23
0

You can use transform matrix like this :

shapeRenderer.setProjectionMatrix(camera.combined);
shapeRenderer.setTransformMatrix(...your transformation matrix...);

camera.combined contains both camera projection and view. your transformation matrix might be scaling matrix in your case (scaleX = -1 for horizontal flipping and/or scaleY = -1 for vertical flipping)

mgsx-dev
  • 440
  • 3
  • 5