summaryrefslogtreecommitdiffstats
path: root/examples/animation/sub-attaq/states.h
diff options
context:
space:
mode:
Diffstat (limited to 'examples/animation/sub-attaq/states.h')
-rw-r--r--examples/animation/sub-attaq/states.h31
1 files changed, 30 insertions, 1 deletions
diff --git a/examples/animation/sub-attaq/states.h b/examples/animation/sub-attaq/states.h
index 52d4ffa..8dbdf86 100644
--- a/examples/animation/sub-attaq/states.h
+++ b/examples/animation/sub-attaq/states.h
@@ -47,10 +47,12 @@
#include "qstate.h"
#include "qsignaltransition.h"
#include "qpropertyanimation.h"
+#include "qkeyeventtransition.h"
#else
#include <QState>
#include <QSignalTransition>
#include <QPropertyAnimation>
+# include <QKeyEventTransition>
#endif
#include <QSet>
@@ -64,7 +66,6 @@ class PlayState : public QState
public:
PlayState(GraphicsScene *scene, QState *parent = 0);
~PlayState();
- void initializeLevel();
protected:
void onEntry();
@@ -79,8 +80,22 @@ private :
friend class UpdateScoreState;
friend class UpdateScoreTransition;
friend class WinTransition;
+ friend class CustomSpaceTransition;
friend class WinState;
friend class LostState;
+ friend class LevelState;
+};
+
+class LevelState : public QState
+{
+public:
+ LevelState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
+protected:
+ void onEntry();
+private :
+ void initializeLevel();
+ GraphicsScene *scene;
+ PlayState *game;
};
class PauseState : public QState
@@ -140,6 +155,7 @@ protected:
virtual bool eventTest(QEvent *event) const;
private:
PlayState * game;
+ GraphicsScene *scene;
};
//These transtion test if we have won the game
@@ -151,6 +167,19 @@ protected:
virtual bool eventTest(QEvent *event) const;
private:
PlayState * game;
+ GraphicsScene *scene;
+};
+
+//These transtion is true if one level has been completed and the player want to continue
+ class CustomSpaceTransition : public QKeyEventTransition
+{
+public:
+ CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key);
+protected:
+ virtual bool eventTest(QEvent *event) const;
+private:
+ PlayState *game;
+ int key;
};
#endif // STATES_H