除了引擎提供的xml文件,之外,我们还可以利用C/C++的文件保存方式保存到本地
看例子代码:
void CSaveMsg::setRestStarPoint(const MaxPiectInformation &r_point) { const char *pPath = g_pUserDefault->getXMLFilePath().c_str(); FILE *pOpen; if ( (pOpen = fopen("D:a.txt","wb+")) == nullptr) { return; //读取空指针了 } fwrite(&r_point,sizeof(MaxPiectInformation),1,pOpen); fclose(pOpen); } const MaxPiectInformation &CSaveMsg::getRestStarPoint() { const char *pPath = g_pUserDefault->getXMLFilePath().c_str(); FILE *pOpen; if ((pOpen = fopen("D:a.txt","rb")) == nullptr) { MaxPiectInformation point; std::memset(&point,sizeof(point)); return point; //读取空指针了 } MaxPiectInformation readPoint; fread(&readPoint,pOpen); fclose(pOpen); return readPoint; }