123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- //
- // TestScene.cpp
- // demo
- //
- // Created by Red_mini on 2024/10/11.
- //
- #include "TestScene.h"
- #include "RUPlatform.h"
- #include "IAPCtlShop.hpp"
- #include "IAPDefine.hpp"
- #include "IAPTestCard.hpp"
- USING_NS_CC;
- Scene* TestScene::createScene(){
-
- // create the scene with physics enabled
- auto scene = Scene::create();
- auto layer = TestScene::create();
- scene->addChild(layer);
-
- return scene;
- }
- bool TestScene::init(){
- if (!Layer::init()) {
- return false;
- }
-
- std::string cfgFN = "shop_5.json";
-
- _iapShop = iap::IAPCtlShop::createWith();
- _iapShop->init(cfgFN);
- _iapShop->setCfg4Failure(cfgFN);
-
- iap::IAPPlacement plInfo;
- plInfo.id = "1";
- IAPTestCard* testCard = new IAPTestCard();
- IAPTestCard* testCard2 = new IAPTestCard();
- plInfo.cards.push_back(testCard);
- plInfo.cards.push_back(testCard2);
-
- _iapShop->addAPlacement(plInfo);
-
- // 第二个版位
-
- // iap::IAPPlacement plInfo2;
- // plInfo2.id = "2";
- // IAPTestCard* testCard3 = new IAPTestCard();
- // IAPTestCard* testCard4 = new IAPTestCard();
- // plInfo2.cards.push_back(testCard3);
- // plInfo2.cards.push_back(testCard4);
- //
- // _iapShop->addAPlacement(plInfo2);
-
-
- IAPTestCard* testCard5 = new IAPTestCard();
- _iapShop->addCardToPlacement(plInfo.id, testCard5);
-
- // 在此处添加场景初始化的代码,比如创建背景、角色、UI等
- createBoard();
- schedule(CC_SCHEDULE_SELECTOR(TestScene::update), 1.0f);
-
- return true;
- }
- void TestScene::createBoard(){
- auto lyMap = redutils::RUReboltLayer::createReboltLayer("lyMap.redream");
- this->addChild(lyMap);
- // log(lyMap->getChildrenCount());
- lyMap->registerOnNotify([this](const redutils::ReboltNotifyData& data){
- onNotifyDevelopment(data);
- });
- lyMap->runBehaviacWhitFunName("初始化");
-
- }
- void TestScene::onNotifyDevelopment(const redutils::ReboltNotifyData& data){
- if(data.notify == "点击显示商店"){
- log("点击显示商店按钮");
-
- iap::ShopRequirement shopRequirement;
- shopRequirement.coinsMin = 0;
-
- _iapShop->showInNode(this, shopRequirement);
- }else if(data.notify == "点击设备1"){
- _iapShop->setDeviceLevel(1);
- log("设置为低等级设备");
- }else if(data.notify == "点击设备2"){
- _iapShop->setDeviceLevel(3);
- log("设置为高等级设备");
- }else if(data.notify == "点击失败"){
- log("点击失败时金币不够按钮");
-
- // iap::ShopRequirement shopRequirement;
- // shopRequirement.coinsMin = 10000;
- //
- // _iapShop->showInNode(this, shopRequirement);
- _iapShop->displayFailureCardIn(this);
- }else if(data.notify == "点击重置"){
-
- _iapShop->setDeviceLevel(1);
- _iapShop->clearUserBuyInfo();
- log("重置为低等级设备,且清除用户购买信息");
- }
- }
- void TestScene::update(float dt){
-
-
- }
|