0

I have a sprite which is ball. Let's say, it represents a glass ball.

I am rendering the graphics with SpriteBatch.

Is it possible in libgdx to have a breaking glass effect for the ball? Meaning, I want to split the sprite to different pieces with abnormal borders (not rectangular) and then draw them flying to different directions.

2
  • No, either do this via an animation or you have to replace the ball with several small sprites and let those move in different directions.
    – noone
    Apr 20, 2014 at 11:10
  • what about masking? Is it possible to apply say 10 different masks for each to have the different piece?
    – Genry
    Apr 20, 2014 at 12:09

1 Answer 1

1

Use a PolygonSprite to represent the non-rectangular chunks of your sprite.

To generate the chunks, I suggest picking a random spot near the center of your sprite, and then creating several triangles from that point to the corners and 2 or 3 points on each side of the square sprite. You should be able to define a PolygonRegion for each shard, and use that to build PolygonSprite instances.

I haven't actually used the PolygonRegion API before (and it looks a bit obtuse), so you might want to check the examples.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.