问题
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.
Thanks in Advance.
回答1:
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 file say Player.cpp
#include "MyGameBride.h"
void Player::unlockPlayer()
{
MyGameBride:: shared()-> upgrade_inAp();
}
//.h of MyGameBride.h
#include <stddef.h>
class MyGameBride
{
public:
MyGameBride();
MyGameBride();
static MyGameBride* shared();
void upgrade_inAp();
};
// 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];
}
Here AppController is objective class in .m
回答2:
Use https://github.com/dualface/cocos2d-x-extensions that includes store extension download and browse, it will help you.
All the best..
回答3:
I know i'm biased (I'm one of the creators) but cocos2dx-store is exactly what you need: http://github.com/soomla/cocos2dx-store
来源:https://stackoverflow.com/questions/16815309/creating-inapppurchase-in-cocos2d-x