How do I mask a layer?

0 favourites
  • 3 posts
  • Hello everyone,

    I've been trying to figure out this problem for a while now and I can't find any solution to it.

    I'm making an endless runner that's based on silhouettes. For the background, I've made some terrain sprites that are basically gradients, so the amount of black won't be too overbearing. What I'd like to do (and starting to think isn't possible at all) is for the sun to not be visible through the terrain, like it is now:

    I've tried to do this the way I've seen some people do alpha masks for lighting, but it didn't work at all...Any ideas?

    EDIT: Attached example .capx: [attachment=0:2pel9qyf][/attachment:2pel9qyf]

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • One obvious workaround would be to make your background sprites fully opaque (you'll have to "bake" the gradient in to them) and put the sun and the moon sprites on a Layer behind the BG layer/Objects. Of Course, the way you have it now provides the opportunity to blend the the BG sprites with the BG sky color, like an atmospheric haze and you will lose that ability...

    I am also interested in ways to do masking, I am forced to believe that there isn't an easy or effective way to do it in HTML5. And yes, I've seen the blend modes template, for the love of god, I can't replicate anything useful from that.

    Masking should work like clipping layers in Photoshop or, even better, as within After Effects and have the ability to exist from object level (use a sprite to mask on other sprite(s)), to layer level (use a layer to mask other layer(s)).

  • At first I dismissed your comment since I had tried making them fully opaque before, and the player character was indistinguishable, since everything was black.

    But your comment did give me the idea of adding the atmospheric haze as separate sprites that change opacity depending on what time of day it is (just like the background does). And, since I messed with the opacity formulas a little bit, it actually made the sunrise and the sunset look a lot better, so thank you very much for the suggestion!

    So, yeah, masking seems to be a bit tricky at the moment, so I'm just going to rely on good old opacity. I do hope some more in-depth functionality gets added soon.

    Cheers!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)