VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
CircleBody.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 CIRCLEBODY_H
18 #define CIRCLEBODY_H
19 
20 #include "Body.h"
21 
26 class CircleBody : public Body {
27  Q_OBJECT
28 
32  Q_PROPERTY(float radius READ getRadius WRITE setRadius NOTIFY radiusChanged)
33 
34 public:
35 
39  explicit CircleBody(QObject* parent = nullptr);
40 
44  float getRadius() const { return mRadius; }
45 
50  void setRadius(float value);
51 
52 signals:
56  void radiusChanged();
57 
58 protected:
63  virtual void forEachShape(const std::function<void(b2Shape*)>& func) override;
64 
65 private:
66  float mRadius = 1.0f;
67 };
68 Q_DECLARE_METATYPE(CircleBody*)
69 
70 #endif // CIRCLEBODY_H
float getRadius() const
Returns radius.
Definition: CircleBody.h:44
A QObject container for a Box2D b2Body.
Definition: Body.h:57
void setRadius(float value)
Sets radius.
void radiusChanged()
Emitted when radius changes.
CircleBody(QObject *parent=nullptr)
Constructs a CircleBody.
A QObject container for a Box2D b2Body that represents a circle.
Definition: CircleBody.h:26
virtual void forEachShape(const std::function< void(b2Shape *)> &func) override
Calls func on the b2Shape that represents this CircleBody.
QObject * parent() const
float radius
The radius of the CircleBody.
Definition: CircleBody.h:32