// // TestScene.cpp // demo // // Created by Red_mini on 2024/10/11. // #include "TestScene.h" #include "RUPlatform.h" #include "IAPCtlShop.hpp" #include "IAPDefine.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); // iap::IAPPlacement plInfo; // plInfo.id = "1"; // iap::IAPPlacement plInfo2; // plInfo2.id = "2"; // _iapShop->addAPlacement(plInfo); // _iapShop->addAPlacement(plInfo2); // 在此处添加场景初始化的代码,比如创建背景、角色、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); }else if(data.notify == "点击重置"){ _iapShop->setDeviceLevel(1); _iapShop->clearUserBuyInfo(); log("重置为低等级设备,且清除用户购买信息"); } } void TestScene::update(float dt){ }