Dart で次のコードを実装したい:
var HelloWorldScene = cc.Scene.extend({
onEnter:function () {
this._super();
}
});
私の Dart 実装は次のようになります。
class HelloWorldScene {
HelloWorldScene() {
var sceneCollectionJS = new JsObject.jsify({ "onEnter": _onEnter});
context["HelloWorldScene"] = context["cc"]["Scene"].callMethod("extend", [sceneCollectionJS]);
}
void _onEnter() {
context["this"].callMethod("_super");
}
}
残念ながら、コードを実行すると次のエラーが発生します。
null オブジェクトにはメソッド「callMethod」がありません
次の行で:
context["this"].callMethod("_super", []);
context["this"] は null のように見えるので、私の質問は次のとおりです。Dart から「this」変数を参照するにはどうすればよいですか?
更新 1: 完全なサンプル コードは github にあります: https://github.com/uldall/DartCocos2dTest