一定時間後にスポーン(アクティブになる)したいゲームオブジェクトがあります。時間が経過するたびに、次のエラーが発生します。
Uncaught TypeError: Object [object global] has no method 'SpawnCounter'
私が間違っていることがわかりませんか?これは私のオブジェクトの一部です:
this.Update = function(){
//Collisions
if(this.active){
if(player.Intersects(this)){
console.debug("Player Touching Pick Up!");
if(this.type == "weapon")
player.weapon = this.subtype;
this.active = false;
}
}
else{
//THIS IS THE TIMER
setTimeout( function(){ this.SpawnCounter(); }, 2000 );
}
};
this.SpawnCounter = function(){
this.active = true;
};
これはすべて、ゲームのピックアップであり、2秒後に再び表示されます。