How to make game background(main activity) transparent in cocos2d-xRc0

If you want to make your activity transparent. you will acesse 4 steps

Step1:

Image Title

Add “Translucent” to

android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

Step2:

Open the commit code in this java class

getWindow().setFormat(PixelFormat.TRANSLUCENT);

Image Title

Step3

Open this CCDirector.cpp file

Under project/cocos2d/cocos/2d

Image Title

And find this function modify last alpha value(from 0.0f - 1.0f) to your want

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

Image Title

Step4

Open this nativeactivity.cpp file

Under project/cocos/2d/platform/android

Image Title

And find this function modify

 const EGLint attribs[] = {
            EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
            EGL_BLUE_SIZE, 5,
            EGL_GREEN_SIZE, 6,
            EGL_RED_SIZE, 5,
            EGL_DEPTH_SIZE, 16,
            EGL_STENCIL_SIZE, 8,
            EGL_NONE
    };

To

const EGLint attribs[] = {
	            EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
	            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,  
	            //EGL_BLUE_SIZE, 5,   -->delete 
	            //EGL_GREEN_SIZE, 6,  -->delete 
	            //EGL_RED_SIZE, 5,    -->delete 
	            EGL_BUFFER_SIZE, 32,  //-->new field
	            EGL_DEPTH_SIZE, 16,
	            EGL_STENCIL_SIZE, 8,
	            EGL_NONE
	    };

Image Title


1.png (207.4 KB)


2.png (150.9 KB)


3.png (130.0 KB)


4.png (80.2 KB)


5.png (168.2 KB)


6.png (85.2 KB)

:slight_smile:

:smiley: Good job!