Example #1
0
bool RGBMatrix::loadXML(const QDomElement& root)
{
    if (root.tagName() != KXMLQLCFunction)
    {
        qWarning() << Q_FUNC_INFO << "Function node not found";
        return false;
    }

    if (root.attribute(KXMLQLCFunctionType) != typeToString(Function::RGBMatrix))
    {
        qWarning() << Q_FUNC_INFO << "Function is not an RGB matrix";
        return false;
    }

    /* Load matrix contents */
    QDomNode node = root.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();

        if (tag.tagName() == KXMLQLCFunctionSpeed)
        {
            loadXMLSpeed(tag);
        }
        else if (tag.tagName() == KXMLQLCRGBAlgorithm)
        {
            setAlgorithm(RGBAlgorithm::loader(doc(), tag));
        }
        else if (tag.tagName() == KXMLQLCRGBMatrixFixtureGroup)
        {
            setFixtureGroup(tag.text().toUInt());
        }
        else if (tag.tagName() == KXMLQLCFunctionDirection)
        {
            loadXMLDirection(tag);
        }
        else if (tag.tagName() == KXMLQLCFunctionRunOrder)
        {
            loadXMLRunOrder(tag);
        }
        else if (tag.tagName() == KXMLQLCRGBMatrixStartColor)
        {
            setStartColor(QColor::fromRgb(QRgb(tag.text().toUInt())));
        }
        else if (tag.tagName() == KXMLQLCRGBMatrixEndColor)
        {
            setEndColor(QColor::fromRgb(QRgb(tag.text().toUInt())));
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown RGB matrix tag:" << tag.tagName();
        }

        node = node.nextSibling();
    }

    return true;
}
void Tutorial::Crash()// draws the animation for a crash and pasticles that fly out from there
{
	//animation code
	auto spritecache = SpriteFrameCache::getInstance();
	spritecache->addSpriteFramesWithFile("GameScreen/explosion.plist");
	cocos2d::SpriteFrame* spriteFrame = spritecache->getSpriteFrameByName("explosion0.png");
	cocos2d::Vector<cocos2d::Sprite *> m_aiSprites;
	cocos2d::Vector<cocos2d::SpriteFrame*> m_animFrames;
	for (int i = 0; i < 23; i++)
	{
		// Get a SpriteFrame using a name from the spritesheet .plist file.
		m_animFrames.pushBack(spritecache->getSpriteFrameByName("explosion" + std::to_string(i) + ".png"));
	}
	// Create the animation out of the frames.
	Animation* animation = Animation::createWithSpriteFrames(m_animFrames, 0.065);
	Animate* animate = Animate::create(animation);
	// Create a sprite using any one of the SpriteFrames
	// This is so we get a sprite of the correct dimensions.
	auto sprite = Sprite::createWithSpriteFrame(m_animFrames.at(0));
	// Run and repeat the animation.
	sprite->setScale(3.0f);
	sprite->runAction(RepeatForever::create(animate));
	sprite->setPosition(Vec2(player->getPosition().x, player->getPosition().y - 5));
	this->addChild(sprite, 10);
	m_aiSprites.pushBack(sprite);


	//code for the particles that will be coloured orange
	auto size = Director::getInstance()->getWinSize();
	auto m_emitter = ParticleExplosion::createWithTotalParticles(900);
	m_emitter->setDuration(-1);
	m_emitter->setGravity(Point(0, -240));
	m_emitter->setAngle(0);
	m_emitter->setAngleVar(180);
	m_emitter->setRadialAccel(25);
	m_emitter->setRadialAccelVar(0);
	m_emitter->setTangentialAccel(10);
	m_emitter->setTangentialAccelVar(0);
	m_emitter->setPosVar(Point(1, 0));
	m_emitter->setLife(0.25);
	m_emitter->setLifeVar(0.50);
	m_emitter->setStartSpin(0);
	m_emitter->setStartSpinVar(0);
	m_emitter->setEndSpin(0);
	m_emitter->setEndSpinVar(0);
	m_emitter->setStartColor(Color4F(212, 73, 0, 1));
	m_emitter->setStartColorVar(Color4F(0, 0, 0, 0));
	m_emitter->setEndColor(Color4F(212, 73, 0, 1));
	m_emitter->setEndColorVar(Color4F(0, 0, 0, 0));
	m_emitter->setStartSize(20.0f);
	m_emitter->setStartSizeVar(0);
	m_emitter->setEndSize(15.0f);
	m_emitter->setEndSizeVar(0);
	m_emitter->setEmissionRate(275);
	m_emitter->setPosition(Vec2(player->getPosition().x, player->getPosition().y - 15));
	addChild(m_emitter, 10);
}
Example #3
0
void ParticlePerformTest4::doTest()
{
    auto s = Director::getInstance()->getWinSize();
    auto particleSystem = (ParticleSystem*) getChildByTag(kTagParticleSystem);

    // duration
    particleSystem->setDuration(-1);

    // gravity
    particleSystem->setGravity(Vec2(0,-90));

    // angle
    particleSystem->setAngle(90);
    particleSystem->setAngleVar(0);

    // radial
    particleSystem->setRadialAccel(0);
    particleSystem->setRadialAccelVar(0);

    // speed of particles
    particleSystem->setSpeed(180);
    particleSystem->setSpeedVar(50);

    // emitter position
    particleSystem->setPosition(Vec2(s.width/2, 100));
    particleSystem->setPosVar(Vec2(s.width/2,0));

    // life of particles
    particleSystem->setLife(2.0f);
    particleSystem->setLifeVar(1);

    // emits per frame
    particleSystem->setEmissionRate(particleSystem->getTotalParticles() / particleSystem->getLife());

    // color of particles
    Color4F startColor(0.5f, 0.5f, 0.5f, 1.0f);
    particleSystem->setStartColor(startColor);

    Color4F startColorVar(0.5f, 0.5f, 0.5f, 1.0f);
    particleSystem->setStartColorVar(startColorVar);

    Color4F endColor(0.1f, 0.1f, 0.1f, 0.2f);
    particleSystem->setEndColor(endColor);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f);   
    particleSystem->setEndColorVar(endColorVar);

    // size, in pixels
    particleSystem->setEndSize(64.0f);
    particleSystem->setStartSize(64.0f);
    particleSystem->setEndSizeVar(0);
    particleSystem->setStartSizeVar(0);

    // additive
    particleSystem->setBlendAdditive(false);

}
//The constructor.
Particle::Particle()
{
    //Setting the default values.
    setPosition(Vector3(0, 0, 0));
    setVelocity(Vector3(0, 0, 0));
    setStartColor(Vector4(1, 1, 1, 1));
    setEndColor(Vector4(1, 1, 1, 1));
    setStartSize(1);
    setEndSize(1);
    setLifetime(1);
}
Example #5
0
void Sensors::refresh(void) {

  scene::Main *p_scene_main = static_cast<scene::Main *>(this->getParent());
  p_scene_main->attachWaitAnimation();

  auto p_panel =
      this->_p_contents->getChildByName<ui::Layout *>("panelBackground");

  // last updated at
  auto label_last_updated_at =
      p_panel->getChildByName<ui::Text *>("txtLastUpdatedAt");
  label_last_updated_at->setString(
      lib::network::DataStoreSingleton::getInstance()
          ->getLastUpdatedAtToFormatString());

  auto p_tab_world = p_panel->getChildByName<LayerGradient *>("panelWorld");
  auto p_tab_favorite =
      p_panel->getChildByName<LayerGradient *>("panelFavorite");

  const Color3B enbale_color = Color3B(30, 144, 255);
  const Color3B disable_color = Color3B(191, 191, 191);

  if (this->task_id == Task_Id_World) {
    p_tab_world->setStartColor(enbale_color);
    p_tab_favorite->setStartColor(disable_color);
  } else if (this->task_id == Task_Id_Favorite) {
    p_tab_world->setStartColor(disable_color);
    p_tab_favorite->setStartColor(enbale_color);
  }

  // clear list
  // ひょっとすると消さないで現在の値を更新する必要があるかも
  auto p_list_view = p_panel->getChildByName<ui::ListView *>("listSensors");
  p_list_view->removeAllChildren();

  this->showSensorListOneOfEach();

  this->updateSortType();
}
//The complete constructor.
Particle::Particle(Vector3 position, Vector3 velocity, Vector4 startColor,
                   Vector4 endColor, float startSize,
                   float endSize, float lifetime)
{
    //Setting the values passed in.
    setPosition(position);
    setVelocity(velocity);
    setStartColor(startColor);
    setEndColor(endColor);
    setStartSize(startSize);
    setEndSize(endSize);
    setLifetime(lifetime);
}
Example #7
0
bool RGBMatrix::copyFrom(const Function* function)
{
    const RGBMatrix* mtx = qobject_cast<const RGBMatrix*> (function);
    if (mtx == NULL)
        return false;

    setFixtureGroup(mtx->fixtureGroup());
    if (mtx->algorithm() != NULL)
        setAlgorithm(mtx->algorithm()->clone());
    else
        setAlgorithm(NULL);
    setStartColor(mtx->startColor());
    setEndColor(mtx->endColor());

    return Function::copyFrom(function);
}
Example #8
0
LayerExtendedBlendOpacityTest::LayerExtendedBlendOpacityTest()
{
    auto layer1 = LayerGradient::create(Color4B(255, 0, 0, 255), Color4B(255, 0, 255, 255));
    layer1->setContentSize(Size(80, 80));
    layer1->setPosition(Vec2(50,50));
    addChild(layer1);
    
    auto layer2 = LayerGradient::create(Color4B(0, 0, 0, 127), Color4B(255, 255, 255, 127));
    layer2->setContentSize(Size(80, 80));
    layer2->setPosition(Vec2(100,90));
    addChild(layer2);
    
    auto layer3 = LayerGradient::create();
    layer3->setContentSize(Size(80, 80));
    layer3->setPosition(Vec2(150,140));
    layer3->setStartColor(Color3B(255, 0, 0));
    layer3->setEndColor(Color3B(255, 0, 255));
    layer3->setStartOpacity(255);
    layer3->setEndOpacity(255);
    layer3->setBlendFunc( BlendFunc::ALPHA_NON_PREMULTIPLIED );
    addChild(layer3);
}
Head_ParticalEffect

