大家好,我想監聽到當我的手指經過一個node的動作,就好像botton Hover或滑鼠的MOUSE_ENTER一樣,請問如果做到
触摸屏只有点击和未点击,没有enter或者hover效果,如果你只是想获取手指经过node的位置,监听touchmove事件自己判断手指移动的坐标
thz SHIELD
nodeListener: function(){
var self = this;
var canvas = cc.find("Canvas");
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
onTouchBegan: function(touch, event) {
var location = canvas.convertToNodeSpaceAR( touch.getLocation() );
for (i = 0; i<60; i++){
cc.log("{x:"+location.x.toFixed(1)+", "+"y:"+location.y.toFixed(1)+"},");
cc.log("cc"+lineArray[30].x)
if( lineArray[i].x.toFixed(1) == location.x.toFixed(1) && lineArray[i].y.toFixed(1) == location.y.toFixed(1)){
self.node.removeChild(lineArray[i]);
cc.log("success")
}
}
return true
},
onTouchMoved: function(touch, event) {
var location = canvas.convertToNodeSpaceAR( touch.getLocation() );
// self.touchMovedX.string = location.x;
// self.touchMovedY.string = location.y;
for (i = 0; i<60; i++){
cc.log("{x:"+location.x+", "+"y:"+location.y+"},");
cc.log("cc"+lineArray[30].x)
var forX = location.x - lineArray[i].x;
var forY = location.y - lineArray[i].y;
var forX2 = location.x - lineArray2[i].x;
var forY2 = location.y - lineArray2[i].y;
forX = Math.abs(forX)*1;
forY = Math.abs(forY)*1;
forX2 = Math.abs(forX2)*1;
forY2 = Math.abs(forY2)*1;
if( forX<4 && forY<4){
self.node.removeChild(lineArray[i]);
self.node.removeChild(lineArray[59]);
cc.log("success")
}
if( forX2<4 && forY2<4){
self.node.removeChild(lineArray2[i]);
self.node.removeChild(lineArray2[59]);
cc.log("success")
}
}
return true
},
onTouchEnded: function(touch, event) {
return true
}
}, self.node);
},