问题描述
我是新的Cocos2d-x.I需要创建InAppPurchase对于Cocos2d-x iOS游戏(CPP)。任何人都可以帮助我创建InAppPurchase.or任何教程相关的。
I am new to Cocos2d-x.I need to create InAppPurchase For Cocos2d-x iOS game (CPP).can anybody help me to create InAppPurchase.or any Tutorials Related to this.
感谢提前。
推荐答案
版本的inAp购买在.cpp cocos2d-x项目中。你所需要做的只是在.mm文件中写桥接cpp类。它适用于iOS。
You can use obj.C version of inAp purchase in .cpp cocos2d-x project. All you need to do is just write bridge cpp class in .mm file. It works for iOS.
//。cpp文件说Player.cpp
//.cpp file say Player.cpp
#include "MyGameBride.h"
void Player::unlockPlayer()
{
MyGameBride:: shared()-> upgrade_inAp();
}
//.h of MyGameBride.h
//.h of MyGameBride.h
#include <stddef.h>
class MyGameBride
{
public:
MyGameBride();
MyGameBride();
static MyGameBride* shared();
void upgrade_inAp();
};
// MyGameBride.mm(请注意.mm不是.m)
// MyGameBride.mm (note that here .mm not .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中的客观类。
Here AppController is objective class in .m
这篇关于在Cocos2d-x中创建InAppPurchase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!