MCPcopy Create free account
hub / github.com/axmolengine/axmol / initWithTotalParticles

Method initWithTotalParticles

core/2d/ParticleExamples.cpp:90–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90bool ParticleFire::initWithTotalParticles(int numberOfParticles)
91{
92 if (ParticleSystemQuad::initWithTotalParticles(numberOfParticles))
93 {
94 // duration
95 _duration = DURATION_INFINITY;
96
97 // Gravity Mode
98 this->_emitterMode = Mode::GRAVITY;
99
100 // Gravity Mode: gravity
101 this->modeA.gravity.setZero();
102
103 // Gravity Mode: radial acceleration
104 this->modeA.radialAccel = 0;
105 this->modeA.radialAccelVar = 0;
106
107 // Gravity Mode: speed of particles
108 this->modeA.speed = 60;
109 this->modeA.speedVar = 20;
110
111 // starting angle
112 _angle = 90;
113 _angleVar = 10;
114
115 // emitter position
116 Vec2 winSize = _director->getWinSize();
117 this->setPosition(winSize.width / 2.0f, 60.0f);
118 this->_posVar.set(40.0f, 20.0f);
119
120 // life of particles
121 _life = 3;
122 _lifeVar = 0.25f;
123
124 // size, in pixels
125 _startSize = 54.0f;
126 _startSizeVar = 10.0f;
127 _endSize = START_SIZE_EQUAL_TO_END_SIZE;
128
129 // emits per frame
130 _emissionRate = _totalParticles / _life;
131
132 // color of particles
133 _startColor.r = 0.76f;
134 _startColor.g = 0.25f;
135 _startColor.b = 0.12f;
136 _startColor.a = 1.0f;
137 _startColorVar.r = 0.0f;
138 _startColorVar.g = 0.0f;
139 _startColorVar.b = 0.0f;
140 _startColorVar.a = 0.0f;
141 _endColor.r = 0.0f;
142 _endColor.g = 0.0f;
143 _endColor.b = 0.0f;
144 _endColor.a = 1.0f;
145 _endColorVar.r = 0.0f;
146 _endColorVar.g = 0.0f;
147 _endColorVar.b = 0.0f;

Callers 1

Calls 9

getDefaultTextureFunction · 0.85
setEmitterModeFunction · 0.85
setPosVarFunction · 0.85
setBlendAdditiveMethod · 0.80
Vec2Class · 0.70
setSpeedFunction · 0.70
setZeroMethod · 0.45
setPositionMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected