[JS] conflitto funzione
Inviato: lunedì 26 maggio 2014, 19:47
Salve, ho questo codice .. mi dite perché non posso fare questo metodo:
e chiamare :
mi segnala questo errore nella funzione init(); del mio gioco:
mi segnala:
Uncaught TypeError: undefined is not a function
come posso fare?
grazie mille e buona settimana.
Codice: Seleziona tutto
var f;
var context;
function f()
{
this.setCanvasInit = function()
{
f = document.getElementById("game");
context = f.getContext("2d");
}
this.setCanvasBackground = function(color) {
document.getElementById("game").style.background = color;
}
};
var f = new f();Codice: Seleziona tutto
f.addEventListener('click', function(){ screen = 1}, false);Codice: Seleziona tutto
function init()
{
f.setCanvasInit(); <-- prima funzione che carica body=onload init();
f.run(1000/20);
}Uncaught TypeError: undefined is not a function
come posso fare?
grazie mille e buona settimana.