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