Canvas Bouncing Balls
Just for try some canvas
animation, I've created a Pelota (ball for non-spanish speakers) object that creates a ball on a canvas and makes it bounce around it.
For solving when do I have to clear the canvas
, I've given an id
attribute to each instance of Pelota class. So each time init()
method is executed, it checks which instance is running, and if it's id
is 1
(the first object) clears the canvas
.