D
D
Denis Bogdanov2014-06-13 02:20:35
JavaScript
Denis Bogdanov, 2014-06-13 02:20:35

How to remove an image drawn on canvas?

Hello. I make clouds animation on canvas. I use clouds from one png image. I cut and draw each with the ctx.drawImage() method. In order for the clouds to move, I throw them into setInterval () and change the x and y coordinates in it. But faced with it. That the rendered cloud remains on the so-called. canvas, I tried to clean up the canvas with the ctx.clearRect () method, but this option is not suitable, because it is necessary to be able to overlay one cloud on another. Thanks for the answer.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Bogdanov, 2014-06-13
@den-bogdanov

The issue was resolved after a night of reflection. The fact is that I rendered each cloud separately, and accordingly deleted each cloud separately, thus it turned out that the cleared area often cleared the rest of the clouds.
I decided to draw all the clouds at the same time with one function, and the cleaning began to work as it should. Thank you.

N
Nikita Markelov, 2014-06-13
@Entii

And why can't one cloud overlap another when using screen clearing?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question