void CustomImageLayer::onEnter() { Layer::onEnter(); GUIReader* guiReader = GUIReader::getInstance(); guiReader->registerTypeAndCallBack("CustomImageView", &CustomImageView::createInstance, CustomImageViewReader::getInstance(), parseselector(CustomImageViewReader::setProperties)); Layout* layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/CustomImageViewTest/NewProject_2_1.ExportJson")); addChild(layout); }
void CustomParticleWidgetLayer::onEnter() { CCLayer::onEnter(); GUIReader* guiReader = GUIReader::getInstance(); guiReader->registerTypeAndCallBack("CustomParticleWidget", &CustomParticleWidget::createInstance, CustomParticleWidgetReader::getInstance(), parseselector(CustomParticleWidgetReader::setProperties)); CustomParticleWidget* custom = CustomParticleWidget::create(); custom->setParticlePlist("Particles/BoilingFoam.plist"); addChild(custom, 10, -1); }
void CocostudioParserJsonLayer::onEnter() { Layer::onEnter(); GUIReader* guiReader = GUIReader::getInstance(); guiReader->registerTypeAndCallBack("CustomImageView", &CustomImageView::createInstance, CustomImageViewReader::getInstance(), parseselector(CustomImageViewReader::setProperties)); guiReader->registerTypeAndCallBack("CustomParticleWidget", &CustomParticleWidget::createInstance, CustomParticleWidgetReader::getInstance(), parseselector(CustomParticleWidgetReader::setProperties)); Layout* layout = static_cast<Layout*>(guiReader->widgetFromJsonFile(_jsonFile.c_str())); layout->setScale(0.5); addChild(layout); }
void CustomParticleWidgetReader::setProperties(const std::string& classType, Widget *widget, const rapidjson::Value &customOptions) { GUIReader* guiReader = GUIReader::getInstance(); CustomParticleWidget* custom = static_cast<CustomParticleWidget*>(widget); bool isExistPlistFile = DICTOOL->checkObjectExist_json(customOptions, "PlistFile"); if (isExistPlistFile) { const char* PlistFile = DICTOOL->getStringValue_json(customOptions, "PlistFile"); std::string PlistFilePath = guiReader->getFilePath(); PlistFilePath.append(PlistFile); custom->setParticlePlist(PlistFilePath.c_str()); } }