Libgdx: Adding shadows to actors from a top down perspective

One of my games is viewed from the top down perspective. I wanted to add shadows to my sprites, but I didn’t want to have to incorporate Box2D or Box2D lights for such simple shadows.¬†All I wanted was a pixel perfect copy of my sprites. Here is the result:


First, to make sure that all ships are considered the same z-index and are above the shadows, I created two Groups in my stage

Then, I decided to make my shadows actually be separate actors from my ships so that they could be in the separate layers. The ShadowActors need to get at the Texture and draw coordinates of the actors they represent, so all Actors with a shadow implement this interface

I created a ShadowActor, which takes an IHaveTexture

And lastly, I made a few modifications to my ShipActor


Leave a Reply

Your email address will not be published. Required fields are marked *