Making an enemy flash when hit

12 posts

Flag Post

Back when I was learning the basics in Stencyl I would just use the adjust brightness block to make the enemy brighter for a split-second. I have yet to find a similar solution for as3. Any help would be greatly appreciated.

Flag Post

Go look up the AS3 version of the Shootorials. The use an “on-player-hit → wiggle” code but the same method is adaptable to use on enemies and for flashing.

Flag Post

I already knew how to detect if the enemy was being hit, so the shootorial didn’t help much. I ended up finding this tutorial , which taught me how to change the RGB values of a movieclip. Making the values higher gave it a sense of being brighter.

Flag Post
Originally posted by Gharrot:

I already knew how to detect if the enemy was being hit

I was specifically referring to some code that runs because the player is hit, not how to detect it.

Flag Post

Could you not just make a new object of your object > break you object apart > put it in a movieclip > make the pixels in it white > make a shape tween going from max alpha to 0 alpha over like 10 frames and then place it on top of you object that was hit. If you start the new movieclips alpha at 0 and begin it at frame 10 then whenever you are hit make the object go to frame 1. So the animation of the white will be fully visible and the fade animation will begin again.

Hope that made sense.

Flag Post

WTF? That’s like the least useful thing to do.

Flag Post

Depends if they are all the same. If it is just one object that you need this for, using a MovieClip would be fairly easy but if you need it for many more or need a dynamic way to do it, you best look for something else.

One way to have the effect would be to just add a filter or something to the MovieClip and remove it after a couple of frames.
thing.filters=[new GlowFilter()] edit the parameters of the filter though.

But I don’t know how performance or resource intensive that is though. There probably is a lighter solution.

Flag Post

If you’re using adobe flash, you could animate it yourself.
Or even if you’re not, you still could I just don’t know how to go about it.
But I believe that you can download and integrate something with flash develop if I remember correctly. Or maybe not and you just use an editor separately.
Either way its not a big deal.

But if you’re seeking to do it programmically…
google “as3 tint”

and I don’t believe theres any more efficient ways of doing this without using Timers.
So google “as3 timers” as well.

Flag Post

You may not need timers or intervals if it is only supposed to last for a small length of time. If you have lots of moving objects all of the same class and are updating them every frame, you could just add a section to the update code to say something like


You make an int instead which is decremented every frame and then checked if 0 if you want it to last more than 1 frame.

Also, fl.motion.Color or ColorTransform ways to change colour

Flag Post
Originally posted by feartehstickman:

say something like

Congradulations on posting the exact code I told him to go find in the Shootorials.

And yes, I spelled “congradulations” wrong on purpose.

Flag Post

Not sure what is going on…

Flag Post

I solved the problem on my own, thought I said that in the third post. I already knew how I was going to code it, I just needed to know how to change the brightness of a movieclip. I ended up just increasing the RGB values by 140.