summaryrefslogtreecommitdiffstats
path: root/examples/animation/stickman/lifecycle.h
blob: 437e935e51fd981882ec99f1cf963cba03e656c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef LIFECYCLE_H
#define LIFECYCLE_H

#include <Qt>

class StickMan;
class QStateMachine;
class QAnimationGroup;
class QState;
class QAbstractState;
class QAbstractTransition;
class GraphicsView;
class LifeCycle
{
public:
    LifeCycle(StickMan *stickMan, GraphicsView *keyEventReceiver);
    ~LifeCycle();

    void setDeathAnimation(const QString &fileName);
    void setResetKey(Qt::Key key);
    void addActivity(const QString &fileName, Qt::Key key);    

    void start();

private:
    void connectByAnimation(QState *s1, QAbstractState *s2, 
                            QAbstractTransition *transition = 0);
    QState *makeState(QState *parentState, const QString &animationFileName);

    StickMan *m_stickMan;
    QStateMachine *m_machine;
    QAnimationGroup *m_animationGroup;
    GraphicsView *m_keyReceiver;

    QState *m_alive;
    QState *m_dead;
    QState *m_idle;
};

#endif