Only onTouchBegan callback is being fired in Touch EventListener


I have added a touch eventListener to my animation layer in order to handle dragging of one sprite to another. I copied the listener/handler from a working project, but in my project the only callback that ever gets called is onTouchBegan - never moved, ended, or canceled. What am I doing wrong?

var myLayer = cc.Layer.extend({

  ctor: function() {

      event: cc.EventListener.TOUCH_ONE_BY_ONE,
      swallowTouches: true,
      onTouchBegan: function() {console.log('Began')},
      onTouchMoved: function() {console.log('Moved')},
      onTouchEnded: function () {console.log('Ended')},
      onTouchCancelled: function () {console.log('Cancelled')}
    }, this);


I don’t see it clearly spelled out in the documentation / blog post, but a StackOverflow post set me straight - the callbacks need to return true or false. Adding return true; to the end of onTouchBegan fixed it - all callbacks are now being called.


Checkout this link. Good explanation is provided here.


Thanks for the response, but that’s the blog post I was referring to. It specifies what returning true / false do when swallowTouches is true, but it doesn’t mention that a return value is required for the listeners to function in general. Perhaps I should have read that into it.