我试着让mousedown函数在ios上工作但是似乎无法修复issuse。我知道问题在于下面的代码,任何帮助都会很棒!
bindInteractions: function(){
// bind interactions used during live play
this.playfield.on('mousedown','touchstart', _.throttle(_.bind(function(event){
this.fireGun();
var weaponSpread = this.player.getWeapon().getSpread();
if(weaponSpread <= 0) {
console.error("Zero spread weapons can do no damage. Recommended minimum size: 25");
}
var playfieldOffset = $(event.delegateTarget).offset();
var location = {
top: event.pageY - playfieldOffset.top,
left: event.pageX - playfieldOffset.left
};
$.each(this.liveDucks, function(i,duck){
duck.shotsFired(location, weaponSpread);
});
},this), this.player.getWeapon().getReloadTime()));
this.showLevelInfo();
},
unbindInteractions: function(){
// unbind interactions that should not be available during transitions and other non live play states
this.playfield.off('mousedown','touchstart');
$.each(this.liveDucks, function(i, duck) {
duck.unbindEvents();
});
答案 0 :(得分:0)
根据JQuery documentation关于.on()
.on(events [,selector] [,data],handler)
活动
类型:字符串一个或多个以空格分隔的事件类型和 可选的命名空间,例如&#34; click&#34;或&#34; keydown.myPlugin&#34;。
它说One or more space-separated event types
。
所以也许你的mousedown
和touchstart
应该在同一个字符串参数中:
this.playfield.on('mousedown touchstart', _.throttle(_.bind(function(event){
}