I'm making a game and I'm currently building a screen where I would have a fade in ( fade in >) and, after it's finished, I'd start another opacity transition.
The problem is when the first transition ends and the other begins, as the first transition accompanies the opacity of the other. And I'm redefining CanvasRenderingContext2D.prototype.globalAlpha
to draw with different transparency.
Example:
// Isso é memorizado em um bloco anterior
var alpha0 = 0, // A opacidade da primeira transição
alpha1 = 0; // A opacidade da outra
// ===========================================
// Enquanto o jogo executa, esse bloco executa
context.globalAlpha = alpha0;
// ...
context.globalAlpha = alpha1;
// ...
if(alpha0 < 1)
alpha0 += 0.1;
;else if(alpha1 < 1)
alpha1 += 0.1;
Because when I draw anything after defining the current opacity of the first transition and the second transition begins I see the drawing have the current opacity of the second transition.