so I’m trying to have shadows below my wall blocks (which are destructable) in my top down roguelike type game https://flowlab.io/game/play/1416959 and because they are destructable, i can"t just place a shadow underneath, as when the block is destroyed, the shadow will stay. so I’ve been using an emmiter to emit the shadow underneath, and stop emmiting when the block is destroyed, but the first probem with this is that if the shadow is 50% alpha (where i want it) it will keep flashing between the opacity, and second problem is that it lags the game a lot. anyone know a better way to do this?
You could try this:
- Add your walls to the level
- Add your shadows to the level too
- When your wall gets destroyed, it extracts it’s x and x value and sends it in a message to all shadows like this:
Game Width * wall y + wall x
- Your shadows should check that against thier own position like so:
Game Width * (wall y - 32) + wall x
Where you subtract 32 if the shadow is below the wall, or add 32 if the shadow is above it.
- If the values match, then destroy the shadow
Here’s an example - click the wall to destroy it, and the cap and shadow will disappear as well:
That’s a really good way but wouldn’t attaching a shadow object work?
What am I missing?
@PixelPizza i actually didn’t think of that. that works awesome thanks! what grazer said I’m sure works really great but I don’t really understand how the Expressions work just yet so attaching a shadow works better for me.
Heh, attaching the shadow would work - I assumed that they needed to be on separate render layers for some reason. I guess my assumptions were overcomplicating things.
If they can be attached - just make them all one sprite, no attachment needed