Cocos2dx 3. x determines whether the node click area is transparent.

Source: Internet
Author: User

Cocos2dx 3. x determines whether the node click area is transparent.

Sometimes we need to determine whether the area we touch is transparent. In this case, we need to call the glReadPixels function to extract the rgb color value.

Original in vain, mobile games column www.bkjia.com

 

Size size = Director: getInstance ()-> getVisibleSize (); CCRenderTexture * render = RenderTexture: create (size. width, size. height); render-> beginWithClear (,); node-> visit (); // original GLubyte pColor [4]; point location = this-> convertTouchToNodeSpace (touch); glReadPixels (location. x, location. y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, & pColor [0]); render-> end (); log (r % d g % d B % d a % d, pColor [0], pColor [1], pColor [2], pC Olor [3]); if (! PColor [0] &! PColor [1] &! PColor [2]) {log (tou ming);} else {log (bu tou ming );}


 


 

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.