如何在cocos2dx ios sdk接入-x游戏接入IOS登录模块

君,已阅读到文档的结尾了呢~~
cocos2d-x强交互网络游戏架构设计与实践,cocosd x,一线架构师实践指南,云计算架构技术与实践,交互设计信息架构图,x架构键盘,x86 架构,架构调整 g x3,titan x架构,x架构键盘推荐
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
cocos2d-x强交互网络游戏架构设计与实践
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer--144.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口问题:苹果公司现任CEO是谁?2字正确答案:库克
主题 : iOS-Cocos2dx游戏中IOS_iAP功能的接入
级别: 新手上路
UID: 491441
可可豆: 205 CB
威望: 179 点
在线时间: 303(时)
发自: Web Page
来源于&&分类
iOS-Cocos2dx游戏中IOS_iAP功能的接入&&&
Cocos2d-x游戏iOS客户端开发从零到AppStore发布笔记(十)本帖主题:iOS-Cocos2dx游戏中IOS_iAP功能的接入    游戏开发中集成应用内支付是一个非常重要的环节,任何APP中的虚拟物品的出售都必须要接入iOS的iAP支付功能。今天就分享我在游戏中接入iOSIAP的过程及遇到的问题。我接入的代码的思想主要是参考泰然网:Cocos2d-x使用iOS游戏内付费IAP(C++篇),以及其他的博客加上自己的一些理解。前期准备,自然还是那老三样,mac、真机、开发者帐号。 一、在开发者后台中APPID中设置 App支持Iap支付功能块,到iTunes Connect后台设置你要出售的物品的信息(具体设置方法就百度下吧),同时记得要设置一个沙箱测试帐号(不能与iTunes帐号相同)。(还要吐槽的是坑爹苹果居然要3:7分真是狠。。。) 二、封装iAP(注:首先是记得导入storeKit系统库) 1)支付流程介绍及代码分析 -&发起商品信息请求(此处调用iOSProductByIdentifier方法并调用 SKProductsRequest接口发起请求),并等待苹果服务器返回信息void IOSiAP::requestProducts(std::vector  &productIdentifiers){[pre]    // 1.    NSMutableSet *set = [NSMutableSet setWithCapacity:productIdentifiers.size()];    std::vector ::    for (iterator = productIdentifiers.begin(); iterator != productIdentifiers.end(); iterator++) {        [set addObject:[NSString stringWithUTF8String:(*iterator).c_str()]];    }    // 2.    SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:set];    // 3.    iAPProductsRequestDelegate *delegate = [[iAPProductsRequestDelegate alloc] init];    delegate.iosiap =    productsRequest.delegate =    // 4.    [productsRequest start];[/pre]} -&获取每个商品的信息(通过SKProductsRequestDelegate中响应请求事件并将商品信息重新返回给iOSProduct)     // release old    if (_iosiap-&skProducts) {        [(NSArray *)(_iosiap-&skProducts) release];    }     // record new product    _iosiap-&skProducts = [response.products retain]; -&请求购买商品及商品数量(上一步已经返回了商品,进行ID匹配,调用SKMutablePayment接口进行购买)  if(iosProduct!=NULL){    SKProduct *skProduct = [(NSArray *)(skProducts) objectAtIndex:iosProduct-&index];    SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:skProduct];    payment.quantity =     [[SKPaymentQueue defaultQueue] addPayment:payment];        }
-&购买事务回调(定义了一个叫iAPTransactionObserver的Object-c类来实现桥接,主要获取购买成功与否的相关处理)- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{    for (SKPaymentTransaction *transaction in transactions) {         std::string identifier([transaction.payment.productIdentifier UTF8String]);        IOSiAPPaymentE         switch (transaction.transactionState) {            case SKPaymentTransactionStatePurchasing:                event = IOSIAP_PAYMENT_PURCHASING;                           case SKPaymentTransactionStatePurchased:                event = IOSIAP_PAYMENT_PURCHAED;                           case SKPaymentTransactionStateFailed:                event = IOSIAP_PAYMENT_FAILED;                NSLog(@& == ios payment error : %@&,transaction.error);                           case SKPaymentTransactionStateRestored:                // NOTE: consumble payment is NOT restorable                event = IOSIAP_PAYMENT_RESTORED;                        }             _iosiap-&delegate-&onPaymentEvent(identifier, event,int(transaction.payment.quantity));       if (event != IOSIAP_PAYMENT_PURCHASING) {            [[SKPaymentQueue defaultQueue] finishTransaction: transaction];      }    }} -&恢复购买(在C++桥接类中需要恢复购买的方法调用[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]即可);
三、封装C++接口 定义一个IOSiAP_Bridge继承IOSiAPDelegate:起到桥梁作用的中间类,主要功能是调用iAP中的各种请求接口,并且IOSiAPDelegate中的结果会通过代理返回到此类中。
class IOSiAP_Bridge : public IOSiAPDelegate{public:    IOSiAP_Bridge();    ~IOSiAP_Bridge();    IOSiAP *    int productID;    void requestProducts(int);    void requestRestore();//请求恢复购买    virtual void onRequestProductsFinish(void);    virtual void onRequestProductsError(long code);    virtual void onPaymentEvent(std::string &identifier, IOSiAPPaymentEvent event, int quantity);    virtual void onRestoreFinished(bool succeed);    static bool alertS}; 1)支付调用代码 #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)    IOSiAP_Bridge* bridge=new IOSiAP_Bridge();     switch (daojvid)    {         case DJSHOP_libao:            bridge-&requestProducts(1);                   case DJSHOP_jinbi1:            bridge-&requestProducts(2);                   case DJSHOP_jinbi2:            bridge-&requestProducts(3);                   case DJSHOP_jinbi3:            bridge-&requestProducts(4);                   case DJSHOP_jinbi4:            bridge-&requestProducts(5);               } #endif 2)真机测试
前面也提到过测试购买,苹果提供的是沙盒测试,需要注册一个与itunes Connect不同的帐号;购买过程中使用网速较快的网络,购买过程真心是慢的。(苹果服务器) 四、遇到的问题1)   第一次提交的时候忘加恢复购买,直接被打回来了浪费许多时间,所以切记加入一键恢复购买;2)由于请求购买的时间较长苹果不会有任何提示,所以最好设置一个风火轮显示购买中,如果不成功则弹出购买失败弹框;3)对于弱联网游戏,用户经常会忘了连接网络,最好设置个对话框提示如果没网就弹出提示要连接网络;4)虚拟物品的ID在IOSBridge和itunesConnect一定要相同要不然请求不到数据;5)虚拟物品价格设定别忘了考虑美元汇率,特别是从安卓游戏转IOS游戏的常常会忘了这一点。暂时就这么多问题了,后续碰到了再添加吧!!!借鉴的博客:1)泰然网:;2)苹果内购官方网站:3)51CTO内购专题:4)iOS支付那些坑:
共享开发心情,相互交流技术。。。。
关注本帖(如果有新回复会站内信通知您)
苹果公司现任CEO是谁?2字 正确答案:库克
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
我们所看到的游戏画面,游戏音乐,以及一些触控,输入等。在逻辑上就是这么一个死循环。这个循环一直在跑,期间会处理一些列的事件,简化之就是上面的两个函数。cocos2d-x引擎也是如此,所有的逻辑都是在这个主循环下实现的。下面看看cocos2dx在各平台上的主循环实现。1.Win看它的main.cpp[cpp]&前面都不要关心,只是用来传递OpenGL窗口的,关键是最后一句,CCApplication::sharedApplication()-&run()。看这个run函数:[cpp]&不熟悉windows的童鞋估计都知道windows是消息驱动的。这个死循环就是用来处理windows的消息循环的,在其中处理了FPS逻辑,消息分发等。注意看其中红色标标注的[cpp]&这是神马东西啊!这个就是cocos2d-x的主循环了,由导演负责维护。从此就进入了cocos2d-x的世界,跟windows没有一毛钱关系了。2.iOsios上面和Android上类似。看AppController.mm[cpp]&直接看标注,跟进run()[cpp]&再跟标注的startMainLoop()[cpp]&好了,看红色标注。这个貌似循环不起来啊,呵呵。仔细看他加载的这个类CADisplayLink,就是这个东西循环起来的。这其实就是个定时器,默认每秒运行60次,其有个属性可以设置FPS。看后面有个回调函数doCaller,跟进[cpp]&好了,终于又看到导演了。导演很忙,又开始主循环了。一旦进入主循环,游戏就开始我们自己设计的游戏逻辑。
阅读(4970)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'cocos2d-x 游戏引擎的处理流程 MainLoop主循环(上)',
blogAbstract:'首先还是就我个人的理解,讲讲游戏引擎的处理流程。其实游戏逻辑简单化就是一个死循环,如下:',
blogTag:'cocos2d-x',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:2,
permalink:'blog/static/',
commentCount:1,
mainCommentCount:1,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}后使用我的收藏没有帐号?
所属分类: &
查看: 11814|回复: 7
游戏引擎为COCOS2D-X的如何接入91SDK
TA的勋章:
本帖最后由 啊,将进酒 于
17:08 编辑
游戏引擎为COCOS2D-X如何接入91SDK-iOS的参考:
游戏引擎为COCOS2D-X如何接入91SDK-Android的参考:
开发技术问题请自行百度解决。
点这里&&&&
太坑爹了&&一步一步跳过去&&最后还是c++调用java
指尖每日首次回帖可以赚5金币()收起回复展开回复
点这里&&&&
指尖每日首次回帖可以赚5金币()收起回复展开回复
点这里&&&&
如果我想使用cocos2d-x的plugin的话,其中只有plugin只封装了几个API,我配置了DeveloperInfo,然后设置了Debug模式为true,也写了对应商品的ProductId,结果,进入支付页面默认是充值的页面,不太理解
还有就是ProductId指的是什么?
而使用了91默认给的例子和plugin给的例子都可以显示出商品,希望收到您的回复,谢谢
指尖每日首次回帖可以赚5金币()收起回复展开回复
点这里&&&&
TA的勋章:
如果我想使用cocos2d-x的plugin的话,其中只有plugin只封装了几个API,我配置了DeveloperInfo,然后设置了D ...
请按要求找91商务拉讨论组,会分配专人解答你的问题。论坛不做解答。
指尖每日首次回帖可以赚5金币()收起回复展开回复
点这里&&&&
话说你们的讨论组是在哪,有问题一直无法解决啊。
指尖每日首次回帖可以赚5金币()收起回复展开回复
点这里&&&&
为什么技术支持的QQ没一个能加上的,讨论组号码也没有,论坛里刚注册,发布了帖子,也没有权限发内部消息,我们的技术问题怎么找谁啊,。能不能把开发者后面的联系方式删掉那几个加不了的QQ号呀
指尖每日首次回帖可以赚5金币()收起回复展开回复
点这里&&&&
TA的勋章:
为什么技术支持的QQ没一个能加上的,讨论组号码也没有,论坛里刚注册,发布了帖子,也没有权限发内部消息, ...
&&请按要求先找商务联系,SDK是联运游戏才使用到的,不是相关业务的不提供SDK的技术支持服务。
指尖每日首次回帖可以赚5金币()收起回复展开回复
点这里&&&&
全民唱变大赛海量好礼等你来拿!
大尺度卖萌勋章
在论坛任意版块发帖晒出自己的萌照通过审核即可获得
长期对论坛的繁荣而不断努力,精华帖40篇以上。
限量十二星座勋章:处女座
花费1500论坛金币在勋章商店中购买cocos2d-x -- 渠道SDK【棱镜】接入(1) - 推酷
cocos2d-x -- 渠道SDK【棱镜】接入(1)
棱镜SDK简介
若想让游戏上线,渠道接入步骤是必不可少的,为了避免一对一接入渠道问题,我选择了棱镜SDK,因为棱镜是游戏与渠道SDK的 中间层 ,为CP厂商屏蔽各个渠道SDK之间的差异,整个接入过程, 不会改变各个渠道SDK的功能、特性、参数等,对玩家完全透明。
棱镜平台基本工作原理:/ljdocs/lj_principle.html
棱镜技术接入文档(cocos2d-x)::/ljdocs/lj_tech_integration_cpp.html
棱镜SDK下载:/ljdocs/lj_tech_general.html
客户端接入流程
1.将Demo项目中Classes/GameProxy.h 复制到你的C++工程中头文件存放的位置,如Cocos2dx项目放入Classes目录, 将Classes/gameproxy.cpp 放入源码目录,如Cocos2dx的Classes目录:
2.windows平台添加代码如下:
#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include &cocos2d.h&
class HelloWorld : public cocos2d::CCLayer
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::CCScene* scene();
// a selector callback
void menuCloseCallback(CCObject* pSender);
void setUserListener();
void loginCallback(CCObject* pSender);
void logoutCallback(CCObject* pSender);
void chargeCallback(CCObject* pSender);
void payCallback(CCObject* pSender);
void exitCallback(CCObject* pSender);
void showInfo(const char* str);
// implement the &static node()& method manually
CREATE_FUNC(HelloWorld);
cocos2d::CCLabelTTF* outputL
#endif // __HELLOWORLD_SCENE_H__
HelloWorldScene.cpp
#include &HelloWorldScene.h&
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include &GameProxy.h&
USING_NS_CC;
CCScene* HelloWorld::scene()
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();
// add layer as a child to scene
scene-&addChild(layer);
// return the scene
// on &init& you need to initialize your instance
bool HelloWorld::init()
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
CCSize visibleSize = CCDirector::sharedDirector()-&getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()-&getVisibleOrigin();
CCLabelTTF* pLabel = CCLabelTTF::create(&CoCos2d-x SDKTest&, &Arial&, 30);
// position the label on the center of the screen
pLabel-&setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - pLabel-&getContentSize().height));
// add the label as a child to this layer
this-&addChild(pLabel, 1);
this-&outputLabel = CCLabelTTF::create(&Output Here&, &Arial&, 20);
this-&outputLabel-&setHorizontalAlignment(kCCTextAlignmentLeft);
// position the label on the center of the screen
this-&outputLabel-&setAnchorPoint(ccp(0, 0));
this-&outputLabel-&setPosition(ccp(origin.x + visibleSize.width/2, origin.y));
this-&addChild(this-&outputLabel, 1);
// add &HelloWorld& splash screen&
CCSprite* pSprite = CCSprite::create(&icon.png&);
// position the sprite on the center of the screen
pSprite-&setPosition(ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2));
// add the sprite as a child to this layer
this-&addChild(pSprite, 0);
CCMenuItemFont *loginItem = CCMenuItemFont::create(
menu_selector(HelloWorld::loginCallback));
CCMenuItemFont *logoutItem = CCMenuItemFont::create(
menu_selector(HelloWorld::logoutCallback));
CCMenuItemFont *chargeItem = CCMenuItemFont::create(
menu_selector(HelloWorld::chargeCallback));
CCMenuItemFont *payItem = CCMenuItemFont::create(
menu_selector(HelloWorld::payCallback));
CCMenuItemFont *exitItem = CCMenuItemFont::create(
menu_selector(HelloWorld::exitCallback));
float borderWidth = 0;
float currentYBorder = origin.y + visibleSize.
float offset = borderWidth + loginItem-&getContentSize().height/2;
loginItem-&setPosition(ccp(origin.x + loginItem-&getContentSize().width/2 + borderWidth,
currentYBorder - offset));
currentYBorder -= 2 *
offset = borderWidth + logoutItem-&getContentSize().height/2;
logoutItem-&setPosition(ccp(origin.x + logoutItem-&getContentSize().width/2 + borderWidth ,
currentYBorder - offset));
currentYBorder -= 2 *
offset = borderWidth + chargeItem-&getContentSize().height/2;
chargeItem-&setPosition(ccp(origin.x + chargeItem-&getContentSize().width/2 + borderWidth ,
currentYBorder - offset));
currentYBorder -= 2 *
offset = borderWidth + payItem-&getContentSize().height/2;
payItem-&setPosition(ccp(origin.x + payItem-&getContentSize().width/2 + borderWidth ,
currentYBorder - offset));
currentYBorder -= 2 *
offset = borderWidth + exitItem-&getContentSize().height/2;
exitItem-&setPosition(ccp(origin.x + exitItem-&getContentSize().width/2 + borderWidth ,
currentYBorder - offset));
CCMenu* pMenu = CCMenu::create(loginItem,logoutItem,chargeItem,payItem,exitItem,NULL);
pMenu-&setPosition(CCPointZero);
this-&addChild(pMenu,1,2);
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
this-&showInfo(GameProxy::GetAndroidManifestMeta(&XMGAME_PRODUCT_CODE&));
void HelloWorld::showInfo(const char *info){
this-&outputLabel-&setString(info);
CCLOG(&showinfo %s&, info);
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
class XMUserListenerImpl: public XMUserListener {
HelloWorld *
XMUserListenerImpl(HelloWorld* parent) {
this-&parent =
virtual void onLoginSuccess(XMUser user, const char *customParams) {
// 游戏的登陆逻辑需要写在这里
// 当游戏调用 GameProxy::Login(params) 时,该函数会被调用
// 其中user对象为渠道登陆系统返回的用户相关参数,包含uid token 渠道号等
// 其中params为调用GameProxy::Login( params)时,传入的params
// 确保该函数被调用后,用户可以正确地进入游戏
CCLOG(&login success&);
is && &uid : & && user.getUserId() && &\ntoken : & && user.getToken() && &\nchannelId : & && user.getChannelId();
parent-&showInfo(is.str().c_str());
GameProxy::SetXMRoleData(&1&, &hi&, &10&, &1&, &1&);
virtual void onLoginFailed(const char *reason,
const char *customParams) {
is && &login failed reason: & && reason && &\ncustomParams: & && customP
parent-&showInfo(is.str().c_str());
virtual void onLogout(const char *customParams) {
// 游戏相关的用户登出注销逻辑需要写在这里
// 当渠道的用户中心界面中点击注销,该函数会被调用
// 当游戏调用 GameProxy::Logout(params) 时,该函数也会被调用
// 其中params为用户调用 GameProxy::Logout(params) 时传入的params
// params可以用来传递一些游戏中的上下文,可以是任意字符串
// 确保游戏中任何时候,该函数被调用后,游戏可以正确登出
parent-&showInfo(&logout&);
class PayCallBackImpl:public PayCallBack{
HelloWorld*
PayCallBackImpl(HelloWorld* parent) {
this-&parent =
virtual void onPaySuccess(char *successinfo){
is && &sucess: & &&
parent-&showInfo(is.str().c_str());
virtual void onPayFail(char *failinfo){
is && &payfailed: & &&
parent-&showInfo(is.str().c_str());
class ExitCallBackImpl:public ExitCallBack{
virtual void onGameExit(){
CCDirector::sharedDirector()-&end();
virtual void onNo3rd(){
CCDirector::sharedDirector()-&end();
void HelloWorld::setUserListener(){
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
GameProxy::SetUserListener(new XMUserListenerImpl(this));
void HelloWorld::loginCallback(CCObject* pSender)
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
this-&showInfo(&logining&);
HelloWorld::setUserListener();
const char *customParams = &login&;
GameProxy::Login(customParams);
void HelloWorld::logoutCallback(CCObject* pSender){
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
const char *customParams = &logout&;
GameProxy::Logout(customParams);
void HelloWorld::chargeCallback(CCObject* pSender){
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
const char *itemName = &元宝&;
int unitPrice = 10;
int defalutNum = 500;
const char *callBackInfo = &this is callback info...&;
const char *callbackUrl = &http://test&;
GameProxy::Charge(itemName, unitPrice, defalutNum, callBackInfo, callbackUrl,new PayCallBackImpl(this));
void HelloWorld::payCallback(CCObject* pSender){
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
int amount = 10;
const char *unitName = &天币&;
int count = 118;
const char *callBackInfo = &this is callback info&;
const char *callbackUrl = &http://test&;
GameProxy::Pay(amount, unitName, count, callBackInfo, callbackUrl, new PayCallBackImpl(this));
void HelloWorld::exitCallback(CCObject* pSender){
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
GameProxy::Exit(new ExitCallBackImpl());
void HelloWorld::menuCloseCallback(CCObject* pSender)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
CCMessageBox(&You pressed the close button. Windows Store Apps do not implement a close button.&,&Alert&);
CCDirector::sharedDirector()-&end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
3.android平台:
环境搭建:
将Demo项目中libs目录下
jar包 复制到游戏项目的libs目录下
将Demo项目中assets目录下的文件复制到游戏项目的assets目录下
AndroidManifest.xml
&?xml version=&1.0& encoding=&utf-8&?&
&manifest xmlns:android=&/apk/res/android&
package=&com.InsetSDK.org&
android:versionCode=&1&
android:versionName=&1.0&&
&uses-sdk android:minSdkVersion=&8&/&
&uses-feature android:glEsVersion=&0x& /&
&application
android:name=&com.xinmei365.game.proxy.XMApplication&
android:label=&@string/app_name&
android:icon=&@drawable/icon&&
&activity android:name=&.InsetSDK&
android:label=&@string/app_name&
android:screenOrientation=&landscape&
android:theme=&@android:style/Theme.NoTitleBar.Fullscreen&
android:configChanges=&orientation&&
&intent-filter&
&action android:name=&android.intent.action.MAIN& /&
&category android:name=&android.intent.category.LAUNCHER& /&
&/intent-filter&
&/activity&
&meta-data android:name=&XMGAME_CHANNEL_CODE& android:value=&9f10f46c3b5409a05ebf& /&
&meta-data android:name=&XMGAME_PRODUCT_CODE& android:value=&lsjs& /&
&/application&
&supports-screens android:largeScreens=&true&
android:smallScreens=&true&
android:anyDensity=&true&
android:normalScreens=&true&/&
&uses-permission android:name=&android.permission.INTERNET&/&
&/manifest&
Activity的Java代码:
public class InsetSDK extends Cocos2dxActivity{
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
GameProxyNativeStub.init(this, GameProxy.getInstance(), new XMGLThreadRunner() {
public void runOnGLThread(Runnable pRunnable) {
InsetSDK.this.runOnGLThread(pRunnable);
GameProxy.getInstance().applicationInit(this);
GameProxy.getInstance().onCreate(this);
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
// InsetSDK should create stencil buffer
glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
return glSurfaceV
System.loadLibrary(&cocos2dcpp&);
public void onStop() {
super.onStop();
GameProxy.getInstance().onStop(this);
public void onDestroy() {
super.onDestroy();
GameProxy.getInstance().onDestroy(this);
public void onResume() {
super.onResume();
GameProxy.getInstance().onResume(this);
public void onPause() {
super.onPause();
GameProxy.getInstance().onPause(this);
public void onRestart() {
super.onRestart();
GameProxy.getInstance().onRestart(this);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
GameProxy.getInstance().onActivityResult(this, requestCode, resultCode, data);
真机运行效果图:
已发表评论数()
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
主题不准确
没有分页内容
图片无法显示
视频无法显示
与原文不一致}

我要回帖

更多关于 cocos2dx接入appstore 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信