1. How make actor blink without making additional animation frames ?
2. How make text actor blink? Text actors can not have animation at all...
Well, it's simple. First, let's see how to play with transparency.
All you have to do is to insert following code into actors "Draw Actor" function
- Code: Select all
double Base; // base value of transparency, between 0..1
int Frequency; // Frequency of blinking, must be >1
double Amplitude; // how much trancparency will change.
// of cause you can declare these variables in global code instead of local procedure
// Normally:
// Base+Amplitude<=1
// Base-Amplitude>=0
Base=0.5;
Frequency=8;
Amplitude=0.5;
transp=1-(Base+cos(degtorad(frame)*Frequency)*Amplitude);
Actor will blink.
As you can see, all based on cos function. Changing Base, Frequency, Amplitude values you can adjust your actor's blinking.
Note, that
- Code: Select all
transp=1-(Base+cos(degtorad(frame)*Frequency)*Amplitude)
Code
- Code: Select all
transp=Base+cos(degtorad(frame)*Frequency)*Amplitude;
The second case is "color-changing" blinking. In this case we have to work with r,g,b values of actor. Insert into "Draw Actor" function next code:
- Code: Select all
int Base_R,Base_G,Base_B; // base value of transparency, between 0..255
int Frequency_R,Frequency_G,Frequency_B; // Frequency of blinking, must be >1
int Amplitude_R,Amplitude_G,Amplitude_B; // how much value will change.
// Normally:
// Base+Amplitude<=255
// Base-Amplitude>=0
Base_R=128;
Base_G=128;
Base_B=128;
Frequency_R=16;
Frequency_G=16;
Frequency_B=16;
Amplitude_R=128;
Amplitude_G=128;
Amplitude_B=128;
r=Base_R+cos(degtorad(frame)*Frequency_R)*Amplitude_R;
g=Base_G+cos(degtorad(frame)*Frequency_G)*Amplitude_G;
b=Base_B+cos(degtorad(frame)*Frequency_B)*Amplitude_B;
Actor will fade to black and return to normal condition again and again.
Changing initial values of variables will help you to get different effects
Have fun !
