Search code examples
c++cocos2d-x

Cocos2d-x How do i enable / disable ccTouchMoved events?


i have CCSprite that received ccTouchMoved event and can be dragged all over the screen now i want to enable the user to:
1. move it for 5 or 10 pixels with the ccTouchMoved
2. the ccTouchMoved event will be disabled that means the user couldn't drag it
3. the animation to X or Y direction depending the drag direction will continue another 100 pixels with CCMoveBy action
4. when animation done enable the ccTouch events

the most important for me is how to enable / disable the ccTouch events
p.s
this is not give me the code question , i just need to know what are the command to use thanks


Solution

  • You can go for this to remove touch delegate (i,e your object which takes touches)

    CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(yourObject);
    

    Else, better use some boolean variable inside your class. Check it before processing touches inside delegate methods.