View Full Version : Game Maker: Fading in and out sprite


iTom
07-14-2006, 07:02 PM
With Game Maker sometimes you want to create nice effects, one of them fading in and out. This is a registered trick ONLY. Registration costs $20, and is REALLY worth it. Trust me, it's really cool :)

Anyway, onto the tutorial. Sprite fading in and out requires use of the varible named image_alpha but, there is a catch. image_alpha can only have a value between 0 and 1 (or anything between), it is not 0-255 or 0-1000. However, this means we only have to use small values.

Here's the code we'll use, place this in the STEP event:

amount_per_step_forward = 0.01;
amount_per_step_backward = -0.01;

if(image_alpha>0 && image_alpha<1) {
image_alpha+=amount_per_step_forward;
} else {
image_alpha+=amount_per_step_backward;
}


There you have it, a fading sprite! You might want to configure the varibles, though.