It's a man's next layer 100 [layer 5] -- 2048 from the source code to the release market, 100 layer 2048

Source: Internet
Author: User

It's a man's next layer 100 [layer 5] -- 2048 from the source code to the release market, 100 layer 2048

In the previous article "men are on the fifth layer [Fifth Layer] -- skin-changing version of 100 games", Sun Xiaoqiang implemented 2048 games in his own way and shared the core source code, this sunny Xiaoqiang intends to publish all the source code of the project and use this example to introduce how to add advertisements and implement sharing functions in this article.

The final running effect is as follows (for more running effects, see "is a man's next layer 100 [Fifth Layer] -- skin swap version 2048 game"):


I. The idea of skin replacement is actually very simple. Add a menu in the ActionBar. After you select a skin, modify the current skin status and save it to SharedPreference, this allows you to read the skin directly after startup, create a Bitmap object for the skin, and draw it in onDraw.
private void changeSkin(int skin) {Editor edit = sharedPreference.edit();edit.putInt("skin", skin);edit.commit();my2048View.changeSkin(skin);}
public void changeSkin(int skin){this.skin = skin;switch (skin) {case 0:for(int i=0; i<bitmaps.length; i++){bitmaps[i] = null;}for(int i=0; i<bitmaps_skin3.length; i++){bitmaps_skin3[i] = null;}break;case 1:for(int i=0; i<bitmaps_skin3.length; i++){bitmaps_skin3[i] = null;}initBitmap();break;case 2:for(int i=0; i<bitmaps.length; i++){bitmaps[i] = null;}initBitmap();break;}invalidate();}
2. How to add an advertisement some friends may ask before adding an advertisement. Which advertisement platform is better? I don't know the answer to this question. Before that, Sun Xiaoqiang never added advertisements to the app. This time, I just tried to use rice ads first, finally, I switched to jumi's advertisement (I personally think that jumi's advertising revenue is slightly higher ). In fact, the ad Integration Methods for various platforms are basically similar. Let's take a look at how the ads of jumi integrate:
I first selected the official unified PUSH package, after integration found that 360 is easy to detect, and later changed to the custom PUSH method (official documentation is very detailed: http://www.adjumi.com/AppDevPlat/Page/SDKSm.aspx ), I will not explain it step by step here. Remember to turn on the advertisement:
The next thing we will do is very simple. Let's take a look at our own benefits over a period of time.
3. There are two ways to add the sharing function. One is to start the analysis component of the system (the interface is difficult to modify and control ), the other is to use third-party analysis components (easy to customize, beautiful interface, recommended ). The first method is implemented as follows:
@ Overridepublic void onClick (View arg0) {/* my2048View. saveMaxScore (); Intent intent = new Intent (Intent. ACTION_SEND); intent. setType ("image/*"); intent. putExtra (Intent. EXTRA_SUBJECT, "2048 LOL"); // intent. putExtra (Intent. EXTRA_STREAM, Uri. fromFile (new File ("android: resource: // com. example. my2048/"+ R. raw. required _img); intent. putExtra (Intent. EXTRA_TEXT, "My highest record is" + sharedPreference. getInt ("maxScore", 0) + "Points, come and have fun, LOL version 2048! Youmu youzhe ~~, Go in and see the http://blog.csdn.net/dawanganban/article/details/37863693 "); intent. setFlags (Intent. FLAG_ACTIVITY_NEW_TASK); startActivity (Intent. createChooser (intent, getTitle (); * // whether the sharing selection page is my2048View only for logged-on users. saveMaxScore (); mController. openShare (MainActivity. this, false );}
The second way to achieve a variety of platforms available (here choose umeng) first registered as umeng developers, and get umeng appkey umeng to share the help documentation (http://dev.umeng.com/social/android/share/quick-integration ), before sharing, you need to make some preparations and apply for an appkey from each sharing platform.
Please refer to umeng's API for details. (This is a bit of a discussion. The API documentation is too bad ~~) Umeng has three integration methods. I chose the second method officially recommended, so I need to introduce an external project (for shared projects ), and the project is stored in the same directory as the project. Umeng social sharing component project (Git used in the project: git@code.csdn.net: lxq_xsyu/social_sdk_library_project.git) here to confuse the need to pay attention to a little path problem:-libraryjars .. /social_sdk_library_project/libs/SocialSDK_QQZone_2.jar 4. Download the complete source code. For details and better methods, refer to this project. I will paste all the source code of the project (note: please use the Git tool to download and download the above shared component project usage instructions to add)
Git: git@code.csdn.net: lxq_xsyu/my2048.git code: plugin? Articleid = 37863693

If you have any questions, please leave a message below ~~ If Sun Xiaoqiang sees it, he will reply in time.


The source code for the next layer is for a man.

I should search for the Chinese source code website on the Internet, but I remember the one in flash programming,

It's a man. The source code of the Third-layer C Language

You don't have to score 1000 points.
 

Related Article

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.