Search code examples
androidcocos2d-android

cocos2d-android : touch events are not firing


In my custom CCLayer, I use 4 functions to override touch events:

@Override
public boolean ccTouchesBegan(MotionEvent event) {
  return CCTouchDispatcher.kEventHandled;
}
@Override
public boolean ccTouchesEnded(MotionEvent event) {
  return super.ccTouchesEnded(event);
}
@Override
public boolean ccTouchesMoved(MotionEvent event) {
  return super.ccTocuhesMoved(event);
}
@Override
public boolean ccTouchesCancelled(MotionEvent event) {
  return super.ccTouchesCancelled(event);
}

None of the above is responding. Any reason that the touch events not firing ?


Solution

  • If anyone encounters the same problem, please remember to add the following line to constructor:

    this.setIsTouchEnabled(true);