CCActionManagerEx.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /****************************************************************************
  2. Copyright (c) 2013-2017 Chukong Technologies Inc.
  3. http://www.cocos2d-x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #ifndef __ActionMANAGER_H__
  21. #define __ActionMANAGER_H__
  22. #include "editor-support/cocostudio/CCActionObject.h"
  23. #include "editor-support/cocostudio/DictionaryHelper.h"
  24. #include "editor-support/cocostudio/CocosStudioExport.h"
  25. namespace cocostudio {
  26. class CocoLoader;
  27. struct stExpCocoNode;
  28. class CC_STUDIO_DLL ActionManagerEx:public cocos2d::Ref
  29. {
  30. public:
  31. /**
  32. * Default constructor
  33. * @js ctor
  34. */
  35. ActionManagerEx();
  36. /**
  37. * Default destructor
  38. * @js NA
  39. * @lua NA
  40. */
  41. virtual ~ActionManagerEx();
  42. /**
  43. * Gets the static instance of ActionManager.
  44. * @js getInstance
  45. * @lua getInstance
  46. */
  47. static ActionManagerEx* getInstance();
  48. /**
  49. * Purges ActionManager point.
  50. * @js purge
  51. * @lua destroyActionManager
  52. */
  53. static void destroyInstance();
  54. /**
  55. * Gets an ActionObject with a name.
  56. *
  57. * @param jsonName UI file name
  58. *
  59. * @param actionName action name in the UI file.
  60. *
  61. * @return ActionObject which named as the param name
  62. */
  63. ActionObject* getActionByName(const char* jsonName,const char* actionName);
  64. /**
  65. * Play an Action with a name.
  66. *
  67. * @param jsonName UI file name
  68. *
  69. * @param actionName action name in the UIfile.
  70. *
  71. * @return ActionObject which named as the param name
  72. */
  73. ActionObject* playActionByName(const char* jsonName,const char* actionName);
  74. /**
  75. * Play an Action with a name.
  76. *
  77. * @param jsonName UI file name
  78. *
  79. * @param actionName action name in the UIfile.
  80. *
  81. * @param func ui action call back
  82. */
  83. ActionObject* playActionByName(const char* jsonName,const char* actionName, cocos2d::CallFunc* func);
  84. /**
  85. * Stop an Action with a name.
  86. *
  87. * @param jsonName UI file name
  88. *
  89. * @param actionName action name in the UIfile.
  90. *
  91. * @return ActionObject which named as the param name
  92. */
  93. ActionObject* stopActionByName(const char* jsonName,const char* actionName);
  94. /*init properties with json dictionary*/
  95. void initWithDictionary(const char* jsonName,const rapidjson::Value &dic, Ref* root, int version = 1600);
  96. void initWithBinary(const char* file, Ref* root, CocoLoader* cocoLoader, stExpCocoNode* pCocoNode);
  97. /**
  98. * Release all actions.
  99. *
  100. */
  101. void releaseActions();
  102. int getStudioVersionNumber() const;
  103. protected:
  104. std::unordered_map<std::string, cocos2d::Vector<ActionObject*>> _actionDic;
  105. int _studioVersionNumber;
  106. };
  107. }
  108. #endif