Game Development Community

Making sprites flash and glow

by Andy Hawkins · in Torque Game Builder · 09/30/2006 (5:11 pm) · 2 replies

I want some of my sprites to flash or glow brighter depending on their status. So I tried doing a flash function where they toggle blending between

%obj.setBlending(true,SRC_ALPHA,ONE);

and

%obj.setBlending(false,SRC_ALPHA,ONE);

I'm assuming this turns it off.

But there was no effect. Underneath the sprites is black so maybe it's working like it should. This lead me to the conclusion that maybe changing a sprites blending mode isn't all that's required.

So when I want a sprite to glow (increasing brightness) or flash (toggle brightness) how would it be done?

I'm stuck with the set of sprites, so I thought maybe pasting a glowing sprite over the top maybe? But I'd have to do a sprite for every sprite to match the shape.

Can anyone offer some help? I mean, if I did it in Photoshop, I would multiply a brighter, gaussian blurred version of the same image over the top. I guess that's what I want to do, but I can't go and make duplicate sprites for every sprite I have.

#1
09/30/2006 (5:28 pm)
Well, just changing blending modes isn't going to do all that much - that's useful for changing how the sprite's aplha values are used. One way to do it would be to use setBlendColor. First, I would use onLevelLoaded or your datablocks or whatever to make your sprites start out at, say, .8,.8,.8, 1 (RGBA values for setblend) and then, when you want them to be bright, set the blend color to all ones. Alternatively, you could do something like have them only show the red channel with setBlendColor(1,0,0,1). That could be a cool effect.

Another easy way to do it would be to use particles. You could use a general particle effect or even use the same sprite with "use intense particles" (or whatever it's called - it's a checkbox in the emitter rollout or can be set from script). That would make a bright particle in the same shape as your character that you could put on top.

Hmmm. Another way you could do it would be to add a whole bunch of mount points or something (mount points because they're easy to add in the levelbuilder) and then, when you want the sprite to glow, put some nice circular glow particles on each one.

I don't know if any of those ideas will get you the best effect, but it would be fun playing around with it. There are lots of things to try out.
#2
09/30/2006 (6:33 pm)
Thanks Tom. I like the idea of adding a particle on the top. Then I could have a sparkle or something. I'll give it a go.