GEuser's CUSTOMIZABLE GUI LIBRARY: Flashing Actors

BASIC INFORMATION



Uses trigonometry function sin() to vary transparency of an actor to create a flashing effect.
The trig. method creates a more smooth transition between flashing phases.
TO USE:
Step 1.. create an ACTOR VARIABLE: flashValue
Step 2. Copy / paste the Global code below into Global Code Editor (add as: flashActor)
( Script=>Global code => Global Code Editor =>[add] )
Step 3. set flashValue to 0 in your CREATE ACTOR EVENT, like this:
CALL this function from your DRAW ACTOR EVENT like this:
You should now be-able to flash any actor (canvas, text or normal) by simplying calling from it's draw event.
FIND GLOBAL CODES BELOW (with & without comments).
Global Code WITH comments
Global Code WITHOUT comments



Uses trigonometry function sin() to vary transparency of an actor to create a flashing effect.
The trig. method creates a more smooth transition between flashing phases.
TO USE:
Step 1.. create an ACTOR VARIABLE: flashValue
Step 2. Copy / paste the Global code below into Global Code Editor (add as: flashActor)
( Script=>Global code => Global Code Editor =>[add] )
Step 3. set flashValue to 0 in your CREATE ACTOR EVENT, like this:
- Code: Select all
flashValue = 0;
CALL this function from your DRAW ACTOR EVENT like this:
- Code: Select all
flashActor(20);
You should now be-able to flash any actor (canvas, text or normal) by simplying calling from it's draw event.
FIND GLOBAL CODES BELOW (with & without comments).
Global Code WITH comments
- Code: Select all
// FLASHES ACTORS using the alpha value with trigonometry function sin
// works with text, canvas and normal actors.
//
// step 1. create an ACTOR VARIABLE: flashValue
//
// step 2. Add this code to your Global Code Editor as: flashActor
//
// step 3. set flashValue to 0 in your CREATE ACTOR EVENT, like this:
//
// flashValue = 0;
//
// CALL this function from your DRAW ACTOR EVENT like this:
//
// flashActor(20);
//
// The number is the flash rate or delay, change it to suit your needs. Have fun :)
//
void flashActor ( int flashFrequency)
{
double tempVal=0; // temp value to hold calculated flash rate
flashValue+=1; // Increment degrees (used for sinewave)
if (flashValue>359) // Has 360 been reached (a full cycle)?
{
flashValue=0; // if yes reset to start of 0 degrees
}
// calculate new flashing with sinewave at 'flashFrequency' rate
// you could use cosine too (or another formula, play around with other trig. funcs)
//
// Watch out for Tan (Tangent, has infinity values at 90 & 270 degrees may cause crash).
tempVal=sin(degtorad(flashValue*flashFrequency));
// store temp value in calling actor's transparency variable
transp=tempVal;
}
Global Code WITHOUT comments
- Code: Select all
void flashActor ( int flashFrequency)
{
double tempVal=0;
flashValue+=1;
if (flashValue>359)
{
flashValue=0;
}
tempVal=sin(degtorad(flashValue*flashFrequency));
transp=tempVal;
}