summaryrefslogtreecommitdiffstats
path: root/examples/statemachine/errorstate/rocketitem.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-04-30 07:43:13 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-04-30 07:43:13 (GMT)
commit0d33e6e464c324d1b43b08ce7ac0dcd4c216d17e (patch)
tree3e56d4d54a996ee5264c009d9976b2731bbef509 /examples/statemachine/errorstate/rocketitem.cpp
parent0f8de3b0b4ccccbeba97999635eb5716f561fb30 (diff)
downloadQt-0d33e6e464c324d1b43b08ce7ac0dcd4c216d17e.zip
Qt-0d33e6e464c324d1b43b08ce7ac0dcd4c216d17e.tar.gz
Qt-0d33e6e464c324d1b43b08ce7ac0dcd4c216d17e.tar.bz2
Make design better. Remove the Tank interface. This is now an implicit interface
based on the meta-object system.
Diffstat (limited to 'examples/statemachine/errorstate/rocketitem.cpp')
-rw-r--r--examples/statemachine/errorstate/rocketitem.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/statemachine/errorstate/rocketitem.cpp b/examples/statemachine/errorstate/rocketitem.cpp
index 85d436b..c324980 100644
--- a/examples/statemachine/errorstate/rocketitem.cpp
+++ b/examples/statemachine/errorstate/rocketitem.cpp
@@ -10,8 +10,8 @@
#define M_PI 3.14159265358979323846
#endif
-RocketItem::RocketItem()
- : m_direction(0.0), m_distance(300.0)
+RocketItem::RocketItem(QObject *parent)
+ : GameItem(parent), m_direction(0.0), m_distance(300.0)
{
}
@@ -48,8 +48,11 @@ void RocketItem::idle(qreal elapsed)
if (requestedPosition == nextPosition) {
setPos(nextPosition);
} else {
- if (TankItem *tankItem = qgraphicsitem_cast<TankItem *>(collidedItem))
- tankItem->hitByRocket();
+ if (GameItem *gameItem = qgraphicsitem_cast<GameItem *>(collidedItem)) {
+ TankItem *tankItem = qobject_cast<TankItem *>(gameItem);
+ if (tankItem != 0)
+ tankItem->hitByRocket();
+ }
scene()->removeItem(this);
delete this;