USING_NS_CC;
class lightCCSprite : public CCSprite { public: static CCSprite *spriteWithfile(const char * filename); virtual voID draw(); };
****************.cpp文件****************** #include "lightCCSprite.h"
CCSprite *lightCCSprite::spriteWithfile(const char * filename){
CCSprite *pobSprite = new lightCCSprite();//这里才会调用draw,而不是CCSprite的draw
if (pobSprite && pobSprite->initWithfile(filename)) { pobSprite->autorelease(); return pobSprite; } CC_SAFE_DELETE(pobSprite);
return NulL; }
voID lightCCSprite::draw(){
//CCSprite::draw();//如果不取消的话如果两个lightCCSPrite对象只有一个会产生亮光
((HelloWorld*)getParent())->darknessLayer->begin();
CC_PROfileR_START_category(kCCProfilercategorySprit
#define kQuadSize sizeof(m_squad.bl)
if (m_pobTexture!= NulL) { glBindTexture(GL_TEXTURE_2D,m_pobTexture->getname()); } else { glBindTexture(GL_TEXTURE_2D,0); }
long offset = (long)&m_squad;
glcolorMask(1.0f,1.0f,1.0f); ((HelloWorld*)getParent())->darknessLayer->end(); } ********************调用处************************* CCSprite *sprite2=lightCCSprite::spriteWithfile("light.png");//继承ccsprite新建对象 sprite2->setposition(ccp(100,200)); this->addChild(sprite2,2); sprite2->runAction(CCRepeatForever::create((CCActionInterval *)CCSequence::create(CCMoveBy::create(3.0f,ccp(300,0)),CCMoveBy::create(0.1f,ccp(-300,NulL)));
darknessLayer = CCRenderTexture::create(size.wIDth,size.height); darknessLayer->setposition(ccp( size.wIDth /2,size.height/2 )); this->addChild(darknessLayer,20); darknessLayer->clear(0,0.5f);//设置黑夜笼罩 *********************最终效果************************
制作光晕特效" name="image_operate_32241410170041285" alt="cocos2d
以上是内存溢出为你收集整理的cocos2d 制作光晕特效全部内容,希望文章能够帮你解决cocos2d 制作光晕特效所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)