Cocos2dx Android on the start Page settings are almost the same, read some information on the internet, a lot of people are re-get an activity as the start page, this is no problem, but in cocos2dx Android on the middle there will be a long black screen time, This is mainly in the loading of some resources; another way to start the page is to write directly on the main page, for the implementation please refer to
How to implement Android app launcher interface
This blog personal feeling or write good, well now implement COCOS2DX Android on the Start Page method implemented as follows:
I used the version of COCOS2DX 3.2.
Add the appropriate code to the Appactivity
Private StaticActivity mAct =NULL; Private StaticHandler Muihandler =NULL; Private StaticImageView imageview=NULL; @Overrideprotected voidonCreate (Bundle savedinstancestate) {//TODO auto-generated Method Stub Super. OnCreate (savedinstancestate); Muihandler=NewHandler (); Addcontentview (Createlogoimg (),Newlayoutparams (layoutparams.fill_parent, layoutparams.fill_parent));//Add Start Page} PublicImageView createlogoimg () {ImageView=NewImageView ( This); Imageview.setimageresource (R.drawable.splash);
Imageview.setscaletype (ImageView.ScaleType.FIT_CENTER);Sets the image of the current image (position is the position of the current image list)
imageview.setrotation (return
The start page has been added, it must be moved out
Public Static void Removeimgview () { muihandler.post () {/imageview (new Runnable ()} is in the UI thread, the main thread, So we can only send messages to the main thread via a child thread to the new UI @Override publicvoid run () {if (imageview!=null) { imageview.setvisibility (view.gone);}} ); }
We definitely need to move out after the resources have been loaded, and we need to use JNI to invoke the Java method in C + +:
void Ccsetimagevisiblefalse () {//because in the packaging of the use of the ANYSDK, so I directly import ANYSDK package, did not intentionally import JNI-related package pluginjnimethodinfo t; if (Pluginjnihelper::getstaticmethodinfo (T, "org/cocos2dx/cpp/appactivity", "Removeimgview", "() V")) { t.env Callstaticvoidmethod (T.classid, t.methodid); T.env-Deletelocalref (T.CLASSID); }
This code is written directly in the C + + class, where you want to move out of ImageView and call this method directly
COCOS2DX Settings for Android startup page