How to make endless generation of objects in requestAnimationFrame?

var plane1 = new Plane();

var plane2 = new Plane();

var positionY = 0;

generationPlanes function(positionY) {
 context.clearRect(0, 0, canvas.the width of the canvas.height);

positionY++;

 plane1.initPlane(50, positionY);

 plane2.initPlane(250, positionY);

requestAnimationFrame(generationPlanes);
}

generationPlanes(positionY);


In this code, the plane that flies from top to bottom, I can't get to the planes appeared alternately every 340px along the Y-axis of the canvas, one by one, if I prescribe another plane, but with a different position on the X-axis (positionX), they just fly to equal and go beyond how to make endless generation of aircraft every 340 px with different positions along the X-axis?
June 10th 19 at 15:39
0 answer

Find more questions by tags CanvasAnimationJavaScript