states.h Example File
demos/sub-attaq/states.h
#ifndef STATES_H
#define STATES_H
#include <QtCore/QState>
#include <QtCore/QSignalTransition>
#include <QtCore/QPropertyAnimation>
#include <QtGui/QKeyEventTransition>
#include <QtCore/QSet>
class GraphicsScene;
class Boat;
class SubMarine;
class QStateMachine;
class PlayState : public QState
{
public:
PlayState(GraphicsScene *scene, QState *parent = 0);
~PlayState();
protected:
void onEntry(QEvent *);
private :
GraphicsScene *scene;
QStateMachine *machine;
int currentLevel;
int score;
QState *parallelChild;
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(QEvent *);
private :
void initializeLevel();
GraphicsScene *scene;
PlayState *game;
};
class PauseState : public QState
{
public:
PauseState(GraphicsScene *scene, QState *parent = 0);
protected:
void onEntry(QEvent *);
void onExit(QEvent *);
private :
GraphicsScene *scene;
Boat *boat;
};
class LostState : public QState
{
public:
LostState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
protected:
void onEntry(QEvent *);
void onExit(QEvent *);
private :
GraphicsScene *scene;
PlayState *game;
};
class WinState : public QState
{
public:
WinState(GraphicsScene *scene, PlayState *game, QState *parent = 0);
protected:
void onEntry(QEvent *);
void onExit(QEvent *);
private :
GraphicsScene *scene;
PlayState *game;
};
class UpdateScoreState : public QState
{
public:
UpdateScoreState(PlayState *game, QState *parent);
private:
QPropertyAnimation *scoreAnimation;
PlayState *game;
};
class UpdateScoreTransition : public QSignalTransition
{
public:
UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target);
protected:
virtual bool eventTest(QEvent *event);
private:
PlayState * game;
GraphicsScene *scene;
};
class WinTransition : public QSignalTransition
{
public:
WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target);
protected:
virtual bool eventTest(QEvent *event);
private:
PlayState * game;
GraphicsScene *scene;
};
class CustomSpaceTransition : public QKeyEventTransition
{
public:
CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key);
protected:
virtual bool eventTest(QEvent *event);
private:
PlayState *game;
int key;
};
#endif // STATES_H