FadeIn and FadeOut sprite or image object

How can I make an image appear smoothly and then disappear?

I solved it using the following code:
this.load.image(“bola1”,“images/bola.png”);
this.bola1.alpha = 0;
let timeline = this.tweens.createTimeline();
timeline.add({
targets: this.bola1,
alpha: 1,
x:600,
duration:100
});
timeline.add({
targets: this.bola1,
x:100,
duration:2000
});
timeline.add({
targets: this.bola1,
alpha: 0,
y:200,
duration:1000
});
timeline.play();

1 Like