mirror of https://github.com/axmolengine/axmol.git
Add CCRemoveSelf Action
This commit is contained in:
parent
f6742c3bcd
commit
af9e3442c6
|
@ -191,24 +191,29 @@ CCObject* CCToggleVisibility::copyWithZone(CCZone *pZone)
|
|||
//
|
||||
// Remove Self
|
||||
//
|
||||
CCRemoveSelf * CCRemoveSelf::create()
|
||||
CCRemoveSelf * CCRemoveSelf::create(bool isNeedCleanUp /*= true*/)
|
||||
{
|
||||
CCRemoveSelf *pRet = new CCRemoveSelf();
|
||||
|
||||
if (pRet) {
|
||||
if (pRet && pRet->init(isNeedCleanUp)) {
|
||||
pRet->autorelease();
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
bool CCRemoveSelf::init(bool isNeedCleanUp) {
|
||||
m_bIsNeedCleanUp = isNeedCleanUp;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCRemoveSelf::update(float time) {
|
||||
CC_UNUSED_PARAM(time);
|
||||
m_pTarget->removeFromParentAndCleanup(true);
|
||||
m_pTarget->removeFromParentAndCleanup(m_bIsNeedCleanUp);
|
||||
}
|
||||
|
||||
CCFiniteTimeAction *CCRemoveSelf::reverse() {
|
||||
return (CCFiniteTimeAction*) (CCRemoveSelf::create());
|
||||
return (CCFiniteTimeAction*) (CCRemoveSelf::create(m_bIsNeedCleanUp));
|
||||
}
|
||||
|
||||
CCObject* CCRemoveSelf::copyWithZone(CCZone *pZone) {
|
||||
|
@ -223,6 +228,7 @@ CCObject* CCRemoveSelf::copyWithZone(CCZone *pZone) {
|
|||
}
|
||||
|
||||
CCActionInstant::copyWithZone(pZone);
|
||||
pRet->init(m_bIsNeedCleanUp);
|
||||
CC_SAFE_DELETE(pNewZone);
|
||||
return pRet;
|
||||
}
|
||||
|
|
|
@ -122,9 +122,12 @@ public:
|
|||
virtual CCFiniteTimeAction * reverse(void);
|
||||
virtual CCObject* copyWithZone(CCZone *pZone);
|
||||
public:
|
||||
|
||||
/** Allocates and initializes the action */
|
||||
static CCRemoveSelf * create();
|
||||
/** create the action */
|
||||
static CCRemoveSelf * create(bool isNeedCleanUp = true);
|
||||
/** init the action */
|
||||
bool init(bool isNeedCleanUp);
|
||||
protected:
|
||||
bool m_bIsNeedCleanUp;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue