Hello I am trying to add an effect when enemies are damaged the sprite changes to a solid white for 0.1 seconds then back to the original state any ideas on how to achieve this effect?
Hi! You can try to add a counter variable to each enemy. Everytime the enemy gets damage, add a value to that counter. Each loop, if the counter is over 0, change the sprite color to white and decrease its value a bit (using TimeDelta for fixed timing)
Thanks for your reply! I don’t know any function that changes a sprite to solid white? The only way I know how to do this effect is with animation when enemy is damaged it plays “hit” animation which has 1 frame of animation for 0.1 sec then back to animation “idle” which has 3 frames but this resets the animation loop and doesn’t look right?
You can get the fame number with Sprite(), save it in a variable and set it back afterward.
Hello, there may be some confusion in the thread.
There is no native way to flash a sprite white. The Change Tint (previously known as Change Color) events treat white as “normal colors”. So you can at most tint to a dark grey, but not white.
Hi! Yes no way to change sprite to white changing the animation seems to be the way to go the only problem is I don’t know how to sync the frames of “idle” and “hit” when changing animations. Basically I want to change animations from “idle” to “hit” for 1 frame then back to “idle” again without resetting the frames every time. Do I use variables to get current frame and resume animation from last frame?
I believe you can get the current frame number of an animation by using the expression builder. I think it shows up as “Image” for sprite/animations, and the expression is ObjectName.Sprite().
You should be able to use that to say which frame to start in the new animation.
Well, it seems there hardly is any elegant solution for what you want to do.
Let me suggest a couple alternatives:
1: Flash them yellow or red, which works. I just tried yellow tint intermittent flashing on a 0.25 seconds timer on an interface elements and it’s quite noticeable.
2: Use a white frame just like you’re doing. But for the number of frames you’re using, and the minute differences between each frame, I don’t think re-syncing the animations is worthwhile from either the graphical standpoint or the performance standpoint: The frames are similar enough that the player won’t notice or care. I have used white hit frames in animations for retro games I’ve worked on in the past, and a hit animation consisting of 1-3 white frames works perfectly well without needing to sync the animations.
3: Use a white frame that is INTENTIONALLY different. Don’t just make it white, make the tentacles shoot outward stiffly, like the creature is actually in pain. Since the animation changes, again you don’t need to sync them.
I thought of another option. You can create a new layer with an adjustement effect, with contrast 0 and RGB at maximum, so everything in that layer will be drawn white. Just move the object to that layer whenever its damaged, and then move back to the base layer when finished.
layer using blend mode?
Add a “adjustment” effect to a layer clicking on the button at the right of the name of the layer:
And modify the variables as shown:
Would you be able to give an example of what the code looks like for this? I’m new to gdevelop. Thanks