From 19c9c38d28cdaafcc1b496027f53dcd1914037cf Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 17 Apr 2011 19:54:02 +0200 Subject: get rid of two dynamic_casts and use qgraphicitem_cast which is A LOT faster (it makes use of static casts) --- pacman-c++/gameentity.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pacman-c++/gameentity.h') diff --git a/pacman-c++/gameentity.h b/pacman-c++/gameentity.h index 2fde095..92b485e 100644 --- a/pacman-c++/gameentity.h +++ b/pacman-c++/gameentity.h @@ -4,6 +4,7 @@ #include "constants.h" #include "pixmapitem.h" #include +#include class Actor; @@ -13,6 +14,12 @@ class Actor; class GameEntity : public PixmapItem { +public: + enum + { + Type = UserType + 1 + }; + public: GameEntity(Color::Color color = Color::none, QGraphicsItem *parent = 0); GameEntity(QGraphicsItem *parent); @@ -52,7 +59,14 @@ public: virtual void onDie(Actor *) {}; + /* enable the use of qgraphicsitem_cast with this item */ + int type() const + { + return m_type; + } + protected: + int m_type; bool m_eaten; Color::Color m_color; }; -- cgit v1.2.3