Creating InAppPurchase in Cocos2d-x [closed]

99封情书 提交于 2020-01-01 06:39:26

问题


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

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