void addParticalToHead(Node* node)
{
	Vec2 pos[4];
	pos[0] = Vec2(5, 75);
	pos[1] = Vec2(75, 75);
	pos[2] = Vec2(75, 5);
	pos[3] = Vec2(5, 5);

	for (int i = 0; i < 2; i++)
	{
		auto   partNode = ParticleSystemQuad::createWithTotalParticles(60);
		partNode->setTexture(TextureCache::getInstance()->addImage("GameUI/CommonUI/fire.png"));//设置粒子图
		partNode->setDuration(-1);//发射时长

		// life of particles
		partNode->setLife(0.5f);//粒子生命
		partNode->setLifeVar(0.1f);

		partNode->setEmissionRate(partNode->getTotalParticles() / partNode->getLife());//发射器发射频率
		partNode->setPositionType(ParticleSystem::PositionType::FREE);//设置发射器的跟随模式

		// color of particles
		partNode->setStartColor(ccc4f(0.76f, 0.25f, 0.12f, 1.0f));//起始颜色
		partNode->setStartColorVar(ccc4f(0.1f, 0.1f, 0.1f, 0.0f));

		partNode->setEndColor(ccc4f(1.0f, 1.0f, 1.0f, 1.0f));//结束颜色
		partNode->setEndColorVar(ccc4f(0.1f, 0.1f, 0.1f, 0.1f));

		// size, in pixels
		partNode->setStartSize(15);//粒子大小
		partNode->setStartSizeVar(3);
		partNode->setEndSize(0);
		partNode->setEndSizeVar(3);

		// angle
		partNode->setAngle(0);//发射器角度
		partNode->setAngleVar(0);

		// speed of particles
		partNode->setSpeed(0);//粒子速度
		partNode->setSpeedVar(0);

		// emitter position
		partNode->setPosVar(ccp(0, 0));//发射器位置变化

		partNode->setBlendAdditive(true);

		node->addChild(partNode);
		partNode->setTag(PARTICALTAG);
		auto move0 = MoveTo::create(1.f, pos[0]);
		auto move1 = MoveTo::create(1.f, pos[1]);
		auto move2 = MoveTo::create(1.f, pos[2]);
		auto move3 = MoveTo::create(1.f, pos[3]);

		if (i == 0)
		{
			partNode->setPosition(pos[0]);
			partNode->runAction(RepeatForever::create(Sequence::create(move1, move2, move3, move0, nullptr)));
		}
		else
		{
			partNode->setPosition(pos[2]);
			partNode->runAction(RepeatForever::create(Sequence::create(move3, move0, move1, move2, nullptr)));
		}

	}
}
Example #10
0
void TestScene::emit()
{
    auto _emitter = ParticleSystemQuad::createWithTotalParticles(100);
    addChild(_emitter, 10);

    _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png"));
    _emitter->setDuration(1.f);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // angle
    _emitter->setAngle(90);
    _emitter->setAngleVar(0);

    // speed of particles
    _emitter->setSpeed(260);
    _emitter->setSpeedVar(0);

    // radial
    _emitter->setRadialAccel(-260);
    _emitter->setRadialAccelVar(0);

    // tagential
    _emitter->setTangentialAccel(00);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    //    _emitter->setPosition( Vec2(160,240) );
    _emitter->setPosVar({2,10});

    // life of particles
    _emitter->setLife(1);
    _emitter->setLifeVar(0);

    // spin of particles
    _emitter->setStartSpin(10000);
    _emitter->setStartSizeVar(360);
    _emitter->setEndSpin(0);
    _emitter->setEndSpinVar(360);

    // color of particles
    Color4F startColor(0.f, 0.5f, 0.f, 1.0f);
    _emitter->setStartColor(startColor);

    Color4F startColorVar(0.f, 0.1f, 0.f, 1.0f);
    _emitter->setStartColorVar(startColorVar);

    Color4F endColor(0.1f, 0.5f, 0.1f, 1.0f);
    _emitter->setEndColor(endColor);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.2f);
    _emitter->setEndColorVar(endColorVar);

    // size, in pixels
    _emitter->setStartSize(5.0f);
    _emitter->setStartSizeVar(1.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive
    _emitter->setBlendAdditive(true);
    //addChild(_emitter);
    _emitter->setPosition(genPos({0.5,0.5}));
    //    _emitter->runAction(RotateBy::create(10.f, 1000));
}
Example #11
0
void BaseScene::putEmitter3(Vec2 pos){
	m_emitterCreated ++;

	auto _emitter = ParticleSystemQuad::createWithTotalParticles(20);
    //_emitter->retain();
	_emitter->setTag(m_emitterCreated);

    this->addChild(_emitter, 10000);
    ////_emitter->release();    // win32 : Remove this line
    _emitter->setTexture( Director::getInstance()->getTextureCache()->addImage("ui/ball_outer.png") );

	_emitter->setAngleVar(360);

    // duration
    _emitter->setDuration(-1);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // speed of particles
    _emitter->setSpeed(320);
    _emitter->setSpeedVar(80);

    // radial
    _emitter->setRadialAccel(-30);
    _emitter->setRadialAccelVar(-10);

    // tagential
    _emitter->setTangentialAccel(30);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    _emitter->setPosition(pos);
    _emitter->setPosVar(Vec2::ZERO);

    // life of particles
    _emitter->setLife(1.6f);
    _emitter->setLifeVar(0.8f);

    // color of particles
	_emitter->setStartColor(C4F_(E::P.C500, 0.4f));
    _emitter->setStartColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.3f));
    _emitter->setEndColor(C4F_(E::P.C300, 0.3f));
    _emitter->setEndColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.2f));

    // size, in pixels
    _emitter->setStartSize(32.0f);
    _emitter->setStartSizeVar(8.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive

    _emitter->setBlendAdditive(false);
	auto cbStopEmitter = CallFunc::create([this](){m_emitterStopped++; ((ParticleSystemQuad*)this->getChildByTag(m_emitterStopped))->stopSystem();});
	auto cbRemoveEmitter = CallFunc::create([this](){m_emitterReleased++; this->getChildByTag(m_emitterReleased)->removeFromParentAndCleanup(true);});
	_emitter->runAction(Sequence::create(DelayTime::create(0.3f), cbStopEmitter, DelayTime::create(2.0f), cbRemoveEmitter, nullptr));

}
Example #12
0
void LayerRadialGradient::setStartColor(const Color3B& color)
{
    setStartColor(Color4B(color));
}
// on "init" you need to initialize your instance
bool MainMenuScene::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
	pRate = 3.1415926/2;
    // Music By Matthew Pable (http://www.matthewpablo.com/)
    // Licensed under CC-BY 3.0 (http://creativecommons.org/licenses/by/3.0/)
    CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("Star_Chaser.mp3");
    
    SpriteFrameCache::getInstance()->addSpriteFramesWithFile("menu_scene.plist","menu_scene.png");
    SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Particle.plist","Particle.png");
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();
    
    //************ adds Plane ****************
    plane = Plane::create();
    this->addChild(plane, 10);
    this->scheduleUpdate();
    
    //************ adds emission flare ****************
    auto flare = ParticleSystemQuad::create("missileFlare.plist");
    flare->setScale(5);
    float originX = -9.0f;
    float originY = 159.0f;
    float originZ = 9.0f;
    flare->setTotalParticles(50);
    flare->setRotation3D(Vertex3F(-originX,-originY,-originZ));
    flare->setPosition(-39,0);
    flare->setPositionType(tPositionType::GROUPED);
    flare->setStartColor(Color4F(0,0.99,1,1));
    plane->addChild(flare, -1);
    
    auto emis = ParticleSystemQuad::create("menuEmission.plist");
    emis->setScale(3);
    emis->setRotation3D(Vertex3F(-originX,-originY,-originZ));
    emis->setPosition(-40,0);
    emis->setPositionType(tPositionType::GROUPED);
    emis->setRotation(180);
    plane->addChild(emis, -2);

    
    //************ adds vanishing ****************
    auto fileUtil = FileUtils::getInstance();
    auto plistData = fileUtil->getValueMapFromFile("vanishingPoint.plist");
    //auto sf = SpriteFrame::create("bullets.png", Rect(5,8,24,32));
    auto vanishing = ParticleSystemQuad::create(plistData);
    vanishing->setAnchorPoint(Point(0.5f,0.5f));
    vanishing->setPosition(visible_size_macro.width-90,visible_size_macro.height/2 +50);
    this->addChild(vanishing,1,1);
    
    //************* adds background ***********
    auto background = Sprite::createWithSpriteFrameName("mainmenu_BG.png");
    background->setAnchorPoint(Point(0,0));
    this->addChild(background,-1,-1);
    
    //************* adds start game ***********
    auto start_normal=Sprite::createWithSpriteFrameName("start_game.png");
    auto start_pressed=Sprite::createWithSpriteFrameName("start_game.png");
    startgame_item = MenuItemSprite::create(start_normal, start_pressed, CC_CALLBACK_1(MainMenuScene::startgame, this));
    startgame_item->setPosition(visibleSize.width/2,200);
    startgame_item->setScale(1.3);
    
    //************* license *******************
    auto license_normal=Sprite::createWithSpriteFrameName("license.png");
    auto license_pressed=Sprite::createWithSpriteFrameName("license.png");
    license_item = MenuItemSprite::create(license_normal, license_pressed, CC_CALLBACK_1(MainMenuScene::license, this));
    license_item->setPosition(visibleSize.width/2-200,100);
    license_item->setScale(0.7);

    //************* credits ******************
    auto credits_normal=Sprite::createWithSpriteFrameName("credits.png");
    auto credits_pressed=Sprite::createWithSpriteFrameName("credits.png");
    credits_item = MenuItemSprite::create(credits_normal, credits_pressed, CC_CALLBACK_1(MainMenuScene::credits, this));
    credits_item->setPosition(visibleSize.width/2+200,100);
    credits_item->setScale(0.7);

    //************* Menu ******************
    auto menu = Menu::create(startgame_item,license_item,credits_item, NULL);
    menu->setPosition(origin);
    this->addChild(menu,3);
    
    return true;
}
Example #14
0
bool RGBMatrix::loadXML(QXmlStreamReader &root)
{
    if (root.name() != KXMLQLCFunction)
    {
        qWarning() << Q_FUNC_INFO << "Function node not found";
        return false;
    }

    if (root.attributes().value(KXMLQLCFunctionType).toString() != typeToString(Function::RGBMatrixType))
    {
        qWarning() << Q_FUNC_INFO << "Function is not an RGB matrix";
        return false;
    }

    /* Load matrix contents */
    while (root.readNextStartElement())
    {
        if (root.name() == KXMLQLCFunctionSpeed)
        {
            loadXMLSpeed(root);
        }
        else if (root.name() == KXMLQLCRGBAlgorithm)
        {
            setAlgorithm(RGBAlgorithm::loader(doc(), root));
        }
        else if (root.name() == KXMLQLCRGBMatrixFixtureGroup)
        {
            setFixtureGroup(root.readElementText().toUInt());
        }
        else if (root.name() == KXMLQLCFunctionDirection)
        {
            loadXMLDirection(root);
        }
        else if (root.name() == KXMLQLCFunctionRunOrder)
        {
            loadXMLRunOrder(root);
        }
        else if (root.name() == KXMLQLCRGBMatrixStartColor)
        {
            setStartColor(QColor::fromRgb(QRgb(root.readElementText().toUInt())));
        }
        else if (root.name() == KXMLQLCRGBMatrixEndColor)
        {
            setEndColor(QColor::fromRgb(QRgb(root.readElementText().toUInt())));
        }
        else if (root.name() == KXMLQLCRGBMatrixProperty)
        {
            QString name = root.attributes().value(KXMLQLCRGBMatrixPropertyName).toString();
            QString value = root.attributes().value(KXMLQLCRGBMatrixPropertyValue).toString();
            setProperty(name, value);
            root.skipCurrentElement();
        }
        else if (root.name() == KXMLQLCRGBMatrixDimmerControl)
        {
            setDimmerControl(root.readElementText().toInt());
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown RGB matrix tag:" << root.name();
            root.skipCurrentElement();
        }
    }

    return true;
}
void FloatingEffectManager::toast_cure(const cocos2d::Vec2& srcPos, const cocos2d::Vec2& desPos, DDElementType elementType, int level)
{

    const float speed = 300;
    float len = (desPos-srcPos).length();
    if (len == 0) {
        return;
    }
    auto _emitter = ParticleSystemQuad::createWithTotalParticles(500);
    _emitter->setAutoRemoveOnFinish(true);
    _layer->addChild(_emitter, 10);

    _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png"));
    _emitter->setDuration(len/speed);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // angle
    _emitter->setAngle(vector2angel(desPos-srcPos));
    _emitter->setAngleVar(0.5f* std::atan(DDConfig::battleCubeWidth()/len) * 180.f/3.1415926f);

    // speed of particles
    _emitter->setSpeed(speed);
    _emitter->setSpeedVar(0);

    // radial
    _emitter->setRadialAccel(-(speed/(2*len/speed)));
    _emitter->setRadialAccelVar(0);

    // tagential
    _emitter->setTangentialAccel(00);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    //    _emitter->setPosition( Vec2(160,240) );
    _emitter->setPosVar({0,0});

    // life of particles
    _emitter->setLife(2*len/speed);
    _emitter->setLifeVar(0);

    // spin of particles
    _emitter->setStartSpin(720);
    _emitter->setStartSizeVar(360);
    _emitter->setEndSpin(0);
    _emitter->setEndSpinVar(360);

    // color of particles
    Color4F startColor(0.f, 0.5f, 0.f, 0.8f);
    _emitter->setStartColor(startColor);

    Color4F startColorVar(0.f, 0.1f, 0.f, 0.1f);
    _emitter->setStartColorVar(startColorVar);

    Color4F endColor(0.1f, 0.5f, 0.1f, 0.8f);
    _emitter->setEndColor(endColor);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.1f);
    _emitter->setEndColorVar(endColorVar);

    // size, in pixels
    _emitter->setStartSize(3.0f);
    _emitter->setStartSizeVar(1.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive
    _emitter->setBlendAdditive(true);

    _emitter->setPosition(srcPos);
}
void FloatingEffectManager::toast_help_tail(const cocos2d::Vec2& srcPos, const cocos2d::Vec2& desPos, const cocos2d::Color4F& color)
{
    const float time = 0.2;
    float len = (desPos-srcPos).length();
    if (len == 0) {
        return;
    }

    const float speed = len/time;
    auto _emitter = ParticleSystemQuad::createWithTotalParticles(500);
    _emitter->setAutoRemoveOnFinish(true);
    _layer->addChild(_emitter, 10);

    _emitter->setTexture(Director::getInstance()->getTextureCache()->addImage("images/test_lizi.png"));
    _emitter->setDuration(time*5);

    // gravity
    _emitter->setGravity(Vec2::ZERO);

    // angle
    _emitter->setAngle(vector2angel(srcPos-desPos));
    _emitter->setAngleVar(3);

    // speed of particles
    _emitter->setSpeed(speed/5);
    _emitter->setSpeedVar(0);

    // radial
    _emitter->setRadialAccel(0);
    _emitter->setRadialAccelVar(0);

    // tagential
    _emitter->setTangentialAccel(0);
    _emitter->setTangentialAccelVar(0);

    // emitter position
    //    _emitter->setPosition( Vec2(160,240) );
    _emitter->setPosVar({0,0});

    // life of particles
    _emitter->setLife(0.2);
    _emitter->setLifeVar(0);

    // spin of particles
    _emitter->setStartSpin(720);
    _emitter->setStartSizeVar(360);
    _emitter->setEndSpin(0);
    _emitter->setEndSpinVar(360);

    // color of particles
    _emitter->setStartColor(color);

    Color4F startColorVar(0.f, 0.1f, 0.f, 0.1f);
    _emitter->setStartColorVar(startColorVar);

    _emitter->setEndColor(color);

    Color4F endColorVar(0.1f, 0.1f, 0.1f, 0.1f);
    _emitter->setEndColorVar(endColorVar);

    // size, in pixels
    _emitter->setStartSize(2.0f);
    _emitter->setStartSizeVar(1.0f);
    _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

    // emits per second
    _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());

    // additive
    _emitter->setBlendAdditive(true);
    
    _emitter->setPosition(srcPos);
    _emitter->runAction(MoveTo::create(0.1, desPos));
}
Example #17
0
void EquipLongjingView::onShowData()
{
    m_bgNode->removeAllChildren();
    
    auto tbg = CCLoadSprite::loadResource("UI_UseSkill_picture_blackwhite.png");
    auto tBatchNode = CCSpriteBatchNode::createWithTexture(tbg->getTexture());
    int maxHight = CCDirector::sharedDirector()->getWinSize().height;
    int curHight = -500;
    while (curHight<maxHight) {
        auto bg = CCCommonUtils::addFilterSprite("UI_UseSkill_picture_blackwhite.png", CCCommonUtils::covertHSBToRGB(bgColorH[m_page-1], bgColorS[m_page-1], bgColorB[m_page-1]), 0, 1.04, 4.4);
        bg->setAnchorPoint(ccp(0, 1));
        bg->setPosition(ccp(0, curHight));
        curHight += bg->getContentSize().height;
        tBatchNode->addChild(bg);
    }
    m_bgNode->addChild(tBatchNode);
    
    m_parNode->removeAllChildrenWithCleanup(true);
    for (int i=1; i<3; i++) {
        auto particle = ParticleController::createParticle(CCString::createWithFormat("SkillBG_G_%d",i)->getCString());
        if (m_page == 1) {
            particle->setStartColor(ccc4f(0, 1, 0, 1));
        }else if (m_page == 2) {
            particle->setStartColor(ccc4f(0, 0.5, 1, 1));
        }else if (m_page == 3) {
            particle->setStartColor(ccc4f(1, 0, 1, 1));
        }else if (m_page == 4) {
            particle->setStartColor(ccc4f(1, 0.4, 0, 1));
        }else if (m_page == 5) {
            particle->setStartColor(ccc4f(1, 1, 0, 1));
        }
        particle->setPositionY(i==1?-m_extH/2:m_extH/2);
        m_parNode->addChild(particle);
    }
    
    int cellW = 204;
    int offX = 116;
    int offY = 120;
    dataSize = m_curList.size();
    
    int sumH = cellW * (2 + (dataSize-2)/2 );
    if (dataSize%2==0) {
        sumH -= cellW;
    }
    sumH = offY + sumH + offY;
    
    int curY = sumH - offY;
    m_scrollView->getContainer()->removeAllChildren();
    for (int i=0; i<m_curList.size(); i++)
    {
        auto cell = EquipLongjingCell::create(m_curList[i], i);
        if (i==0) {
            cell->setPosition(ccp(offX+cellW, curY));
            curY -= cellW;
        }
        else
        {
            int curX = offX;
            if (i%4==0 || i%4==3) {
                curX += cellW*2;
            }
            if (i%2==0) {
                curY -= cellW;
            }
            cell->setPosition(ccp(curX, curY));
        }
        m_scrollView->addChild(cell);
    }
    
    m_scrollView->setContentSize(CCSize(m_infoNode->getContentSize().width,sumH));
    m_scrollView->setContentOffset(ccp(0, m_infoNode->getContentSize().height - sumH));
    
    m_color1Btn->setEnabled(true);
    m_color2Btn->setEnabled(true);
    m_color3Btn->setEnabled(true);
    m_color4Btn->setEnabled(true);
    m_color5Btn->setEnabled(true);
    if (m_page == 1) {
        m_color1Btn->setEnabled(false);
    }else if (m_page == 2) {
        m_color2Btn->setEnabled(false);
    }else if (m_page == 3) {
        m_color3Btn->setEnabled(false);
    }else if (m_page == 4) {
        m_color4Btn->setEnabled(false);
    }else if (m_page == 5) {
        m_color5Btn->setEnabled(false);
    }
}
void Portal::update(float dt)
{
    auto emitterUnder = dynamic_cast<ParticleSystemQuad*>(this->getChildByName(portalDefs::PARTICLE_UNDER_NAME));
    
    if (emitterUnder && _emitterTop)
    {
        float particleUnderAlphaMultiplier = _particleGlobalAlphaMultiplier;
        float particleTopAlphaMultiplier = _particleGlobalAlphaMultiplier;
        
        if ((_state == ePortalState::ENTERING_PORTAL) || ((_state == ePortalState::OPEN_PORTAL) && _playerIn))
        {
            if (_timerDelay != 0.0f)
            {
                if (_timer != portalDefs::PARTICLE_RESIZE_TIME)
                {
                    _timer++;
                    _emitterTop->setScale(portalDefs::PARTICLE_RESIZE_TIME/_timer);
                }
                _timerDelay--;
            }
            else
            {
                _emitterTop->setScale(portalDefs::PARTICLE_RESIZE_TIME/_timer);
                
                if (!_isEntered)
                {
                    this->playSoundOpen();
                    _isEntered = true;
                }
                
                if ((--_timer) == 30.0f)
                {
                    auto node = static_cast<Node*>(this);
                    
                    std::string nodeName = this->getPortalName();
                    
                    node->setName(nodeName);
                    
                    if (_callback && _callbackListener)
                    {
                        (_callbackListener->*_callback)(node);
                    }
                }
            }
        }
        else if (_state == ePortalState::OPEN_PORTAL)
        {
            particleUnderAlphaMultiplier *= portalDefs::PARTICLE_IDLE_OPACITY_MULTIPLIER;
            particleTopAlphaMultiplier *= portalDefs::PARTICLE_IDLE_OPACITY_MULTIPLIER;
            
            _timerDelay = portalDefs::PARTICLE_DELAY;
            
            if (_timer != portalDefs::PARTICLE_RESIZE_TIME)
            {
                _isEntered = false;
                _timer++;
                _emitterTop->setScale(portalDefs::PARTICLE_RESIZE_TIME/_timer);
            }
        }
        
        float opacityTimer = _timer - (portalDefs::PARTICLE_RESIZE_TIME - portalDefs::PARTICLE_OPACITY_TIME);
        if (opacityTimer <= portalDefs::PARTICLE_OPACITY_TIME)
        {
            particleUnderAlphaMultiplier *= opacityTimer/portalDefs::PARTICLE_OPACITY_TIME;
            particleTopAlphaMultiplier *= 1.0f - opacityTimer/portalDefs::PARTICLE_OPACITY_TIME;
        }
        
        // Update alpha particellari
        Color4F c;
        c = _originalEmitterStartColor;
        emitterUnder->setStartColor(Color4F(c.r, c.g, c.b, c.a * particleUnderAlphaMultiplier));
        _emitterTop->setStartColor(Color4F(c.r, c.g, c.b, c.a * particleTopAlphaMultiplier));
        c = _originalEmitterStartColorVar;
        emitterUnder->setStartColorVar(Color4F(c.r, c.g, c.b, c.a * particleUnderAlphaMultiplier));
        _emitterTop->setStartColorVar(Color4F(c.r, c.g, c.b, c.a * particleTopAlphaMultiplier));
        c = _originalEmitterEndColor;
        emitterUnder->setEndColor(Color4F(c.r, c.g, c.b, c.a * particleUnderAlphaMultiplier));
        _emitterTop->setEndColor(Color4F(c.r, c.g, c.b, c.a * particleTopAlphaMultiplier));
        c = _originalEmitterEndColorVar;
        emitterUnder->setEndColorVar(Color4F(c.r, c.g, c.b, c.a * particleUnderAlphaMultiplier));
        _emitterTop->setEndColorVar(Color4F(c.r, c.g, c.b, c.a * particleTopAlphaMultiplier));
        
        if (particleUnderAlphaMultiplier > 0.0f)
        {
            emitterUnder->setVisible(true);
        }
        else
        {
            emitterUnder->setVisible(false);
        }
        
        if (particleTopAlphaMultiplier > 0.0f)
        {
            _emitterTop->setVisible(true);
        }
        else
        {
            _emitterTop->setVisible(false);
        }
    }
}