zoukankan      html  css  js  c++  java
  • 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));

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

  • 相关阅读:
    maxsdk sample中3dsexp.rc点不开并提示specstrings.h中找不到sal.h解法
    安装max plugin wizard
    max plugin wizard,project creation faild解法
    unity, 由5.2.1f1升级到5.3.5f1,2d物理不正常解法
    maxscript,#号和$号
    maxscript,执行选中代码片段
    maxscript,MAXScript Listener下输入print "hi"为什么输出两次
    editplus查找替换的正则表达式应用
    命令行创建畸形文件夹+畸形目录管理工具(DeformityPath)
    费曼技巧——高速学习的方法
  • 原文地址:https://www.cnblogs.com/MrGreen/p/3300086.html
Copyright © 2011-2022 走看看