2013-06-06 12:02:54 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 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 "CCDisplayManager.h"
|
|
|
|
#include "../CCBone.h"
|
|
|
|
#include "../CCArmature.h"
|
|
|
|
#include "../utils/CCUtilMath.h"
|
|
|
|
#include "../display/CCSkin.h"
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
NS_CC_EXT_ARMATURE_BEGIN
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DisplayManager *DisplayManager::create(Bone *bone)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
DisplayManager *pDisplayManager = new DisplayManager();
|
2013-06-06 12:02:54 +08:00
|
|
|
if (pDisplayManager && pDisplayManager->init(bone))
|
|
|
|
{
|
|
|
|
pDisplayManager->autorelease();
|
|
|
|
return pDisplayManager;
|
|
|
|
}
|
|
|
|
CC_SAFE_DELETE(pDisplayManager);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DisplayManager::DisplayManager()
|
2013-09-13 18:07:37 +08:00
|
|
|
: m_pDecoDisplayList(NULL)
|
|
|
|
, m_pDisplayRenderNode(NULL)
|
|
|
|
, m_pCurrentDecoDisplay(NULL)
|
|
|
|
, m_iDisplayIndex(-1)
|
|
|
|
, m_bForceChangeDisplay(false)
|
|
|
|
, m_bVisible(true)
|
|
|
|
, m_pBone(NULL)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DisplayManager::~DisplayManager()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
CC_SAFE_DELETE(m_pDecoDisplayList);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
if( m_pDisplayRenderNode )
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pDisplayRenderNode->removeFromParentAndCleanup(true);
|
|
|
|
if(m_pDisplayRenderNode->retainCount() > 0)
|
|
|
|
CC_SAFE_RELEASE_NULL(m_pDisplayRenderNode);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
bool DisplayManager::init(Bone *bone)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
bool ret = false;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pBone = bone;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
initDisplayList(bone->getBoneData());
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
ret = true;
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
|
|
|
while (0);
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
void DisplayManager::addDisplay(DisplayData *displayData, int index)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
DecorativeDisplay *decoDisplay = NULL;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
if(index >= 0 && (unsigned int)index < m_pDecoDisplayList->count())
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
decoDisplay = (DecorativeDisplay *)m_pDecoDisplayList->getObjectAtIndex(index);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
decoDisplay = DecorativeDisplay::create();
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pDecoDisplayList->addObject(decoDisplay);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DisplayFactory::addDisplay(m_pBone, decoDisplay, displayData);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
//! if changed display index is current display index, then change current display to the new display
|
2013-09-13 18:07:37 +08:00
|
|
|
if(index == m_iDisplayIndex)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
m_iDisplayIndex = -1;
|
2013-06-07 10:52:32 +08:00
|
|
|
changeDisplayByIndex(index, false);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
void DisplayManager::addDisplay(Node *display, int index)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
DecorativeDisplay *decoDisplay = NULL;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
if(index >= 0 && (unsigned int)index < m_pDecoDisplayList->count())
|
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
decoDisplay = (DecorativeDisplay *)m_pDecoDisplayList->getObjectAtIndex(index);
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
decoDisplay = DecorativeDisplay::create();
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pDecoDisplayList->addObject(decoDisplay);
|
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DisplayData *displayData = NULL;
|
|
|
|
if (Skin *skin = dynamic_cast<Skin *>(display))
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
|
|
|
skin->setBone(m_pBone);
|
2013-09-15 19:08:45 +08:00
|
|
|
displayData = SpriteDisplayData::create();
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DisplayFactory::initSpriteDisplay(m_pBone, decoDisplay, skin->getDisplayName().c_str(), skin);
|
2013-09-13 18:07:37 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
if (SpriteDisplayData *spriteDisplayData = (SpriteDisplayData *)decoDisplay->getDisplayData())
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
|
|
|
skin->setSkinData(spriteDisplayData->skinData);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
BaseData baseData;
|
2013-09-13 18:07:37 +08:00
|
|
|
skin->setSkinData(baseData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (dynamic_cast<ParticleSystemQuad *>(display))
|
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
displayData = ParticleDisplayData::create();
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
2013-09-15 19:08:45 +08:00
|
|
|
else if(Armature *armature = dynamic_cast<Armature *>(display))
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
displayData = ArmatureDisplayData::create();
|
2013-09-13 18:07:37 +08:00
|
|
|
armature->setParentBone(m_pBone);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
displayData = DisplayData::create();
|
2013-09-13 18:07:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
decoDisplay->setDisplay(display);
|
|
|
|
decoDisplay->setDisplayData(displayData);
|
|
|
|
|
|
|
|
//! if changed display index is current display index, then change current display to the new display
|
|
|
|
if(index == m_iDisplayIndex)
|
|
|
|
{
|
|
|
|
m_iDisplayIndex = -1;
|
|
|
|
changeDisplayByIndex(index, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
void DisplayManager::removeDisplay(int index)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
|
|
|
m_pDecoDisplayList->removeObjectAtIndex(index);
|
|
|
|
|
|
|
|
if(index == m_iDisplayIndex)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
setCurrentDecorativeDisplay(NULL);
|
|
|
|
}
|
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
Array *DisplayManager::getDecorativeDisplayList()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
return m_pDecoDisplayList;
|
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
void DisplayManager::changeDisplayByIndex(int index, bool force)
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
|
|
|
CCAssert( (m_pDecoDisplayList ? index < (int)m_pDecoDisplayList->count() : true), "the _index value is out of range");
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
m_bForceChangeDisplay = force;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
//! If index is equal to current display index,then do nothing
|
2013-09-13 18:07:37 +08:00
|
|
|
if ( m_iDisplayIndex == index)
|
2013-06-07 10:52:32 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
m_iDisplayIndex = index;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
//! If displayIndex < 0, it means you want to hide you display
|
2013-09-13 18:07:37 +08:00
|
|
|
if (m_iDisplayIndex < 0)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
if(m_pDisplayRenderNode)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pDisplayRenderNode->removeFromParentAndCleanup(true);
|
2013-06-06 12:02:54 +08:00
|
|
|
setCurrentDecorativeDisplay(NULL);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DecorativeDisplay *decoDisplay = (DecorativeDisplay *)m_pDecoDisplayList->getObjectAtIndex(m_iDisplayIndex);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
setCurrentDecorativeDisplay(decoDisplay);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
void DisplayManager::setCurrentDecorativeDisplay(DecorativeDisplay *decoDisplay)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
|
|
|
|
if (m_pCurrentDecoDisplay && m_pCurrentDecoDisplay->getColliderDetector())
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pCurrentDecoDisplay->getColliderDetector()->setActive(false);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
#endif
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pCurrentDecoDisplay = decoDisplay;
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
|
|
|
|
if (m_pCurrentDecoDisplay && m_pCurrentDecoDisplay->getColliderDetector())
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pCurrentDecoDisplay->getColliderDetector()->setActive(true);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
#endif
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
Node *displayRenderNode = m_pCurrentDecoDisplay == NULL ? NULL : m_pCurrentDecoDisplay->getDisplay();
|
|
|
|
if (m_pDisplayRenderNode)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
if (dynamic_cast<Armature *>(m_pDisplayRenderNode) != NULL)
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pBone->setChildArmature(NULL);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pDisplayRenderNode->removeFromParentAndCleanup(true);
|
|
|
|
m_pDisplayRenderNode->release();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pDisplayRenderNode = displayRenderNode;
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
if(m_pDisplayRenderNode)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
if (Armature *armature = dynamic_cast<Armature *>(m_pDisplayRenderNode))
|
2013-09-13 18:07:37 +08:00
|
|
|
{
|
|
|
|
m_pBone->setChildArmature(armature);
|
|
|
|
}
|
|
|
|
else if (ParticleSystemQuad *particle = dynamic_cast<ParticleSystemQuad *>(m_pDisplayRenderNode))
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
particle->resetSystem();
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
2013-09-13 18:07:37 +08:00
|
|
|
|
|
|
|
if (RGBAProtocol *rgbaProtocaol = dynamic_cast<RGBAProtocol *>(m_pDisplayRenderNode))
|
|
|
|
{
|
|
|
|
rgbaProtocaol->setColor(m_pBone->getDisplayedColor());
|
|
|
|
rgbaProtocaol->setOpacity(m_pBone->getDisplayedOpacity());
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pDisplayRenderNode->retain();
|
|
|
|
m_pDisplayRenderNode->setVisible(m_bVisible);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
Node *DisplayManager::getDisplayRenderNode()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
return m_pDisplayRenderNode;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
int DisplayManager::getCurrentDisplayIndex()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
return m_iDisplayIndex;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DecorativeDisplay *DisplayManager::getCurrentDecorativeDisplay()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
return m_pCurrentDecoDisplay;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DecorativeDisplay *DisplayManager::getDecorativeDisplayByIndex( int index)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
return (DecorativeDisplay *)m_pDecoDisplayList->getObjectAtIndex(index);
|
2013-06-07 10:52:32 +08:00
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
void DisplayManager::initDisplayList(BoneData *boneData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
CC_SAFE_DELETE(m_pDecoDisplayList);
|
|
|
|
m_pDecoDisplayList = Array::create();
|
|
|
|
m_pDecoDisplayList->retain();
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
CS_RETURN_IF(!boneData);
|
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
Object *object = NULL;
|
2013-09-13 18:07:37 +08:00
|
|
|
Array *displayDataList = &boneData->displayDataList;
|
2013-06-06 12:02:54 +08:00
|
|
|
CCARRAY_FOREACH(displayDataList, object)
|
|
|
|
{
|
2013-09-15 19:08:45 +08:00
|
|
|
DisplayData *displayData = (DisplayData *)object;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DecorativeDisplay *decoDisplay = DecorativeDisplay::create();
|
2013-06-06 12:02:54 +08:00
|
|
|
decoDisplay->setDisplayData(displayData);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
DisplayFactory::createDisplay(m_pBone, decoDisplay);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
m_pDecoDisplayList->addObject(decoDisplay);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
}
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
bool DisplayManager::containPoint(Point &point)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
if(!m_bVisible || m_iDisplayIndex < 0)
|
2013-06-07 10:52:32 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-06 12:02:54 +08:00
|
|
|
bool ret = false;
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
switch (m_pCurrentDecoDisplay->getDisplayData()->displayType)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
case CS_DISPLAY_SPRITE:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* First we first check if the point is in the sprite content rect. If false, then we continue to check
|
|
|
|
* the contour point. If this step is also false, then we can say the bone not contain this point.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-07-12 14:11:55 +08:00
|
|
|
Point outPoint = Point(0, 0);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
Sprite *sprite = (Sprite *)m_pCurrentDecoDisplay->getDisplay();
|
2013-06-20 14:15:53 +08:00
|
|
|
sprite = (Sprite *)sprite->getChildByTag(0);
|
2013-06-07 10:52:32 +08:00
|
|
|
|
|
|
|
ret = CC_SPRITE_CONTAIN_POINT_WITH_RETURN(sprite, point, outPoint);
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
bool DisplayManager::containPoint(float x, float y)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-07-12 14:11:55 +08:00
|
|
|
Point p = Point(x, y);
|
2013-06-06 12:02:54 +08:00
|
|
|
return containPoint(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
void DisplayManager::setVisible(bool visible)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
if(!m_pDisplayRenderNode)
|
2013-06-07 10:52:32 +08:00
|
|
|
return;
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
m_bVisible = visible;
|
|
|
|
m_pDisplayRenderNode->setVisible(visible);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
bool DisplayManager::isVisible()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
return m_bVisible;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
Size DisplayManager::getContentSize()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
CS_RETURN_IF(!m_pDisplayRenderNode) Size(0, 0);
|
|
|
|
return m_pDisplayRenderNode->getContentSize();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
Rect DisplayManager::getBoundingBox()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
CS_RETURN_IF(!m_pDisplayRenderNode) Rect(0, 0, 0, 0);
|
|
|
|
return m_pDisplayRenderNode->getBoundingBox();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
Point DisplayManager::getAnchorPoint()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
CS_RETURN_IF(!m_pDisplayRenderNode) Point(0, 0);
|
|
|
|
return m_pDisplayRenderNode->getAnchorPoint();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-09-15 19:08:45 +08:00
|
|
|
Point DisplayManager::getAnchorPointInPoints()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-09-13 18:07:37 +08:00
|
|
|
CS_RETURN_IF(!m_pDisplayRenderNode) Point(0, 0);
|
|
|
|
return m_pDisplayRenderNode->getAnchorPointInPoints();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-13 18:07:37 +08:00
|
|
|
NS_CC_EXT_ARMATURE_END
|