2010-08-30 11:45:46 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
#include "CCTMXObjectGroup.h"
|
|
|
|
#include "ccMacros.h"
|
|
|
|
namespace cocos2d {
|
|
|
|
|
|
|
|
//implementation CCTMXObjectGroup
|
|
|
|
|
2010-08-31 18:11:31 +08:00
|
|
|
CCTMXObjectGroup::CCTMXObjectGroup()
|
|
|
|
:m_sGroupName("")
|
2011-03-07 17:11:57 +08:00
|
|
|
,m_tPositionOffset(CCPointZero)
|
2010-08-30 11:45:46 +08:00
|
|
|
{
|
2011-03-18 14:31:29 +08:00
|
|
|
m_pObjects = new CCMutableArray<CCStringToStringDictionary*>();
|
2011-03-07 17:11:57 +08:00
|
|
|
m_pProperties = new CCStringToStringDictionary();
|
2010-08-30 11:45:46 +08:00
|
|
|
}
|
|
|
|
CCTMXObjectGroup::~CCTMXObjectGroup()
|
|
|
|
{
|
2010-08-30 15:23:07 +08:00
|
|
|
CCLOGINFO( "cocos2d: deallocing.");
|
2011-03-07 17:11:57 +08:00
|
|
|
CC_SAFE_RELEASE(m_pObjects);
|
|
|
|
CC_SAFE_RELEASE(m_pProperties);
|
2010-08-30 11:45:46 +08:00
|
|
|
}
|
2011-03-07 17:11:57 +08:00
|
|
|
CCStringToStringDictionary * CCTMXObjectGroup::objectNamed(const char *objectName)
|
2010-08-30 11:45:46 +08:00
|
|
|
{
|
2010-09-06 20:26:19 +08:00
|
|
|
if (m_pObjects && m_pObjects->count() > 0)
|
2010-08-30 11:45:46 +08:00
|
|
|
{
|
2011-03-18 14:31:29 +08:00
|
|
|
CCMutableArray<CCStringToStringDictionary*>::CCMutableArrayIterator it;
|
2010-09-06 20:26:19 +08:00
|
|
|
for (it = m_pObjects->begin(); it != m_pObjects->end(); ++it)
|
2010-08-30 11:45:46 +08:00
|
|
|
{
|
2011-03-07 17:11:57 +08:00
|
|
|
CCString *name = (*it)->objectForKey(std::string("name"));
|
2010-09-06 20:26:19 +08:00
|
|
|
if (name && name->m_sString == objectName)
|
|
|
|
{
|
|
|
|
return *it;
|
|
|
|
}
|
2010-08-30 11:45:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// object not found
|
2010-09-06 20:26:19 +08:00
|
|
|
return NULL;
|
2010-08-30 11:45:46 +08:00
|
|
|
}
|
2011-03-07 17:11:57 +08:00
|
|
|
CCString *CCTMXObjectGroup::propertyNamed(const char* propertyName)
|
2010-08-30 11:45:46 +08:00
|
|
|
{
|
2010-09-10 14:08:25 +08:00
|
|
|
return m_pProperties->objectForKey(std::string(propertyName));
|
2010-09-06 20:26:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-07 17:11:57 +08:00
|
|
|
CCStringToStringDictionary * CCTMXObjectGroup::getProperties()
|
2010-09-06 20:26:19 +08:00
|
|
|
{
|
|
|
|
return m_pProperties;
|
|
|
|
}
|
2011-03-07 17:11:57 +08:00
|
|
|
void CCTMXObjectGroup::setProperties(CCStringToStringDictionary * properties)
|
2010-09-06 20:26:19 +08:00
|
|
|
{
|
2011-03-07 17:11:57 +08:00
|
|
|
CC_SAFE_RETAIN(properties);
|
|
|
|
CC_SAFE_RELEASE(m_pProperties);
|
2010-09-06 20:26:19 +08:00
|
|
|
m_pProperties = properties;
|
|
|
|
}
|
2011-03-18 14:31:29 +08:00
|
|
|
CCMutableArray<CCStringToStringDictionary*> *CCTMXObjectGroup::getObjects()
|
2010-09-06 20:26:19 +08:00
|
|
|
{
|
|
|
|
return m_pObjects;
|
|
|
|
}
|
2011-03-18 14:31:29 +08:00
|
|
|
void CCTMXObjectGroup::setObjects(CCMutableArray<CCStringToStringDictionary*> * objects)
|
2010-09-06 20:26:19 +08:00
|
|
|
{
|
2011-03-07 17:11:57 +08:00
|
|
|
CC_SAFE_RETAIN(objects);
|
|
|
|
CC_SAFE_RELEASE(m_pObjects);
|
2010-09-06 20:26:19 +08:00
|
|
|
m_pObjects = objects;
|
2010-08-30 11:45:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}// namespace cocos2d
|