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

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

	}
}