1
0

CCTMXObjectGroup.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /****************************************************************************
  2. Copyright (c) 2010 Neophit
  3. Copyright (c) 2010 Ricardo Quesada
  4. Copyright (c) 2010-2012 cocos2d-x.org
  5. Copyright (c) 2011 Zynga Inc.
  6. Copyright (c) 2013-2017 Chukong Technologies Inc.
  7. http://www.cocos2d-x.org
  8. Permission is hereby granted, free of charge, to any person obtaining a copy
  9. of this software and associated documentation files (the "Software"), to deal
  10. in the Software without restriction, including without limitation the rights
  11. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. copies of the Software, and to permit persons to whom the Software is
  13. furnished to do so, subject to the following conditions:
  14. The above copyright notice and this permission notice shall be included in
  15. all copies or substantial portions of the Software.
  16. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. THE SOFTWARE.
  23. ****************************************************************************/
  24. #ifndef __CCTMX_OBJECT_GROUP_H__
  25. #define __CCTMX_OBJECT_GROUP_H__
  26. #include "math/CCGeometry.h"
  27. #include "base/CCValue.h"
  28. #include "base/CCRef.h"
  29. NS_CC_BEGIN
  30. /**
  31. * @addtogroup _2d
  32. * @{
  33. */
  34. /** @brief TMXObjectGroup represents the TMX object group.
  35. * @since v0.99.0
  36. */
  37. class CC_DLL TMXObjectGroup : public Ref
  38. {
  39. public:
  40. /**
  41. * @js ctor
  42. */
  43. TMXObjectGroup();
  44. /**
  45. * @js NA
  46. * @lua NA
  47. */
  48. virtual ~TMXObjectGroup();
  49. /** Get the group name.
  50. *
  51. * @return The group name.
  52. */
  53. const std::string& getGroupName() const { return _groupName; }
  54. /** Set the group name.
  55. *
  56. * @param groupName A string,it is used to set the group name.
  57. */
  58. void setGroupName(const std::string& groupName) { _groupName = groupName; }
  59. /** Return the value for the specific property name.
  60. *
  61. * @param propertyName The specific property name.
  62. * @return Return the value for the specific property name.
  63. * @js NA
  64. */
  65. Value getProperty(const std::string& propertyName) const;
  66. CC_DEPRECATED_ATTRIBUTE Value propertyNamed(const std::string& propertyName) const { return getProperty(propertyName); };
  67. /** Return the dictionary for the specific object name.
  68. * It will return the 1st object found on the array for the given name.
  69. *
  70. * @return Return the dictionary for the specific object name.
  71. */
  72. ValueMap getObject(const std::string& objectName) const;
  73. CC_DEPRECATED_ATTRIBUTE ValueMap objectNamed(const std::string& objectName) const { return getObject(objectName); };
  74. /** Gets the offset position of child objects.
  75. *
  76. * @return The offset position of child objects.
  77. */
  78. const Vec2& getPositionOffset() const { return _positionOffset; }
  79. /** Sets the offset position of child objects.
  80. *
  81. * @param offset The offset position of child objects.
  82. */
  83. void setPositionOffset(const Vec2& offset) { _positionOffset = offset; }
  84. /** Gets the list of properties stored in a dictionary.
  85. *
  86. * @return The list of properties stored in a dictionary.
  87. */
  88. const ValueMap& getProperties() const { return _properties; }
  89. ValueMap& getProperties() { return _properties; }
  90. /** Sets the list of properties.
  91. *
  92. * @param properties The list of properties.
  93. */
  94. void setProperties(const ValueMap& properties) {
  95. _properties = properties;
  96. }
  97. /** Gets the array of the objects.
  98. *
  99. * @return The array of the objects.
  100. */
  101. const ValueVector& getObjects() const { return _objects; }
  102. ValueVector& getObjects() { return _objects; }
  103. /** Sets the array of the objects.
  104. *
  105. * @param objects The array of the objects.
  106. */
  107. void setObjects(const ValueVector& objects) {
  108. _objects = objects;
  109. }
  110. protected:
  111. /** name of the group */
  112. std::string _groupName;
  113. /** offset position of child objects */
  114. Vec2 _positionOffset;
  115. /** list of properties stored in a dictionary */
  116. ValueMap _properties;
  117. /** array of the objects */
  118. ValueVector _objects;
  119. };
  120. // end of tilemap_parallax_nodes group
  121. /** @} */
  122. NS_CC_END
  123. #endif //__CCTMX_OBJECT_GROUP_H__