Possible to cut off a gradient light?

0 favourites
  • 9 posts
From the Asset Store
Help this cute Monster to cut and release the candy.
  • I'm exploring lighting systems in construct 2, which are a little less than I would hope for. But right now I've got a fog layer with black square as the darkness, and a destination out gradient acting as the gun light. The problem is it shines through everything, So I want to know if there is a way to block this light or another method of doing this entirely. Thanks!

  • You could try ray casting but it adds quite a bit of overhead.

  • You can absolutely block it. This example isn't exactly what you're trying to do, but it has the principles that will show you how.

    Lantern Example

    EDIT:

    Alright, I modified it quickly to do a true flashlight. I made it to work with layers that aren't necessarily 100% dark (they're translucent) so it can fit more applications.

    Flashlight Example

    Just so you know, it's important that the flashlight sprite is at the bottom of the layer (under the shadow objects) for this to work.

    And here's it running in a browser so you can preview the effect: Flashlight Demo (arrows keys to move, mouse to aim the light)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • C-7 Awesome, thanks so much! I didn't know shadowlight would work with destination out systems.

  • C-7's example is awesome - but it might be more advanced than what you need (and more cpu costly than you want). (or maybe it is just my very slow work computer, lol)

    You may be able to do it the way you started above, but just isolate the light and fog area of the current room on a separate layer. Then that wont affect fog outside the current room (on a different layer)...

    Nice thing about C2 is you can have LOTS of layers!

  • C-7's example is awesome - but it might be more advanced than what you need (and more cpu costly than you want). (or maybe it is just my very slow work computer, lol)

    You may be able to do it the way you started above, but just isolate the light and fog area of the current room on a separate layer. Then that wont affect fog outside the current room (on a different layer)...

    Nice thing about C2 is you can have LOTS of layers!

    I kinda had a system like that but it would be clunky when you move from each room, one goes dark and the other whole room appears. Though, now I'm getting a weird glitch where if you shine up at the roof, it will go through like halfway in some places.

    https://dl.dropboxusercontent.com/u/441 ... index.html

  • That just looks like you have something set up wrong (if it works everywhere else, it should work anywhere). Put an event in that sets your flashlight object to the back of the layer just to make sure it's never anywhere else no matter what you do in C2. I mean, I can get light show "show through" further on up if the light object overlaps the shadow boundary, but that shouldn't matter in your game's case.

    If you're looking for an alternative, I wouldn't jump things around layers--that sounds like it'll come back to haunt you later. I suppose you could always place a black tiled background on the floor above (and below depending) that stays locked there until you switch levels to hide anything.

  • That just looks like you have something set up wrong (if it works everywhere else, it should work anywhere). Put an event in that sets your flashlight object to the back of the layer just to make sure it's never anywhere else no matter what you do in C2. I mean, I can get light show "show through" further on up if the light object overlaps the shadow boundary, but that shouldn't matter in your game's case.

    If you're looking for an alternative, I wouldn't jump things around layers--that sounds like it'll come back to haunt you later. I suppose you could always place a black tiled background on the floor above (and below depending) that stays locked there until you switch levels to hide anything.

    It's definitely staying behind them, I'm using other invisible objects to control lighting. Maybe it is overlapping the shadow boundary is there a way to control that?

  • It only overlaps if your light source gets right up on the wall and crosses into it (your light source should be right at or near your player). I'm not sure how to fix your specific problem--I can't make it happen in my own tests. I'd definitely be willing to glance through your capx if you're willing to PM it to me, but it's tough to tell from here.

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