VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Particle.h
1 /*
2  * Copyright (C) 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef PARTICLE_H
18 #define PARTICLE_H
19 
20 #include <QColor>
21 #include <QPointF>
22 
23 class ParticleLayer;
24 
34 class Particle {
35 public:
40  Particle(ParticleLayer* layer);
41  virtual ~Particle();
42 
46  bool isDestroyed() const { return mDestroyed; }
50  void destroy();
51 
52 protected:
62  void createNewParticle(const QPointF& position, const QPointF& velocity, const QColor& color);
63 
74  void mapToExistingParticle(int index);
75 
76 private:
77  ParticleLayer* mLayer = nullptr;
78  bool mDestroyed = false;
79 };
80 
81 #endif // PARTICLE_H
Particle(ParticleLayer *layer)
Constructs a new Particle.
void mapToExistingParticle(int index)
Associates this Particle with an existing LiquidFun particle in the b2ParticleSystem.
bool isDestroyed() const
Returns whether or not destroy() was already called.
Definition: Particle.h:46
Wrapper around a LiquidFun particle.
Definition: Particle.h:34
void destroy()
Destroys the associated LiquidFun particle, removing it from the b2ParticleSystem.
void createNewParticle(const QPointF &position, const QPointF &velocity, const QColor &color)
Constructs a new LiquidFun particle in the particle system associated with this wrapper, using the specified position, velocity, and color.
Wrapper around a b2ParticleSystem, which represents an independent layer of particles.
Definition: ParticleLayer.h:32