aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp18
-rw-r--r--src/quick/items/qquickanimatedsprite_p.h3
2 files changed, 18 insertions, 3 deletions
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
index 7110351cc7..204900177c 100644
--- a/src/quick/items/qquickanimatedsprite.cpp
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -237,19 +237,23 @@ struct AnimatedSpriteVertices {
/*!
\qmlproperty qreal QtQuick2::AnimatedSprite::frameRate
- Frames per second to show in the animation. Values below 0 are invalid.
+ Frames per second to show in the animation. Values equal to or below 0 are invalid.
If frameRate is valid then it will be used to calculate the duration of the frames.
If not, and frameDuration is valid , then frameDuration will be used.
+
+ Changing this parameter will restart the animation.
*/
/*!
\qmlproperty int QtQuick2::AnimatedSprite::frameDuration
- Duration of each frame of the animation. Values below 0 are invalid.
+ Duration of each frame of the animation. Values equal to or below 0 are invalid.
If frameRate is valid then it will be used to calculate the duration of the frames.
If not, and frameDuration is valid, then frameDuration will be used.
+
+ Changing this parameter will restart the animation.
*/
/*!
@@ -314,6 +318,8 @@ struct AnimatedSpriteVertices {
If frameSync is set to true, it overrides both frameRate and frameDuration.
Default is false.
+
+ Changing this parameter will restart the animation.
*/
/*!
@@ -383,6 +389,11 @@ void QQuickAnimatedSprite::start()
return;
m_curLoop = 0;
m_timestamp.start();
+ if (m_spriteEngine) {
+ m_spriteEngine->stop(0);
+ m_spriteEngine->updateSprites(0);
+ m_spriteEngine->start(0);
+ }
m_running = true;
emit runningChanged(true);
update();
@@ -393,6 +404,7 @@ void QQuickAnimatedSprite::stop()
if (!m_running)
return;
m_running = false;
+ m_pauseOffset = 0;
emit runningChanged(false);
}
@@ -550,7 +562,7 @@ void QQuickAnimatedSprite::prepareNextFrame()
if (m_node == 0) //error creating node
return;
- uint timeInt = m_timestamp.elapsed() + m_pauseOffset;
+ int timeInt = m_timestamp.elapsed() + m_pauseOffset;
qreal time = timeInt / 1000.;
m_material->elementHeight = height();
m_material->elementWidth = width();
diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h
index 708f94b7ec..fb00136baa 100644
--- a/src/quick/items/qquickanimatedsprite_p.h
+++ b/src/quick/items/qquickanimatedsprite_p.h
@@ -249,6 +249,7 @@ public slots:
if (m_sprite->m_frameSync != arg) {
m_sprite->setFrameSync(arg);
emit frameSyncChanged(arg);
+ restart();
}
}
@@ -302,6 +303,7 @@ public slots:
if (m_sprite->m_frameRate != arg) {
m_sprite->setFrameRate(arg);
emit frameRateChanged(arg);
+ restart();
}
}
@@ -310,6 +312,7 @@ public slots:
if (m_sprite->m_frameDuration != arg) {
m_sprite->setFrameDuration(arg);
emit frameDurationChanged(arg);
+ restart();
}
}