現在、createjs フレームワークを使用して JavaScript で作成しているゲームのシーン構造を作成しています。私が直面している問題は、プロトタイプ関数で元のクラスを適切に参照することです。私はJavaScriptに比較的慣れていませんが、プロトタイプを使用する必要があったのはこれが初めてです。私の現在のコードは次のとおりです。
function Intro(p, c){
this.parent = p;
var s = new createjs.Stage(c);
this.stage = s;
this.queue = new createjs.LoadQueue(false);
this.queue.installPlugin(createjs.Sound);
this.queue.addEventListener("complete", this.handleComplete);
this.queue.loadManifest([{id:"bg", src:"images/Intro/intro_background.png"}]);
}
Intro.prototype.handleComplete = function(event){
console.log("queue completed - handling...");
var q = event.target;
var bg = new createjs.Bitmap(q.getResult("bg"));
this.stage.addChild(bg);
this.stage.update();
}
たどり着いたら
this.stage.addChild(bg);
スコープが失われているようで、「undefined のメソッド 'addChild' を呼び出せません。
どんな助けでも大歓迎です!-xv