先使用UI中的函数UI.setPlayMenuButton_Play(this.playMenuB_play);
设置函数函数如下:
setPlayMenuButton_Play:function(callfunc){
var button=ccui.helper.seekWidgetByName(this.playMenu.node,“playstory”);
button.addTouchEventListener(function(s,t){
if(t==ccui.Widget.TOUCH_ENDED){
callfunc();
}
},this);
},
跳转的函数:
playMenuB_play:function(){
if(this.wordsArr[this.nowWordIndex][2]){
PlayEffect(this.wordsArr[this.nowWordIndex][2]);
}
},
但当运行到跳转函数时,this.wordsArr的this指向了window,并非原来的layer,这个应该如何解决呢?
顶一下顶一下
试试改成UI.setPlayMenuButton_Play(this.playMenuB_play.bind(this));
var self = this;
试一下