cocos2d-x 之 CCParticleBatchNode CCParallaxNode

//不使用 CCParticleBatchNode : 注意比较 左下角的显示信息
for(int i=0; i<10; ++i)
{
    CCParticleSystem* particleSystem = CCParticleSun::create();
    particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("fire.png"));
    particleSystem->setPosition(ccp(150+i*20,160));
    addChild(particleSystem);
}

 

//使用 CCParticleBatchNode : 注意比较 左下角的显示信息
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage("fire.png");
CCParticleBatchNode* particleNode = CCParticleBatchNode::createWithTexture(texture);
for(int i=0; i<10; ++i)
{
    CCParticleSystem* particleSystem = CCParticleSun::create();
    particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("fire.png"));
    particleSystem->setPosition(ccp(150+i*20,160));
    particleNode->addChild(particleSystem);
}
addChild(particleNode);

 

 

 

 

 

//CCParallaxNode  使用 远景 中景 近景 的移动效果

CCSprite* spFront = CCSprite::create("cocos2dbanner.png");
        CCSprite* spMiddle = CCSprite::create("HelloWorld.png");
        CCSprite* spFar = CCSprite::create("background.png");
        
        CCParallaxNode* parallaxNode = CCParallaxNode::create();
        addChild(parallaxNode);

        //近景
        parallaxNode->addChild(spFront,3,ccp(4.8f,0),ccp(spFront->getContentSize().width/2,spFront->getContentSize().height/2));

        //中景
        parallaxNode->addChild(spMiddle,2,ccp(1.2f,0),ccp(spMiddle->getContentSize().width/2,spMiddle->getContentSize().height/2+spFront->getContentSize().height/2));

        //远景
        parallaxNode->addChild(spFar,1,ccp(0.5f,0),ccp(spFar->getContentSize().width/2,spFar->getContentSize().height/2+spFront->getContentSize().height/2+spMiddle->getContentSize().height/2));

        CCActionInterval* go = CCMoveBy::create(8,ccp(-200,0));
        CCActionInterval* goBack = go->reverse();
        CCFiniteTimeAction* seq = CCSequence::create(go,goBack,NULL);
        parallaxNode->runAction(CCRepeatForever::create((CCActionInterval*)seq));

效果图如下:(无动画效果图片 , 想看效果就必须自己动手了 )

转载于:https://www.cnblogs.com/MrGreen/p/3300086.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值