cocos节点添加Touch监听代码
this.node.on(cc.Node.EventType.TOUCH_START,
function(t){
console.log( "x" + t.getLocation().x + "y" + t.getLocation().y )
console.log(t.getLocation())
},this)
this.node.on(cc.Node.EventType.TOUCH_MOVE,
function(t){
console.log( "x" + t.getLocation().x + "y" + t.getLocation().y )
console.log(t.getLocation())
},this)
this.node.on(cc.Node.EventType.TOUCH_END,
function(t){
console.log( "x" + t.getLocation().x + "y" + t.getLocation().y )
console.log(t.getLocation())
},this)
this.node.on(cc.Node.EventType.TOUCH_CANCEL,
function(t){
console.log( "x" + t.getLocation().x + "y" + t.getLocation().y )
console.log(t.getLocation())
},this)
代码需要放入onLoad函数内才可生效
function(t) 函数内 t 参数为 Touch类型
Touch 类型

浙公网安备 33010602011771号