summaryrefslogtreecommitdiffstats
path: root/examples/widgets/animation/sub-attaq/torpedo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/animation/sub-attaq/torpedo.cpp')
-rw-r--r--examples/widgets/animation/sub-attaq/torpedo.cpp23
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();
}