44
CanvasItem() : game(0), m_overlay(0) { }
46
CanvasItem(b2World* world);
45
47
virtual ~CanvasItem();
46
48
///load your settings from the KConfigGroup, which represents a course.
47
49
virtual void load(KConfigGroup *) {}
130
132
//AFTER THIS LINE follows what I have inserted during the refactoring
136
CollisionFlag = 1 << 0,
137
KinematicSimulationFlag = 1 << 1,
138
DynamicSimulationFlag = 1 << 2
142
///The object is immovable.
144
///The object is immovable, but other objects can interact with it.
145
CollisionSimulation = CollisionFlag,
146
///The object moves according to its kinematic state.
147
KinematicSimulation = CollisionSimulation | KinematicSimulationFlag,
148
///Other objects can collide with the shape of this object.
149
DynamicSimulation = KinematicSimulation | DynamicSimulationFlag
132
152
QList<Kolf::Shape*> shapes() const { return m_shapes; }
133
153
Kolf::Overlay* overlay(bool createIfNecessary = true);
135
155
void addShape(Kolf::Shape* shape);
156
///Configure how this object will participate in physical simulation.
157
void setSimulationType(CanvasItem::SimulationType type);
136
158
///Creates the optimal overlay for this object. The implementation does not have to propagate its properties to the overlay, as the overlay is updated just after it has been created.
137
159
///@warning Do not actually call this function from subclass implementations. Use overlay() instead.
138
160
virtual Kolf::Overlay* createOverlay() { return 0; } //TODO: make this pure virtual when all CanvasItems are QGraphicsItems and implement createOverlay() (and then disallow createOverlay() == 0)
139
161
///This function should be called whenever the value of an object's property changes. This will most prominently cause the overlay to be updated (if it exists).
140
162
void propagateUpdate();
164
friend class Kolf::Shape; //for access to m_body
142
167
Kolf::Overlay* m_overlay;
143
168
QList<Kolf::Shape*> m_shapes;
169
CanvasItem::SimulationType m_simulationType;
146
172
//WARNING: pos() is at center (not at top-left edge of bounding rect!)
147
173
class EllipticalCanvasItem : public Tagaro::SpriteObjectItem, public CanvasItem
150
EllipticalCanvasItem(bool withEllipse, const QString& spriteKey, QGraphicsItem* parent = 0);
176
EllipticalCanvasItem(bool withEllipse, const QString& spriteKey, QGraphicsItem* parent, b2World* world);
151
177
QGraphicsEllipseItem* ellipseItem() const { return m_ellipseItem; }
153
179
virtual bool contains(const QPointF& point) const;