Something is wrong with my canvas coding. It is not working properly. The shift() works only once. It should make the drawing disappear, but it is working normal purpose. Did I do something wrong?
<canvas id='ctx' width="500px" height="500px" style="border:1px solid red;"></canvas>
<script type="text/javascript">
//object array
car_asd=[
{x:100,y:100},
{x:105,y:100},
{x:110,y:100}
];
// end of object array
var ctx=document.getElementById("ctx").getContext("2d");
function a() {
car_asd.shift();//does not working all time
for(i=0;i<3;i++){
cars=car_asd[i];
ctx.fillRect(cars.x,cars.y,10,10);
}
}
setInterval(function(){ a() }, 10);
</script>>