}
SequentialAnimation {
id: anim
- ScriptAction { script: image.goalState = "falling"; }
+ ScriptAction { script: image.goalSprite = "falling"; }
NumberAnimation { target: image; property: "y"; to: 1480; duration: 12000; }
- ScriptAction { script: {image.goalState = ""; image.jumpTo("still");} }
+ ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} }
PropertyAction { target: image; property: "y"; value: 0 }
}
SpriteImage {
height: 256
anchors.horizontalCenter: parent.horizontalCenter
interpolate: false
- goalState: ""
+ goalSprite: ""
Sprite{
name: "still"
source: "content/Bear0.png"
Default is true.
*/
/*!
- \qmlproperty string QtQuick2::SpriteImage::goalState
+ \qmlproperty string QtQuick2::SpriteImage::goalSprite
+
+ The name of the Sprite which is currently animating.
+*/
+/*!
+ \qmlproperty string QtQuick2::SpriteImage::goalSprite
The name of the Sprite which the animation should move to.
m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite), 0, true);
}
-void QQuickSpriteImage::setGoalState(const QString &sprite)
+void QQuickSpriteImage::setGoalSprite(const QString &sprite)
{
if (m_goalState != sprite){
m_goalState = sprite;
- emit goalStateChanged(sprite);
+ emit goalSpriteChanged(sprite);
m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite));
}
}
m_material->sheetHeight = image.height();
m_material->elementWidth = width();
m_material->elementHeight = height();
+ m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name();
+ emit currentSpriteChanged(m_curState);
int vCount = 4;
int iCount = 6;
m_material->animY = m_spriteEngine->spriteY();
m_material->animWidth = m_spriteEngine->spriteWidth();
m_material->animHeight = m_spriteEngine->spriteHeight();
+ m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name();
+ emit currentSpriteChanged(m_curState);
}
}
Q_OBJECT
Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged)
- Q_PROPERTY(QString goalState READ goalState WRITE setGoalState NOTIFY goalStateChanged)
+ Q_PROPERTY(QString goalSprite READ goalSprite WRITE setGoalSprite NOTIFY goalSpriteChanged)
+ Q_PROPERTY(QString currentSprite READ currentSprite NOTIFY currentSpriteChanged)
//###try to share similar spriteEngines for less overhead?
Q_PROPERTY(QDeclarativeListProperty<QQuickSprite> sprites READ sprites)
Q_CLASSINFO("DefaultProperty", "sprites")
return m_interpolate;
}
- QString goalState() const
+ QString goalSprite() const
{
return m_goalState;
}
+ QString currentSprite() const
+ {
+ return m_curState;
+ }
+
signals:
void runningChanged(bool arg);
void interpolateChanged(bool arg);
- void goalStateChanged(QString arg);
+ void goalSpriteChanged(QString arg);
+ void currentSpriteChanged(QString arg);
public slots:
void jumpTo(const QString &sprite);
- void setGoalState(const QString &sprite);
+ void setGoalSprite(const QString &sprite);
void setRunning(bool arg)
{
bool m_running;
bool m_interpolate;
QString m_goalState;
+ QString m_curState;
};
QT_END_NAMESPACE