これがcocos2d-jsスワイプでの私の解決策です
var cambaglayer = cc.Layer.extend({
ctor:function () {
this._super();
var size = cc.winSize;
touchCounter = 0;
if( true || 'touches' in cc.sys.capabilities ) {
cc.eventManager.addListener(cc.EventListener.create({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
onTouchesBegan: function(touches, event) {
console.log("onTouchesBegan!");
touchMenu();
var touch = touches[0];
var loc = touch.getLocation();
this.touchStartPoint = {
x: loc.x,
y: loc.y
};
this.touchLastPoint = {
x: loc.x,
y: loc.y
};
},
onTouchesMoved: function(touches, event) {
var touch = touches[0];
var loc = touch.getLocation(),
start = this.touchStartPoint;
console.log("onTouchesMoved!");
console.log("onTouchesMoved!"+ touchThreshold);
if( loc.x < start.x - touchThreshold ) {
console.log("left!");
if( loc.x > this.touchLastPoint.x ) {
start = this.touchStartPoint = {
x: loc.x,
y: loc.y
};
this.isSwipeLeft = false;
} else {
this.isSwipeLeft = true;
cc.log("swiping left side")
}
}
if( loc.x > start.x + touchThreshold ) {
console.log("right!");
if( loc.x < this.touchLastPoint.x ) {
this.touchStartPoint = {
x: loc.x,
y: loc.y
};
this.isSwipeRight = false;
} else {
this.isSwipeRight = true;
console.log("Swiping Right side");
}
}
this.touchLastPoint = {
x: loc.x,
y: loc.y
};
},
}
), this);
} else {
cc.log("TOUCH_ALL_AT_ONCE is not supported");
}
return true;
}
});