This is my function that receives an object and uses the attributes of type " function ".
FrameWork.prototype.loop = function (objectLoop) {
objectLoop.draw();
objectLoop.update();
window.requestAnimationFrame(this.loop.bind(this));
};
This is the object that I pass to the game function loop and my FrameWork FrameWork is in a separate .js file)
game.loop({
draw : function(){
game.get.Context.clearRect(0, 0, 100, 100);
game.get.Context.fillStyle = colider.color;
game.get.Context.fillRect(colider.x, colider.y, colider.width, colider.height);
game.get.Context.fillStyle = player.color;
game.get.Context.fillRect(player.x, player.y, player.width, player.height);
},
update: function () {
updateBlock();
colide();
wallCollision();
}
});
Error:
Uncaught TypeError: objectLoop.draw is not a function.