[Suggestion] Drop shadow behavior

Post your work in progress addons and get feedback

Post » Wed Jun 20, 2012 12:51 am

I saw that the Canvas element support rendering drop shadows, and by what it seems this includes images with transparency too.

So maybe could be possible to create a behavior that applies drop shadows to objects with parameters Offset X, Offset Y, Blur and Color.

I'm not diving into plugin development yet, so if it's feasible and anyone wants to give it a try here's my suggestion.

Probably would be harder to make it work with WebGL, but even if it's Canvas 2D only should be useful as well.
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Thu Jun 21, 2012 3:38 pm

I was looking into this (and I've just started looking at the SDK). I think the drop shadow code would have to be in the object's draw function. As far as I can tell, behaviors can't draw on the canvas. At least none of the existing ones do.

You could make a new object 'DropShadowSprite' easily enough but it seems like overkill to create a copy of the Sprite plugin just to add this effect. What do you think?

A drop shadow text plugin could be useful and text is rendered to a 2d canvas anyway. Or it's something that could be added to the built-in plugin easily enough. I wonder what @Ashley thinks of that?ramones2012-06-21 15:39:08
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Thu Jun 21, 2012 4:42 pm

@ramones is right that behaviors can't draw.

I would recommend waiting for us to add WebGL shaders - when we do it we'll also be adding a few limited effects that canvas 2D supports, like dropshadow.

A possible problem with dropshadow is in the past I've seen it cause browsers to fall back to a software rendered canvas 2D... not sure if that's fixed.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Thu Jun 21, 2012 5:29 pm

I made a drop shadow text plugin anyway.

Demo

dropshadowtext.zip
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Thu Aug 09, 2012 4:15 am

@Ashley It will be possible to put in Shadows when r100 is out?
B
17
S
4
G
4
Posts: 104
Reputation: 3,950

Post » Thu Aug 09, 2012 2:01 pm

I know I said we would add effects support for it, but on further consideration I don't think it's a good idea. A dropshadow with a heavy blur could render 5-10x slower than just using a black silhouette sprite with a blurred image which is pinned to another object. That's really a better solution.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Thu Aug 09, 2012 4:47 pm

Why not have an effect which does that for you automatically? :)
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Thu Aug 09, 2012 6:08 pm

@Ashley Yeah, but I mean dynamic shadows, realtime shadows, don't know if you get it.

I don't know if this would be possible in r100 or if this is any method to do it, really I didn't try anything right now.
B
17
S
4
G
4
Posts: 104
Reputation: 3,950

Post » Wed Nov 07, 2012 1:31 am

You can always make a main sprite, then make a grey object with a blur effect applied to it and put it behind the main sprite. That'll give you a shadow effect. That's what I'm doing for my game.
B
7
S
2
G
1
Posts: 44
Reputation: 1,415

Post » Mon Dec 30, 2013 12:39 am

how about if you want to make the dynamic drop shadows a gameplay mechanic, similar to
stealthbastard game

Whats the simplest way to achieve that in construct 2?
B
22
S
6
G
1
Posts: 269
Reputation: 2,572

Next

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests