var sprite = cc.find("Canvas/sprite").getComponent(cc.Sprite); sprite.node.on(cc.Node.EventType.TOUCH_START, function (event) { var touches = event.getTouches(); var touchLoc = touches[0].getLocation(); console.log(touchLoc,"start"); });
就是个sprite在浏览器里点击一下下,为啥会打印输出6次?
creator2
打印如下:
Vec2 {x: 179.5, y: 585} “start”
coin.js:62 Vec2 {x: 179.5, y: 585} “start”
coin.js:62 Vec2 {x: 179.5, y: 585} “start”
coin.js:62 Vec2 {x: 179.5, y: 585} “start”
coin.js:62 Vec2 {x: 179.5, y: 585} “start”
coin.js:62 Vec2 {x: 179.5, y: 585} “start”
你为什么要用,精灵,sprite.node.on ,用this 试试
看你注册事件的代码调用了几次
我猜你canves上有5个sprite
解决了,确实我在多个控件上多次注册监听事件的原因。