JürgenB: Prototype Funktion im Prototype aufrufen

Beitrag lesen

Hallo Ahmet,

var Game = function(){
setInterval(this.gameloop, 30);
}

hier zeigt this zwar noch auf Game,

Game.prototype.gameloop = function(){
this.f1(); //klappt nicht
this.f2();//klappt nicht
this.f3();//klappt nicht
}

hier aber nicht mehr, da setInterval unter window läuft.

versuch mal

var Game = function(){
    var dieses = this;
    window.setInterval(function() { dieses.gameloop() }, 30);
}

Gruß, Jürgen