CustomParticleWidget* CustomParticleWidget::create() { CustomParticleWidget* custom = new (std::nothrow) CustomParticleWidget(); if (custom && custom->init()) { custom->autorelease(); return custom; } CC_SAFE_DELETE(custom); return nullptr; }
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 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()); } }