P
Purple_Shy_Guy
Guest
Hello everyone, I'm working on my first project and I need some help. I wanted to make the character blink (in white) during his invincibility time after taking damage. I created a shader for it and it kinda works. The only problem is that the character becomes white during the whole invincibility time, and don't blink. I don't really know how to do it, since I'm still learning lots of things. These are the codes I'm using:
Sh_Flash
Obj_Player
Create Event
Step Event
the variable cooldown is the one I'm using to make the character invincible after taking damage, which works perfectly, so I don't think I should write its code here too, since that's not the point. But if that would help, let me know.
Draw Event
I know this code won't make the character blink, but I don't know what to add here to make it happens, and that's why I'm asking for help.
Sh_Flash
GML:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 base_color = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
base_color.rgb = vec3(1.0);
gl_FragColor = base_color;
}
Create Event
Code:
cooldown = 0;
blink = false;
Code:
if cooldown > 0 {
blink = true;
} else {
blink = false;
}
Draw Event
Code:
if (blink) {
shader_set(Sh_Flash);
draw_self();
shader_reset();
} else {
draw_self();
}