aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/items/qquickspriteimage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/items/qquickspriteimage.cpp')
-rw-r--r--src/declarative/items/qquickspriteimage.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/declarative/items/qquickspriteimage.cpp b/src/declarative/items/qquickspriteimage.cpp
index 36ab73490c..098db67f3a 100644
--- a/src/declarative/items/qquickspriteimage.cpp
+++ b/src/declarative/items/qquickspriteimage.cpp
@@ -250,6 +250,24 @@ struct SpriteVertices {
Default is true.
*/
/*!
+ \qmlproperty string QtQuick2::SpriteImage::goalState
+
+ The name of the Sprite which the animation should move to.
+
+ Sprite states have defined durations and transitions between them, setting goalState
+ will cause it to disregard any path weightings (including 0) and head down the path
+ which will reach the goalState quickest (fewest animations). It will pass through
+ intermediate states on that path, and animate them for their duration.
+
+ If it is possible to return to the goalState from the starting point of the goalState
+ it will continue to do so until goalState is set to "" or an unreachable state.
+*/
+/*! \qmlmethod void QtQuick2::SpriteImage::jumpTo(string sprite)
+
+ This function causes the sprite to jump to the specified state immediately, intermediate
+ states are not played.
+*/
+/*!
\qmlproperty list<Sprite> QtQuick2::SpriteImage::sprites
The sprite or sprites to draw. Sprites will be scaled to the size of this element.
@@ -270,6 +288,22 @@ QQuickSpriteImage::QQuickSpriteImage(QQuickItem *parent) :
this, SLOT(update()));
}
+void QQuickSpriteImage::jumpTo(const QString &sprite)
+{
+ if (!m_spriteEngine)
+ return;
+ m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite), 0, true);
+}
+
+void QQuickSpriteImage::setGoalState(const QString &sprite)
+{
+ if (m_goalState != sprite){
+ m_goalState = sprite;
+ emit goalStateChanged(sprite);
+ m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite));
+ }
+}
+
QDeclarativeListProperty<QQuickSprite> QQuickSpriteImage::sprites()
{
return QDeclarativeListProperty<QQuickSprite>(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear);