Cocos2d-x Android version of China Mobile SDK embedded

Source: Internet
Author: User
<span id="Label3"></p><pre><span style="color: #800080;"><span style="color: #800080;">1</span></span><span style="color: #000000;">the <span style="color: #000000;">Copy API copies Sdk\runtime\cmbilling20007.jar to the game Project's Runtime directory (or other directory), but remember not to compile in the Libs directory, or compile an error (such as bad range). ) (complete) Copy the sdk\libs\armeabi\libmegjb.so to the same directory as the Game. (complete, note: should be re-copied after each Compilation)</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span><span style="color: #000000;">the <span style="color: #000000;">. Copy resource copies all the resources in the Sdk\assets,sdk\res to the same directory as the Game. (complete, note: assets should be re-copied after each Compilation)</span></span><span style="color: #800080;"><span style="color: #800080;">3</span></span><span style="color: #000000;"><span style="color: #000000;">Replace the game maker logo or game logo to assets</span></span>/<span style="color: #000000;"><span style="color: #000000;">two images in openinganimation directory: g_logo_sp.png g_logo_cp.png for your own. There are formatting requirements to see the Documentation. SP and CP simultaneously replace one of them with a game logo to avoid duplication</span></span><span style="color: #800080;"><span style="color: #800080;">4</span></span><span style="color: #000000;"><span style="color: #000000;">Replace the game name Picture Sdk\assets\openinganimation\g_game_title.png with the format requirements see Document.</span></span><span style="color: #800080;"><span style="color: #800080;">5</span></span><span style="color: #000000;"><span style="color: #000000;">Add the activity reference provided by the SDK. A. copy the text from the Sdk\androidmanifest.xml.activity.txt to the androidmanifest.xml of the Game. b.android: screenorientation, set the screen, preferably set as the main interface of the Screen. (completed)</span></span><span style="color: #800080;"><span style="color: #800080;">6</span></span>. Add the required Permissions use-<span style="color: #000000;"><span style="color: #000000;">permision Copy the text in Sdk\androidmanifest.xml.activity.txt to the androidmanifest.xml of the game (complete) do not add permissions repeatedly</span></span><span style="color: #800080;"><span style="color: #800080;">7</span></span>Add China Mobile game Base logo for the main entrance of the game (intent-<span style="color: #000000;"><span style="color: #000000;">Filter) Add China Mobile game Base logo for game main entrance activity</span></span><span style="color: #800080;"><span style="color: #800080;">8</span></span><span style="color: #000000;"><span style="color: #000000;">The game billing information profile assets below has charge.xml,consumecodeinfo.xml (must exist, the two files will be replaced dynamically after the game is Submitted)</span></span><span style="color: #800080;"><span style="color: #800080;">9</span></span><span style="color: #000000;"><span style="color: #000000;">Application Loading interface game developers in the integration sdk, be sure to first customize the global Application. Application inside the code must contain: system.loadlibrary (</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">MEGJB</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #000000;"><span style="color: #000000;">); You can copy Java directly from the Sdkdemo. The sample code is as Follows:</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">class</span></span><span style="color: #000000;"><span style="color: #000000;">Cmgameapplication extends Application {</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">onCreate () {system.loadlibrary (</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">MEGJB</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #000000;"><span style="color: #000000;">); }}androidmanifest.xml configuration: note: The package path of the application class must be consistent with the PackageName configured in Androidmanifest.xml</span></span><span style="color: #800080;"><span style="color: #800080;">Ten</span></span><span style="color: #000000;">Game initialization interface The initialization of the game <span style="color: #000000;">is the necessary action to realize the game Billing. (must be called in the UI Thread) before the game starts, you need to call the following method, or you cannot use the billing feature</span></span><span style="color: #800080;"><span style="color: #800080;">1</span></span><span style="color: #000000;"><span style="color: #000000;">Gameinterface.initializeapp (Activity gmain); overloaded method 1, only used to initialize the basic information of the sdk, does not trigger the billing function, the Game's billing behavior can be 2.</span></span><span style="color: #800080;"><span style="color: #800080;">6</span></span><span style="color: #000000;"><span style="color: #000000;">the. 2 section of the Dobilling interface is complete, however: if the game has only one billing point, you can call the following simplified interface directly, and the initialization is executed with the demo billing logic, refer to overloaded method 3. If you want to specify the game name of the billing interface by the partner itself, the game provider and customer service telephone information (the SDK by default on the platform to declare business when the customer service call), you can call the overloaded interface 2 implementation:</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span><span style="color: #000000;"><span style="color: #000000;">gameinterface.initializeapp (Activity main, string gamename, string provider, string servicetel); call Example: Gameinterface.initializeapp (</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> this</span><span style="color: #000000;"><span style="color: #000000;">);</span></span><span style="color: #800080;"><span style="color: #800080;"></span> one</span><span style="color: #000000;"><span style="color: #000000;">the Start screen mode of the game: invoke the Gameopenactivity implementation in the SDK (recommended) in Androidmanifest.xml The main entry activity is configured as Gameopenactivity (that is, The SDK provides the game splash screen Activit Y). The original main entry of the game activity please add to res</span></span>/values/<span style="color: #000000;"><span style="color: #000000;">G_strings.xml in the G_class_name string, enabling the game to start when the splash screen is complete such as:</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">G_class_name</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span>><span style="color: #000000;"><span style="color: #000000;">Your.game.ui.Entry in Addition: This method can be used to determine whether the user chooses to turn on the background sound by the interface gameinterface.ismusicenabled (), the interface detailed definition see (</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span><span style="color: #000000;"><span style="color: #000000;">. 9 Chapters) If the game uses an API level that is less than or equal to 3, that is: the game is based on Android</span></span><span style="color: #800080;"><span style="color: #800080;">1</span></span><span style="color: #000000;"><span style="color: #000000;">. 5 developed, then also need to set a low version of the identity, (API less than 4 case, Android itself does not support image adaptation, It may cause the SDK interface elements are magnified, poor UI Effect)</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span><span style="color: #800000;"><span style="color: #800000;">gc_billing_islow_version</span></span><span style="color: #800000;"><span style="color: #800000;">"</span></span>><span style="color: #0000ff;"><span style="color: #0000ff;">true</span></span><span style="color: #000000;"><span style="color: #000000;">so that the SDK reads the identity and completes the self-adaptation of the boot interface. </span></span><span style="color: #800080;"><span style="color: #800080;"></span> a</span><span style="color: #000000;">When the game exits the game exit, the interface <span style="color: #000000;">needs to be called to complete the exit logic, which is with 2.</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span><span style="color: #000000;"><span style="color: #000000;">. 2 in pairs, the former user initializes the SDK instance, which frees up the resources and memory used by the SDK and implements the exit confirmation Interface. Calling Interface: gameinterface.exit (contextcontex, gameexitcallback callback); Call Example: (you can refer to the demo Sample's billingdemo.java) gameinterface.exit (billingdemo.</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> this</span>,<span style="color: #0000ff;"><span style="color: #0000ff;">New</span></span><span style="color: #000000;"><span style="color: #000000;">gameexitcallback () {@Override</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">onconfirmexit () {</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;">the <span style="color: #008000;">game developer needs to implement this method, which is implemented after the user clicks the confirm exit callback</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">This is usually the release of the game resources, close the session, finish interface and other Operations. </span></span><span style="color: #000000;"><span style="color: #000000;">} @Override</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">oncancelexit () {</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;">in <span style="color: #008000;">the first scenario, the interface method can be used without adding any code, and the SDK internally puts the current exit</span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">interface Finish off, here if the game developers have special processing needs, can be additional implementation Code. </span></span><span style="color: #000000;"><span style="color: #000000;">}}); When you decide to call Ene () in 2dx in exit, a bug occurs: first time into normal, second flashback, third normal, fourth time flashback ... See the following error in Logcat:</span></span><span style="color: #800080;"><span style="color: #800080;"></span> one</span>-<span style="color: #800080;"><span style="color: #800080;"></span> the</span> <span style="color: #800080;"><span style="color: #800080;"></span> one</span>:<span style="color: #800080;"><span style="color: #800080;"></span> -</span>:<span style="color: #800080;"><span style="color: #800080;">08.922</span></span>: D/cocos2d-x Debug Info (<span style="color: #800080;"><span style="color: #800080;">9466</span></span>): OpenGL Error<span style="color: #800080;"><span style="color: #800080;">0x0501</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">inch</span></span>/users/zxtw/documents/cocos2d-x/cocos2d-<span style="color: #800080;"><span style="color: #800080;">2</span></span>.1rc0-x-<span style="color: #800080;"><span style="color: #800080;">2.1</span></span>.<span style="color: #800080;"><span style="color: #800080;">2</span></span>/cocos2dx/draw_nodes/ccdrawingprimitives.cpp Lazy_init<span style="color: #800080;"><span style="color: #800080;"></span> the</span><span style="color: #000000;"><span style="color: #000000;">note: The result method is System.exit (</span></span><span style="color: #800080;"><span style="color: #800080;">0</span></span><span style="color: #000000;"><span style="color: #000000;">);</span></span><span style="color: #800080;"><span style="color: #800080;"></span> -</span><span style="color: #000000;"><span style="color: #000000;">. More game Interface Gameinterface.viewmoregames (context context);</span></span><span style="color: #800080;"><span style="color: #800080;"></span> -</span><span style="color: #000000;"><span style="color: #000000;">. SDK Billing Point Development one. when you force a billing point, you must call the Get paid flag interface before calling this billing point to determine if the game has been paid.</span></span><span style="color: #800080;"><span style="color: #800080;"></span> the</span><span style="color: #000000;">billing <span style="color: #000000;">activity is billed through the Dobilling interface in gameinterface, and the default processing method is implemented within the billing Activity. The partner only needs to listen to the status of the billing success or failure. the partner invokes the following interface to complete the billing process and complete various billing requirements with different parameter Values. If the game wants to handle the custom logic after billing ends, such as a billing success, a failure, or a user canceling the charge, implement the Ipaycallback callback, and other cases can pass null values Directly. If a billing point in the game needs to be billed repeatedly, pass the isrepeated parameter to a true Value. Gameinterface.dobilling (context context, boolean usesms, boolean isrepeated,</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">string</span></span><span style="color: #000000;"><span style="color: #000000;">Billingindex,ipaycallback billingcallback); After three-bit example of "activation point billing code" in "activation Point information" in the game platform game of China Mobile game base, The billing point "activates the game" after the code three bits is "</span></span><span style="color: #800080;"><span style="color: #800080;">001</span></span>", the billing point" Super Spring "after The code three bits is"<span style="color: #800080;"><span style="color: #800080;">004</span></span><span style="color: #000000;"><span style="color: #000000;">". Code invocation example:</span></span><span style="color: #800080;"><span style="color: #800080;">1</span></span>) using the SMS billing mode, The billing code after three bits is "<span style="color: #800080;"><span style="color: #800080;"></span> the</span><span style="color: #000000;">Billing points <span style="color: #000000;">(non-recurring billing points) to pay Billingcallback billingcallback</span></span>=<span style="color: #0000ff;"><span style="color: #0000ff;">New</span></span><span style="color: #000000;"><span style="color: #000000;">billingcallback () {@Override</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">onbillingsuccess (String Billingindex) {System.</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> out</span><span style="color: #000000;"><span style="color: #000000;">. println ("ok");} @Override</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">onbillingfail (String Billingindex) {System.</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> out</span><span style="color: #000000;"><span style="color: #000000;">. println ("fail"); @Override</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">onuseropercancel (String Billingindex) {System.</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> out</span><span style="color: #000000;"><span style="color: #000000;">. println ("cancel");}; Gameinterface.dobilling (</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> this</span>,<span style="color: #0000ff;"><span style="color: #0000ff;">true</span></span>,<span style="color: #0000ff;"><span style="color: #0000ff;">false</span></span>, “<span style="color: #800080;"><span style="color: #800080;"></span> the</span><span style="color: #000000;"><span style="color: #000000;">", billingcallback); gameinterface.dobilling (</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> this</span>,<span style="color: #0000ff;"><span style="color: #0000ff;">true</span></span>,<span style="color: #0000ff;"><span style="color: #0000ff;">false</span></span>, “<span style="color: #800080;"><span style="color: #800080;"></span> the</span>”,<span style="color: #0000ff;"><span style="color: #0000ff;">NULL</span></span><span style="color: #000000;"><span style="color: #000000;">);</span></span><span style="color: #800080;"><span style="color: #800080;">2</span></span>) using networked billing, three digits after the billing code is "<span style="color: #800080;"><span style="color: #800080;">001</span></span><span style="color: #000000;">Billing point <span style="color: #000000;">(a recurring billing point) for a paid gameinterface.dobilling (</span></span><span style="color: #0000ff;"><span style="color: #0000ff;"></span> this</span>,<span style="color: #0000ff;"><span style="color: #0000ff;">false</span></span>,<span style="color: #0000ff;"><span style="color: #0000ff;">true</span></span>, “<span style="color: #800080;"><span style="color: #800080;">001</span></span><span style="color: #000000;"><span style="color: #000000;">", billingcallback); Special Note: the billing interface to be called in the main thread of the game</span></span><span style="color: #800080;"><span style="color: #800080;"></span> -</span><span style="color: #000000;"><span style="color: #000000;">. Set up a Pay flag interface (not Used)</span></span><span style="color: #800080;"><span style="color: #800080;"></span> -</span><span style="color: #000000;"><span style="color: #000000;">get paid Flag interface (hard billing point used, But general activation will be controlled in 2dx, not important, but write a bit better)</span></span><span style="color: #800080;"><span style="color: #800080;"></span> -</span><span style="color: #000000;"><span style="color: #000000;">get the game background music switch (called when the game is initialized after the SDK to set the Game's initial Sound)</span></span><span style="color: #800080;"><span style="color: #800080;"></span> +</span>. Get the Gamer ID (not used)</pre><p><p>Source: http://blog.sina.com.cn/s/blog_6324d6990101lgjl.html</p></p><p><p>Cocos2d-x Android version of China Mobile SDK embedded</p></p></span>

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.