Basically I have a function that I need to create an object of every time the user presses space(event listeners not shown here).
function arrow(){
this.x = playerXPos + 40;
this.y = playerYPos + 40;
this.init = function(){
var arrowImg = new Image();
arrowImg.src = "arrow.png";
c.drawImage(arrowImg,this.x,this.y);
this.x+=10;
if(this.x > 500){
keySpace = false;
}
}
}
if(keySpace){
arrowObj.init();
}
This works great, but I can only have 1 arrow on the screen at once, which is rather limiting. Is there some way to create a new object every time the if statement is true, and store it in an array or something?