Cocos2d-x Event Passing (function of the return value of the Ontouchbegan)

Source: Internet
Author: User
Tags event listener

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.