Created
February 18, 2014 08:23
-
-
Save pjc0247/9066832 to your computer and use it in GitHub Desktop.
CCAnimate with ccBlendFunc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "CCAnimateWithBlending.h" | |
using namespace cocos2d; | |
CCAnimateWithBlending *CCAnimateWithBlending::create( | |
CCAnimation *animation, ccBlendFunc blendFunc){ | |
CCAnimateWithBlending *p = new CCAnimateWithBlending(); | |
if( p != NULL && p->initWithAnimation(animation, blendFunc) ){ | |
p->autorelease(); | |
return p; | |
} | |
CC_SAFE_DELETE(p); | |
return NULL; | |
} | |
bool CCAnimateWithBlending::initWithAnimation(CCAnimation *animation,ccBlendFunc blendFunc){ | |
bool ret = CCAnimate::initWithAnimation( animation ); | |
if( !ret ) return false; | |
setBlendFunc( blendFunc ); | |
return true; | |
} | |
void CCAnimateWithBlending::update(float dt){ | |
CCAnimate::update(dt); | |
((CCSprite*)m_pTarget)->setBlendFunc( blendFunc ); | |
} | |
CCObject* CCAnimateWithBlending::copyWithZone(CCZone* pZone){ | |
CCZone* pNewZone = NULL; | |
CCAnimateWithBlending* pRet = NULL; | |
if(pZone && pZone->m_pCopyObject){ | |
pRet = (CCAnimateWithBlending*)(pZone->m_pCopyObject); | |
} | |
else{ | |
pRet = new CCAnimateWithBlending(); | |
pZone = pNewZone = new CCZone(pRet); | |
} | |
CCAnimate::copyWithZone(pZone); | |
pRet->initWithAnimation( getAnimation(), blendFunc ); | |
CC_SAFE_DELETE(pNewZone); | |
return pRet; | |
} | |
ccBlendFunc CCAnimateWithBlending::getBlendFunc(){ | |
return this->blendFunc; | |
} | |
void CCAnimateWithBlending::setBlendFunc(ccBlendFunc blendFunc){ | |
this->blendFunc = blendFunc; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
*/ | |
#ifndef _CC_ANIMATE_WITH_BLENDING_H | |
#define _CC_ANIMATE_WITH_BLENDING_H | |
#include <cocos2d.h> | |
NS_CC_BEGIN | |
/* | |
CCAnimateWithBlending | |
*/ | |
class CCAnimateWithBlending : public CCAnimate //<NSCopying> | |
{ | |
public: | |
static CCAnimateWithBlending * create(CCAnimation *animation, ccBlendFunc blend); | |
virtual bool initWithAnimation(CCAnimation *animation, ccBlendFunc blend); | |
virtual void update(float t); | |
virtual CCObject* copyWithZone(CCZone* pZone); | |
ccBlendFunc getBlendFunc(); | |
void setBlendFunc(ccBlendFunc blendFunc); | |
protected: | |
ccBlendFunc blendFunc; | |
}; | |
NS_CC_END | |
#endif // _CC_ANIMATE_WITH_BLENDING_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment