c – 在Cocos2d-x中创建InAppPurchase
作者:互联网
我是Cocos2d-x的新手.我需要创建InAppPurchase For Cocos2d-x iOS游戏(CPP).可以帮助我创建InAppPurchase.or任何与此相关的教程.
提前致谢.
解决方法:
您可以在.cpp cocos2d-x项目中使用inAp购买的obj.C版本.您需要做的就是在.mm文件中编写桥接cpp类.它适用于iOS.
//.cpp文件说Player.cpp
#include "MyGameBride.h"
void Player::unlockPlayer()
{
MyGameBride:: shared()-> upgrade_inAp();
}
// My.hameBride.h
#include <stddef.h>
class MyGameBride
{
public:
MyGameBride();
MyGameBride();
static MyGameBride* shared();
void upgrade_inAp();
};
// MyGameBride.mm(请注意,这里.mm不是.m)
#import "MyGameBride.h"
static MyGameBride *s_gc;
MyGameBride* MyGameBride::shared(){
if (! s_gc) {
s_gc = new MyGameBride();
}
return s_gc;
}
void GameCenter:: upgrade_inAp(){
AppController* app = (AppController*)[[UIApplication sharedApplication] delegate];
[app upgrade];
}
这里AppController是.m中的客观类
标签:cocos2d-x,c,ios,objective-c,in-app-purchase 来源: https://codeday.me/bug/20190831/1778976.html