Cocos2dx uses DrawNode instead of DrawPrimitives to draw a rough line and the painting will not be blocked by the genie.

Source: Internet
Author: User
To work, draw a line to connect the center of the screen and the touch point. The line must be thick and be able to adjust zOrder flexibly. Under this requirement, I first used glLineWidth (10) and DrawPrimitives: drawLine (......) The draw method is rewritten to implement this function. However, it was found that the glLineWidth and 10-200 of the kill were not changed.

To work, draw a line to connect the center of the screen and the touch point. The line must be thick and be able to adjust zOrder flexibly. Under this requirement, I first used glLineWidth (10) and DrawPrimitives: drawLine (......) The draw method is rewritten to implement this function. However, it was found that the glLineWidth and 10-200 of the kill were not changed.

To work, draw a line to connect the center of the screen and the touch point. The line must be thick and be able to adjust zOrder flexibly.

Under this requirement, I first used

GlLineWidth (10) and DrawPrimitives: drawLine (......) The draw method is rewritten to implement this function.

However, it was later found that the glLineWidth and 10-200 of the kill had not changed, and later it was found that the line drawn would be blocked by the genie.

Even if zOrder of the genie is set to a negative number.

I had no choice but to start my journey to Baidu. I found DrawNode on the Forum and tried it. It worked really well.

DrawNode uses the drawn image as a Node in the program. It can adjust zOrder as freely as other nodes, and there is no limit on the width of OpenGL at 10 points. However, DrawNode does not erase the image left by the previous frame. Therefore, we need a global pointer and refresh it manually.

The following code is used:

OK. After such processing, the line width can be adjusted as needed.

Let's take a look at the Super rough line !!

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.