Loss of conciousness effect (Solved)

Started by Ethan D, Sun 25/10/2009 21:23:07

Previous topic - Next topic

Ethan D

Alright,  I'm trying to figure out how to create a certain effect.  The effect is that a character is slowly losing conciousness.  I know that I could do a fade out and have it be slow but I would rather have it fade out a little bit then reverse then fade out more then reverse a little then finally fade to black.  I don't think there are any commands that can do anything like this though.  Any ideas?

Edit: I'm sure this would be possible if I could somehow make fadein and fadeout nonblocking scripts.....

Crimson Wizard

I think you can use tints.

Quote
Region.Tint(int red, int green, int blue, int amount)

Changes the region to have RGB tint (RED, GREEN, BLUE).
The red, green and blue values are between 0 and 255, and you supply the same values that you would use in the editor.

AMOUNT determines the extent of the tinting, and is from 1 to 100, reflecting a percentage figure. 100% will completely colourize characters in that area to the specified colour.




tzachs

Take a look at the tween module, it can make the job easier...

Ethan D

Wow, that looks like a nice module.  I wish I had known about it before I scripted fading in and out for eight different objects... oh well... 

Tint screen:

I don't think this one would get quite the right effect... I suppose I should have explained more.  It would be nice to be able to get the same fadeout that it does normally (Fading out from the edges inward.)  Tint screen would work I suppose but I don't think it would look that good.

Tween:

I don't see how the tween module (as useful as it looks) could apply to this problem unless if I missed a way that it can make fading out non blocking


TerranRich

I would just use an all-black object the same size as your room, and fade that in and out (fade it in for the fade-out effect, and vice versa). That's how I'm doing it in my game. Especially using the Tween module. :)
Status: Trying to come up with some ideas...

Ethan D

#5
Quote from: TerranRich on Sun 25/10/2009 23:54:02
I would just use an all-black object the same size as your room, and fade that in and out (fade it in for the fade-out effect, and vice versa). That's how I'm doing it in my game. Especially using the Tween module. :)

Except when fading in and out objects by changing the transparancy value you get a blanket effect over the whole screen, I'm not entirely opposed to doing this but I would prefer to have the effect from from the outside of the screen inward.  Although, from the looks of it I may have to use an object as you said.

Still, does anybody know of a way to make something that is naturally a blocking script into a non blocking script.  

BTW: I am sorry, if it seems I am being picky... which I suppose I am.  I'm just going for a very specific effect.

Ethan D


TerranRich

Why did you change the entire topic title to "Solved"? You should leave the title there for other people to see your topic if they may have a similar problem.
Status: Trying to come up with some ideas...

Ethan D


Scarab

So... did you end up finding a way to do it, or did you just go with the compromise above?

Scarab

Ethan D

Yeah, I suppose I should have mentioned it.  I went ahead and compromised, I'm don't think there is a way to change a prescripted function.

Charity

Quote from: Ethan Damschroder on Mon 26/10/2009 11:08:55
Yeah, I suppose I should have mentioned it.  I went ahead and compromised, I'm don't think there is a way to change a prescripted function.

What about a two phased thing?  Gradually fade in a screensized sprite with with a gradient of transparency, so that the edges are more opaque and the center is less opaque.  AGS can do that, right?  Then once that has faded in all the way, use an all black sprite or the tint function to uniformly fade to black.  The combined effect should be the screen gradually darkening from the sides first and then closing in on the center, until the screen is completely black.

Ethan D

I'm not sure if AGS can change the transparancy of an object at different areas of the object itself but I think I have a solution that should work just fine.  I'm going to go ahead and use four objects for losing consciousness that I will fade in one after the other and fade out one after the other to get the effect, If done right it should work perfectly. 

This is a little bit more complicated than I had hoped it would be but oh well   :)

Charity

#13
What I meant was fade in a pre-made sprite like this

And then fade a black object in on top of it to complete the effect.  But if you've got something that works go with that.

But now you've got me wondering if AGS could generate an image like that.  I think you could do it with dynamic sprites, but it might take a while to process.  I haven't really messed with those functions to see how they handle opacity, though, so it might not be possible?

TerranRich

In the image above, keep in mind that the lighter areas are transparency, and not actual color. So that the background shows through. Fade that in, then fade the black in over it. Ooh, I wonder how that would look. Somebody should give it a try.
Status: Trying to come up with some ideas...

Charity

Heh.  Just gave it a try.  It works like I thought it would, but the gradient is too big and gradual.  The end result is a really nice fade to black, but it isn't sharp enough to give that darkness closing in effect.  The most appealing unconsciousness-like effect I managed was when I tweened in four different instances of the gradient sprite consecutively, and simultaneously tweened in the solid  black image.  So the whole screen gets darker all at once, but the edges get darker much faster, so you get both the "closing in" feeling and the "shit things are getting darker" feeling at the same time.  The only problem is I end up with an artifact.  A single white pixel in the center of the screen.  I'm not sure what's up with that, but I think it has something to do with the gradient sprite, and the pure transparent spot in the middle.  Probably could hide it by messing with z-order and putting the all black GUI on top anyway.

The only other problem I can think of is that if you have five simultaneous GUIs, four of which display instances of a fairly complex, screen sized sprite, it might cause some nasty slowdown on some machines.

Still, the effect was really neat.

TerranRich

Don't use GUIs, use objects instead. Shouldn't be a problem. And if there's a single white pixel in the middle (which makes sense as that's the only spot on the PNG where it's pure 100% transparency), just use a tiny black object in the middle to cover it up. No need for a huge 320x240 black image for one pixel. :)
Status: Trying to come up with some ideas...

Snarky

Instead of four copies of the same sprite on top of each other, duplicate it on several layers in Photoshop and merge them together into one image.

The only problem is banding in the dark regions, so it's probably best to merge only two copies, and still use two of the resulting sprites in-game.

Charity

Quote from: Snarky on Fri 30/10/2009 16:41:42
Instead of four copies of the same sprite on top of each other, duplicate it on several layers in Photoshop and merge them together into one image.

The only problem is banding in the dark regions, so it's probably best to merge only two copies, and still use two of the resulting sprites in-game.

Yeah, doubling up the sprite in the paint program turns the outer regions solid black, making the fade-in less seamless, though it isn't super noticeable.   

I messed with it some more and didn't notice any slow down, but there wasn't a lot else going on, since it was just a simple test game, and my machine, though a laptop, is relatively new and fast.  In a more complex game on an older computer, I have no idea.

The only thing with using an object or character is you have to worry about positioning it, especially if the game has scrolling rooms, but that's still fairly simple scripting.  Is that definitely faster than GUIs?  Also what about graphical overlays?  Can they be added to the tween module and are they more or less efficient than GUIs and/or objects?

At any rate, the method should work (with some tweaking), and it isn't too difficult to implement, which is good to know.

SMF spam blocked by CleanTalk