我正在尝试处理函数中的事件。所以它在我的gameLogic函数中为每种类型的事件做了一些事情。
不过,水龙头没被认出来。
我该怎么做?我应该将每个事件分开吗?
$(function() {
$(".main-wrapper-inner").swipe( {
//Generic swipe handler for all directions
tap:function(event, target) {
gameLogic("tap");
},
swipeLeft:function(event, distance, duration, fingerCount, fingerData) {
gameLogic("swipeLeft");
},
swipeRight:function(event, distance, duration, fingerCount, fingerData) {
gameLogic("swipeRight");
},
swipeUp:function(event, distance, duration, fingerCount, fingerData) {
gameLogic("swipeUp");
},
swipeDown:function(event, distance, duration, fingerCount, fingerData) {
gameLogic("swipeDown");
},
pinchIn:function(event, direction, distance, duration, fingerCount, pinchZoom, fingerData) {
gameLogic("pinchIn");
},
pinchOut:function(event, direction, distance, duration, fingerCount, pinchZoom, fingerData) {
gameLogic("pinchOut");
},
threshold:0,
fingers: 'all'
});
});发布于 2015-06-06 12:48:28
你可以获得滑动方向(但不是挤压方向),所以你可以减少很多代码(见下文)。
关于点击,您不能将threshold: 0设置为在内部禁用所有点击/点击事件。将threshold设置为任何大于0的值,或完全忽略它(默认为75)以使tap功能正常工作
$(function() {
$(".main-wrapper-inner").swipe( {
//Generic swipe handler for all directions
tap:function(event, target) {
gameLogic("tap");
},
swipe(event, direction) {
// You can obtain the swipe direction
// and process it in your game logic
gameLogic("swipe", direction);
}
pinchIn:function(event) {
gameLogic("pinchIn");
},
pinchOut:function(event) {
gameLogic("pinchOut");
},
threshold: 75, // This must NOT be 0 for taps to work
fingers: 'all'
});
});https://stackoverflow.com/questions/29388469
复制相似问题