Creating InAppPurchase in Cocos2d-x [closed]

久未见 提交于 2019-12-03 20:10:18

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

Use https://github.com/dualface/cocos2d-x-extensions that includes store extension download and browse, it will help you.

All the best..

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!