Blame view

ios/Runner/Wowgame/Classes/game_food/StaticActionParser.cpp 1.47 KB
cb213901   xiaoyu   添加一个游戏的源码和编译选项
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  //
  //  StaticActionParser.cpp
  //  SteveMaggieCpp
  //
  //  Created by Katarzyna Kalinowska-Górska on 21.05.2017.
  //
  //
  
  #include <stdio.h>
  #include "StaticActionParser.h"
  #include "SceneWithUtils.h"
  #include "SoundsRepo.h"
  #include "ResourceUtilities.h"
  
  const std::string StaticActionParser::ACTION_TYPE_PLAY_SOUND = "playSound";
  const std::string StaticActionParser::ACTION_TYPE_DISMISS_DIALOG = "dismissDialog";
  
  void StaticActionParser::parseStaticAction(const rapidjson::Value& actionJson)
  {
      if (actionJson.IsObject() && JSONParseUtils::hasMemberString(actionJson, "actionType")){
      
          const auto& actionType = actionJson["actionType"].GetString();
          if(ACTION_TYPE_PLAY_SOUND == actionType)
          {
              if(JSONParseUtils::hasMemberString(actionJson, "soundPath")){
  //                printf(ResourceUtilities::getInstance().getFullPathForDownloadedFile(actionJson["soundPath"].GetString(), false).c_str());
                  auto cancelOtherSounds = JSONParseUtils::checkMemberBool(actionJson, "cancelOtherSounds", true);
                  SoundsRepo::playSound(ResourceUtilities::getInstance().getFullPathForDownloadedFile(actionJson["soundPath"].GetString(), false).c_str(), cancelOtherSounds);
              }
          }
          else if(ACTION_TYPE_DISMISS_DIALOG == actionType){
              auto currentScene = dynamic_cast<SceneWithUtils*>(cocos2d::Director::getInstance()->getRunningScene());
              currentScene->dismissCurrentDialog();
          }
      }
  }