在回调函数类访问 本类的对象或函数,均报错,如下面的代码 28、29行,应该怎么修改呢?
var UI_Load = cc.Layer.extend({
root:null,
img_load:null,
_listener1: null,
ctor:function () {
this._super();
var mainNode = new cc.Node();
mainNode.attr({anchorX: 0, anchorY: 0, scale: 1, x: 0, y: 0});
mainNode.setTag(1000);
this.addChild(mainNode);
root = ccs.load("res/UI_Load.json").node;
mainNode.addChild(root);
this.init();
},
init:function () {
this._listener1 = cc.EventListener.create({
event: cc.EventListener.CUSTOM,
eventName: "game_custom_event1",
callback: function(event){
cc.log("Custom event 1 received, " + event.getUserData());
cc.log("root.x="+root.x);// 报错:Error: js_cocos2dx_Node_getPositionX : Invalid Native Object
this.showLoad(); //报错:TypeError: this.showLoad is not a function
// mainNode.attr({anchorX: 0, anchorY: 0, scale: 1, x: 0, y: 0});
// var node = this.getChildByTag(1000);
// cc.log("bbbb="+node.y);
}
});
cc.eventManager.addListener(this._listener1, 1);
},
showLoad:function () {
// mainNode.attr({anchorX: 0, anchorY: 0, scale: 1, x: 0, y: 0});
// img_load = ccui.helper.seekWidgetByName(root, "img_load");
// var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
// img_load.runAction(repeat);
},
});