1
0

CCTMXObjectGroup.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #include "2d/CCTMXObjectGroup.h"
  25. #include "base/ccMacros.h"
  26. NS_CC_BEGIN
  27. //implementation TMXObjectGroup
  28. TMXObjectGroup::TMXObjectGroup()
  29. : _groupName("")
  30. {
  31. }
  32. TMXObjectGroup::~TMXObjectGroup()
  33. {
  34. CCLOGINFO("deallocing TMXObjectGroup: %p", this);
  35. }
  36. ValueMap TMXObjectGroup::getObject(const std::string& objectName) const
  37. {
  38. if (!_objects.empty())
  39. {
  40. for (const auto& v : _objects)
  41. {
  42. const ValueMap& dict = v.asValueMap();
  43. if (dict.find("name") != dict.end())
  44. {
  45. if (dict.at("name").asString() == objectName)
  46. return dict;
  47. }
  48. }
  49. }
  50. // object not found
  51. return ValueMap();
  52. }
  53. Value TMXObjectGroup::getProperty(const std::string& propertyName) const
  54. {
  55. if (_properties.find(propertyName) != _properties.end())
  56. return _properties.at(propertyName);
  57. return Value();
  58. }
  59. NS_CC_END