Answer the question
In order to leave comments, you need to log in
How to change the transparency of the canvas part?
Hello. I place part of the image on canvase. At the same time, I want it not to be inserted immediately, but to appear gradually.
ctxBuildings.clearRect(build.x * tileWidth, build.y * tileHeight, 25, 25); // зачищаю место куда буду вставлять
ctxBuildings.globalAlpha = build.opacity; // изменяю на прозрачность 0.2 по умолчанию для каждого объекта build
ctxBuildings.drawImage(tiles, (build.type - 1) * tileWidth, tileWidth, tileWidth, tileWidth, build.x * tileWidth, build.y * tileHeight, 25, 25); // вставляю изображение
build.opacity += 0.1;
ctxBuildings.globalAlpha = 1; // меняю прозрачность на 1
Answer the question
In order to leave comments, you need to log in
or google, or here: https://professorweb.ru/my/html/html5/level4/4_2.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question