Component* ComAudioReader::createComAudioWithFlatBuffers(const flatbuffers::Table *comAudioOptions)
 {
     auto options = (ComAudioOptions*)comAudioOptions;
     
     Component* component = ComAudio::create();
     ComAudio* audio = static_cast<ComAudio*>(component);
     
     auto fileNameData = options->fileNameData();
     
     int resourceType = fileNameData->resourceType();
     switch (resourceType)
     {
         case 0:
         {
             std::string path = fileNameData->path()->c_str();
             audio->setFile(path.c_str());
             break;
         }
             
         default:
             break;
     }
     
     bool loop = options->loop() != 0;
     audio->setLoop(loop);
     
     audio->setName(options->name()->c_str());
     
     return component;
 }
Exemple #2
0
Component* CSLoader::loadComAudio(const rapidjson::Value &json)
{
    ComAudio* audio = ComAudio::create();
    
    const char* name = DICTOOL->getStringValue_json(json, COMPONENT_NAME);
    bool enabled = DICTOOL->getBooleanValue_json(json, COMPONENT_ENABLED);
    
    audio->setName(name);
    audio->setEnabled(enabled);
    
    const char* filePath = DICTOOL->getStringValue_json(json, COMPONENT_AUDIO_FILE_PATH);
    bool loop = DICTOOL->getBooleanValue_json(json, COMPONENT_LOOP);
    
    audio->setFile(filePath);
    audio->setLoop(loop);
    
    
    return audio;
}