Cocos2dx background transparent processing

Source: Internet
Author: User

Cocos2dx background transparent processing
Take the latest Cocos2d-x 3.2 release as an example to explain how to make the background transparent in the Cocos2d-x.

Same, first.


There are not many changes. There are three main steps.

1. Set Activity background transparency in AndroidManifest. xml
?

VcmRlcj0 = "0" cellpadding = "0" cellspacing = "0">
1 android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"

,


2. Modify the init () method in the Cocos2dxActivity. java file in the org. cocos2dx. lib project of the libcocos2dx project.
Add the following code:
?
123 this.mGLSurfaceView.setZOrderOnTop(true);this.mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);this.mGLSurfaceView.setEGLConfigChooser(8,8,8,8,16,0);

Delete the following code (if it is not deleted, there will be a Cocos2dxEditText white bar at the top. Cocos2dxEditText encapsulates EditText, which is mainly used for TextField. If it is used in the program, it is recommended to replace it with EditBox)
?
12 //mFrameLayout.addView(edittext);//this.mGLSurfaceView.setCocos2dxEditText(edittext);

,



3. Modify the onSurfaceCreated () method in the Cocos2dxRenderer. java file in the org. cocos2dx. lib project of the libcocos2dx project.
Add the following code:
?
12345 pGL10.glDisable(GL10.GL_DITHER);pGL10.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);pGL10.glClearColor(0,0,0,0);pGL10.glEnable(GL10.GL_CULL_FACE);pGL10.glShadeModel(GL10.GL_SMOOTH);

,

Well, if you have a better solution, please follow the post.

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.