JavaScript Canvas - change the opacity of image

前端 未结 2 1030
栀梦
栀梦 2020-12-10 15:32

I\'m trying to create a platform game in Canvas. I have main character and some enemies. When player touch enemy, he will lose some HP and he will be untouchable for about 3

2条回答
  •  佛祖请我去吃肉
    2020-12-10 15:46

    You can also use save and restore.

    context.save();
    context.globalAlpha = 0.5;
    .... 
    context.restore();  //this will restore canvas state
    

提交回复
热议问题