Skip to content

Instantly share code, notes, and snippets.

@pjc0247
Created February 18, 2014 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjc0247/9066832 to your computer and use it in GitHub Desktop.
Save pjc0247/9066832 to your computer and use it in GitHub Desktop.
CCAnimate with ccBlendFunc
#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;
}
/*
*/
#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