image.onloadのクラスオブジェクトを参照する方法はありますか? this
は画像そのものを指します。テクスチャオブジェクトをどのように参照できますか?「クラス」内のオブジェクト関数の「クラス」オブジェクトを参照
https://jsfiddle.net/yL648t40/
function Texture(url){
this.image = new Image();
this.image.src = url;
this.image.onload = function(){
this.width = this.image.width;
this.height = this.image.height;
}
}
text = new Texture("http://opengameart.org/sites/default/files/styles/watermarked/public/bone2-equus_hemionus.png");
document.body.innerHTML += text.image + "<br>";
document.body.innerHTML += text.image.src + "<br>";
document.body.innerHTML += text.image.width + "<br>";
私はobiviouslyそれはあなたから自己引数を削除する必要が
'self'は' var self = ... 'として正しく宣言し、それをパラメータリストから削除すると動作します。 – Bergi