Hi guys, I'm struggling to think of how to get this to work. I have a top-down space shooter game, and I want the ship to cast a shadow when over some surfaces - but not all.
The look I want is when the ship is moving over an asteroid, there should be a shadow, but when out in open space the shadow should be gone.
Any ideas? Perhaps I could do this with some sort of masking?
You can create an additional layer between the ship and asteroid. Create a shadow sprite (70% or so opacity) and pin it to the ship.
At beginning of layout -> [shadow sprite] is not visible
[shadow sprite] on collision with [asteroids] -> [shadow sprite is visible]
You can also use blend modes (assuming that your space background and the shadow are both black).
Develop games in your browser. Powerful, performant & highly capable.
You can actually use blend modes without needing your space background to be entirely black.
here's a quick example I made. The asteroids and shadow are all on the 'shadowing' layer (with 'force own texture' set 'on'), and the shadow has a blend mode of 'source atop'.
Woah that's so simple, I would never have thought of using a blend mode for this. Thanks Sqiddster!