COCOS2DX Settings for Android startup page

Source: Internet
Author: User

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

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.