Time for action - Adding a jump animation

Go to the myscene.h file and add a private qreal m_jumpFactor field. Next, declare a getter, a setter, and a change signal for this field:

public:    //...    qreal jumpFactor() const;    void setJumpFactor(const qreal &jumpFactor);signals:    void jumpFactorChanged(qreal);

In the header file, we declare the jumpFactor property by adding the following code just after the Q_OBJECT macro:

Q_PROPERTY(qreal jumpFactor
           READ jumpFactor
           WRITE setjumpFactor
           NOTIFY jumpFactorChanged)

Here, qreal is the type of the property, jumpFactor is the registered name, and the following three lines register the corresponding member functions of the MyScene class in the property system. We'll need this property to make Benjamin jump, ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.