Cocos2d-x Event Passing (function of the return value of the Ontouchbegan)
Only perform two touch events after the return value of Ontouchbegan is True
1 //Ontouchbegan an event that begins to touch2Listener->ontouchbegan = [] (Touch *t, Event *e) {3 //gets the target to the current event through event E, and then gets the bounding area to the target4 //E->getcurrenttarget ()->getboundingbox ( )5 //then decide whether to include a point, that is, touch point:. Containspoint ()6 //get to the touch position t->getlocation ()7 //The goal of the event is that the boundary area of node includes the current touch point, indicating that the current object is being touched8 if(E->getcurrenttarget ()->getboundingbox (). Containspoint (t->getLocation ())) {9Log"ontouchbegan!");Ten } One A - //only perform two touch events after the return value of Ontouchbegan is true - //return false; the return true; - }; - //Touch the Mobile event listener to execute internal code when the touch moves -listener->ontouchmoved = [] (Touch *t, Event *e) { +Log"ontouchmoved>>"); - }; + //Touch End Event listener to execute internal code when touch is finished Alistener->ontouchended = [] (Touch *t, Event *e) { atLog"ontouchend----"); - }; - - - - //Geteventdispatcher Gets the dispatcher for the event, in //addeventlistenerwithscenegraphpriority (event, node); Add Event listener -Director::getinstance ()->geteventdispatcher ()->addeventlistenerwithscenegraphpriority (listener, label);
Cocos2d-x Event Passing (function of the return value of the Ontouchbegan)