I want to implement the following code in Dart:
var HelloWorldScene = cc.Scene.extend({ onEnter:function () { this._super(); } });
The implementation of My Dart is as follows:
class HelloWorldScene { HelloWorldScene() { var sceneCollectionJS = new JsObject.jsify({ "onEnter": _onEnter}); context["HelloWorldScene"] = context["cc"]["Scene"].callMethod("extend", [sceneCollectionJS]); } void _onEnter() { context["this"].callMethod("_super"); } }
Unfortunately, when I run the code, I get the following error:
The null object does not have a 'callMethod' method
in the next line:
context ["this"]. callMethod ("_ super", []);
context ["this"] seems null, so my question is: how can I refer to the "this" variable from Dart?
UPDATE 1: A complete code example can be found on github: https://github.com/uldall/DartCocos2dTest
source share