How do I grey out unseen areas of the screen?

Get help using Construct 2

Post » Wed Mar 15, 2017 8:20 pm

I have these lines in my game that rotate with the player and indicate what they can or can not see.

Image
Image

How would I make it so that everything outside of those lines is greyed out, or is slightly darker than what you are able to see, drawing more attention to that area?
I've tried using transparent sprites and a grey layer, but I'm not sure how to get it to always be the same shape as the area in-between the lines.

Thanks!
B
30
S
8
G
3
Posts: 366
Reputation: 6,302

Post » Wed Mar 15, 2017 8:34 pm

Can you give a capx? i will try something.
B
4
Posts: 10
Reputation: 220

Post » Wed Mar 15, 2017 8:37 pm

Hmmm?

You can use a mask and that would grey out areas. The mask would have to scroll with the player.

That is how we create a darkness effect.

A mask is just a sprite with some of the sprite removed that you place over the player so only areas you want the user to see are exposed as the player moves.
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Wed Mar 15, 2017 9:11 pm

@AkiraBoy https://drive.google.com/open?id=0B-FHV ... jVmT0w1aWs This link should work! (Uses the Canvas Plugin)

@lamar I tried that, but a sprite isn't dynamic enough to fill ONLY the space in-between the red lines. Plus, as it expands, the sprite gets blurrier and blurrier.
B
30
S
8
G
3
Posts: 366
Reputation: 6,302

Post » Wed Mar 15, 2017 9:29 pm

Sorry I can't give you a quick direct answer - this is a bit of an advanced technique.

Here are two resources that give very good explanations of the method though:

http://www.redblobgames.com/articles/visibility/
http://ncase.me/sight-and-light/

You'll need a way to dynamically generate the visibility mask (canvas or paster plugin), and to identify the vertices of interest. You may want to look in to a raycasting function to assist in that endeavor, although there are other ways to go about it.

https://www.scirra.com/tutorials/902/li ... raycasting

Alternatively, you might want to check out R0J0's capx in this thread, from an attempt I made a while ago to implement this without plugins: how-do-i-draw-span-class-posthilit-triangles-span_p1062997?&sid=4d47e89800c2b1c425c7024dbc64daf6#p1062997
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Wed Mar 15, 2017 9:46 pm

@oosyrag Thanks! Though that CAPX doesn't seem to be on Dropbox anymore, so I can't take a look at it.
B
30
S
8
G
3
Posts: 366
Reputation: 6,302

Post » Wed Mar 15, 2017 10:00 pm

Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Wed Mar 15, 2017 11:38 pm

@oosyrag Thanks! I experimented with it a little, and it seems that no matter what I do, it refuses to create the triangles in my game.
B
30
S
8
G
3
Posts: 366
Reputation: 6,302

Post » Wed Mar 15, 2017 11:53 pm

InvaderX wrote:@oosyrag Thanks! I experimented with it a little, and it seems that no matter what I do, it refuses to create the triangles in my game.


Does your triangle field of vision change and what is that change based on if it does?

When you say it gets blurrier are you scolling in and out on the window?
Banned User
B
23
S
6
G
58
Posts: 1,229
Reputation: 34,540

Post » Thu Mar 16, 2017 7:43 pm

B
33
S
18
G
28
Posts: 2,455
Reputation: 20,874


Return to How do I....?

Who is online

Users browsing this forum: Cha0tiXGamer, Google [Bot], ketramtu18, MaujDeveloper and 9 guests