14.2Cocos2d-x 中的粒子系统(笔记);14.2.1 ParticleBatchNode;

前端之家收集整理的这篇文章主要介绍了14.2Cocos2d-x 中的粒子系统(笔记);14.2.1 ParticleBatchNode;前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1,批处理类ParticleBatchNode

2,粒子系统类ParticleSystem

3,粒子系统子类 ParticleSystemQuad



爆炸效果:ParticleExplosion;

火球效果: ParticleFire




14.2.1 粒子批处理类ParticleBatchNode

initWithFile


initWithTexture

disableParticle;

setBlendFunc/getBlendFunc;

updateAllAtlasIndexes;

increaseAtlasCapacityTo;

getCurrentIndex;

searchNewPositionInChildernForZ;

代码实例:

bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
	// 创建精灵类
	auto sprite = Sprite::create("taotaoahui.jpg");
	//sprite->setPosition(ccp(visibleSize.width / 2,visibleSize.height / 2));
	sprite->setAnchorPoint(ccp(0,0));
	addChild(sprite,1);


   // ParticleBatchNode 使用方法,
	 auto _emitter = ParticleSystemQuad::create("Particles/taotao.xml.particle.plist");// 首先创建ParticleSystemQuad或者ParticleSystem
	 _emitter->retain();
	 auto batch = ParticleBatchNode::createWithTexture(_emitter->getTexture());
	 batch->addChild(_emitter);
	 batch->setPosition(ccp(visibleSize.width /2,visibleSize.height /2 ));	// sjt
	 this->addChild(batch,10);
    

    return true;
}

猜你在找的Cocos2d-x相关文章