diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-09-04 14:33:40 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-09-04 14:33:40 +0200 |
commit | f255b1e8e297e7e1363921580007145cff574e0d (patch) | |
tree | 9a799be282e6c0d6544d9f8c872073f83e6c0475 /examples/widgets/animation/sub-attaq/torpedo.cpp | |
parent | 7e8705f6632428a8d9a937ab5fe087999347b3dd (diff) | |
parent | bf8fcab8bb92ff534c5cec048d6dbebb3b73a348 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/qt6
Change-Id: I54741635460bb2d8f3fd0be535ee1968d6c442bb
Diffstat (limited to 'examples/widgets/animation/sub-attaq/torpedo.cpp')
-rw-r--r-- | examples/widgets/animation/sub-attaq/torpedo.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/examples/widgets/animation/sub-attaq/torpedo.cpp b/examples/widgets/animation/sub-attaq/torpedo.cpp index 92a3833452..7395aa39ac 100644 --- a/examples/widgets/animation/sub-attaq/torpedo.cpp +++ b/examples/widgets/animation/sub-attaq/torpedo.cpp @@ -50,15 +50,14 @@ //Own #include "torpedo.h" -#include "pixmapitem.h" #include "boat.h" #include "graphicsscene.h" #include "animationmanager.h" #include "qanimationstate.h" -#include <QtCore/QPropertyAnimation> -#include <QtCore/QStateMachine> -#include <QtCore/QFinalState> +#include <QPropertyAnimation> +#include <QStateMachine> +#include <QFinalState> Torpedo::Torpedo() : PixmapItem(QString::fromLatin1("torpedo"),GraphicsScene::Big), currentSpeed(0) @@ -70,11 +69,11 @@ void Torpedo::launch() { QPropertyAnimation *launchAnimation = new QPropertyAnimation(this, "pos"); AnimationManager::self()->registerAnimation(launchAnimation); - launchAnimation->setEndValue(QPointF(x(),qobject_cast<GraphicsScene *>(scene())->sealLevel() - 15)); + launchAnimation->setEndValue(QPointF(x(), qobject_cast<GraphicsScene *>(scene())->sealLevel() - 15)); launchAnimation->setEasingCurve(QEasingCurve::InQuad); - launchAnimation->setDuration(y()/currentSpeed*10); - connect(launchAnimation,&QVariantAnimation::valueChanged,this,&Torpedo::onAnimationLaunchValueChanged); - connect(this,&Torpedo::torpedoExploded, launchAnimation, &QAbstractAnimation::stop); + launchAnimation->setDuration(y() / currentSpeed * 10); + connect(launchAnimation, &QVariantAnimation::valueChanged, this, &Torpedo::onAnimationLaunchValueChanged); + connect(this, &Torpedo::torpedoExploded, launchAnimation, &QAbstractAnimation::stop); //We setup the state machine of the torpedo QStateMachine *machine = new QStateMachine(this); @@ -84,18 +83,18 @@ void Torpedo::launch() launched->setAnimation(launchAnimation); //End - QFinalState *final = new QFinalState(machine); + QFinalState *finalState = new QFinalState(machine); machine->setInitialState(launched); //### Add a nice animation when the torpedo is destroyed - launched->addTransition(this, &Torpedo::torpedoExploded,final); + launched->addTransition(this, &Torpedo::torpedoExploded, finalState); //If the animation is finished, then we move to the final state - launched->addTransition(launched, &QAnimationState::animationFinished, final); + launched->addTransition(launched, &QAnimationState::animationFinished, finalState); //The machine has finished to be executed, then the boat is dead - connect(machine,&QState::finished,this, &Torpedo::torpedoExecutionFinished); + connect(machine, &QState::finished, this, &Torpedo::torpedoExecutionFinished); machine->start(); } |