CCTMXObjectGroup.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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-2016 Chukong Technologies Inc.
  7. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  8. http://www.cocos2d-x.org
  9. Permission is hereby granted, free of charge, to any person obtaining a copy
  10. of this software and associated documentation files (the "Software"), to deal
  11. in the Software without restriction, including without limitation the rights
  12. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. copies of the Software, and to permit persons to whom the Software is
  14. furnished to do so, subject to the following conditions:
  15. The above copyright notice and this permission notice shall be included in
  16. all copies or substantial portions of the Software.
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. THE SOFTWARE.
  24. ****************************************************************************/
  25. #include "2d/CCTMXObjectGroup.h"
  26. #include "base/ccMacros.h"
  27. NS_CC_BEGIN
  28. //implementation TMXObjectGroup
  29. TMXObjectGroup::TMXObjectGroup()
  30. : _groupName("")
  31. {
  32. }
  33. TMXObjectGroup::~TMXObjectGroup()
  34. {
  35. CCLOGINFO("deallocing TMXObjectGroup: %p", this);
  36. }
  37. ValueMap TMXObjectGroup::getObject(const std::string& objectName) const
  38. {
  39. if (!_objects.empty())
  40. {
  41. for (const auto& v : _objects)
  42. {
  43. const ValueMap& dict = v.asValueMap();
  44. if (dict.find("name") != dict.end())
  45. {
  46. if (dict.at("name").asString() == objectName)
  47. return dict;
  48. }
  49. }
  50. }
  51. // object not found
  52. return ValueMap();
  53. }
  54. Value TMXObjectGroup::getProperty(const std::string& propertyName) const
  55. {
  56. if (_properties.find(propertyName) != _properties.end())
  57. return _properties.at(propertyName);
  58. return Value();
  59. }
  60. NS_CC_END