SOLVED Ball Trail Effect

Viciousse

Member
Hi Everyone,

This will be my first post in this community;

I am working in a "BreakOut" game as first project to get familar with GMS 2, and i want to add a trail effect to the my object "obj_ball" with the following methode:

I created the "obj_ball" and "obj_trail" with the code bellow:

obj_trail:
Create Event
GML:
image_speed = 0;
image_index = 1;
Step Event
GML:
if image_xscale > .1 {

    image_alpha -= .01;

    image_xscale -= .03;

    image_yscale -= .03;

} else {

    instance_destroy();

}
obj_ball:
Step Event
GML:
if (go == true){
    trail = instance_create_layer(x,y,"instances",obj_trail);
    trail.sprite_index = sprite_index;
    trail.image_speed = 0;
    trail.image_index = 1;
  
    //La ball change d'angle suivant la direction ou elle vas
    image_angle=direction;
    image_xscale=1;
    image_yscale=1;
}

else{
    x = obj_plateforme.x;
}
The issue i am facing it that the trail color is opaque, and the sprite showed in the trail effect is the ball "obj_ball"

Any advice to fix this will be much apreciated
 
Last edited:

TheouAegis

Member
The trail has the ball Sprite because you tell it to use the ball sprite_index. Note that you need to also set the trail's image_angle.

As for the opacity, my guess is it's because you have multiple trails on top of each other and the drawing is done using additive blending. Do the trails ever fade out, or do they just seem to go from 1 to 0 instantly?
 

Viciousse

Member
The trail has the ball Sprite because you tell it to use the ball sprite_index. Note that you need to also set the trail's image_angle.

As for the opacity, my guess is it's because you have multiple trails on top of each other and the drawing is done using additive blending. Do the trails ever fade out, or do they just seem to go from 1 to 0 instantly?

The trail sprite is a simple one colore circle, so i guess i dont need to set an image_angle to it, am i wrong?

Following your remarque i just made this:
GML:
if (go == true){
    trail = instance_create_layer(x,y,"instances",obj_trail);
    //trail.sprite_index = sprite_index;
    //trail.image_speed = 0;
    //trail.image_index = 1;
    
    //La ball change d'angle suivant la direction ou elle vas
    image_angle=direction;
    image_xscale=1;
    image_yscale=1;
}

else{
    x = obj_plateforme.x;
}
Now the sprite of the trail is used :)

Here is a screen shot:

2020-07-09_19-42-05.png

Now how can i add some transpacency ?
 

TheouAegis

Member
It should already be doing that. You don't have a draw event in the trail object, do you? What if you reduce the alpha by .03 instead of .01?
 
Top