绑定函数同时绑定作用域

This commit is contained in:
郑浩乐
2016-01-01 19:43:22 +08:00
parent fce69b38fd
commit 2e51922fc1
2 changed files with 34 additions and 6 deletions

View File

@@ -58,7 +58,7 @@ function Game(id,options){
});
});
}
_events[eventType]['s'+this.stage.index+'i'+this.index] = callback;
_events[eventType]['s'+this.stage.index+'i'+this.index] = callback.bind(this); //绑定作用域
};
//布景对象构造器
var Stage = function(options){
@@ -128,7 +128,7 @@ function Game(id,options){
}
});
}
_events[eventType]['s'+this.index] = callback;
_events[eventType]['s'+this.index] = callback.bind(this); //绑定事件作用域
};
//事件坐标
this.getPosition = function(e){