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;
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值