}
QQuickSpriteEngine::QQuickSpriteEngine(QObject *parent)
- : QQuickStochasticEngine(parent), m_startedImageAssembly(false)
+ : QQuickStochasticEngine(parent), m_startedImageAssembly(false), m_loaded(false)
{
}
QQuickSpriteEngine::QQuickSpriteEngine(QList<QQuickSprite*> sprites, QObject *parent)
- : QQuickStochasticEngine(parent), m_startedImageAssembly(false)
+ : QQuickStochasticEngine(parent), m_startedImageAssembly(false), m_loaded(false)
{
foreach (QQuickSprite* sprite, sprites)
m_states << (QQuickStochasticState*)sprite;
int QQuickSpriteEngine::spriteState(int sprite)
{
+ if (!m_loaded)
+ return 0;
int state = m_things[sprite];
if (!m_sprites[state]->m_generatedCount)
return state;
int QQuickSpriteEngine::spriteStart(int sprite)
{
- if (!m_duration[sprite])
+ if (!m_duration[sprite] || !m_loaded)
return m_timeOffset;
int state = m_things[sprite];
if (!m_sprites[state]->m_generatedCount)
int QQuickSpriteEngine::spriteFrames(int sprite)
{
+ if (!m_loaded)
+ return 1;
int state = m_things[sprite];
if (!m_sprites[state]->m_generatedCount)
return m_sprites[state]->frames();
int QQuickSpriteEngine::spriteDuration(int sprite)//Full duration, not per frame
{
- if (!m_duration[sprite])
+ if (!m_duration[sprite] || !m_loaded)
return m_duration[sprite];
int state = m_things[sprite];
if (!m_sprites[state]->m_generatedCount)
int QQuickSpriteEngine::spriteY(int sprite)
{
+ if (!m_loaded)
+ return 0;
int state = m_things[sprite];
if (!m_sprites[state]->m_generatedCount)
return m_sprites[state]->m_rowY;
int QQuickSpriteEngine::spriteX(int sprite)
{
+ if (!m_loaded)
+ return 0;
int state = m_things[sprite];
if (!m_sprites[state]->m_generatedCount)
return m_sprites[state]->m_rowStartX;
{
if (m_startedImageAssembly)
return;
+ m_loaded = false;
//This could also trigger the start of the image loading in Sprites, however that currently happens in Sprite::setSource
qDebug() << "Assembled image output to: " << fPath.arg(acc);
#endif
+ m_loaded = true;
+ m_startedImageAssembly = false;
return image;
}
void QQuickSpriteEngine::restart(int index) //Reimplemented to recognize and handle pseudostates
{
bool randomStart = (m_startTimes[index] == NINF);
- if (m_sprites[m_things[index]]->frameSync()) {//Manually advanced
+ if (m_loaded && m_sprites[m_things[index]]->frameSync()) {//Manually advanced
m_startTimes[index] = 0;
if (randomStart && m_sprites[m_things[index]]->m_generatedCount)
m_startTimes[index] += qrand() % m_sprites[m_things[index]]->m_generatedCount;
void QQuickSpriteEngine::advance(int idx) //Reimplemented to recognize and handle pseudostates
{
+ if (!m_loaded) {
+ qWarning() << QLatin1String("QQuickSpriteEngine: Trying to advance sprites before sprites finish loading. Ignoring directive");
+ return;
+ }
+
if (idx >= m_things.count())
return;//TODO: Proper fix(because this has happened and I just ignored it)
if (m_duration[idx] == 0) {
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//QTBUG-24797
+import QtQuick 2.0
+
+Rectangle {
+ width: 800
+ height: 800
+
+ SpriteSequence {
+ id: mysprite
+ sprites: [s1,s2]
+ scale: 2
+ height: 200
+ width: 200
+ anchors.centerIn: parent
+ }
+
+ Component.onCompleted: mysprite.jumpTo("running")
+ Sprite {
+ id: s1
+ name: "standing"
+ frameCount: 12
+ frameDuration: 80
+ source: "squarefacesprite.png"
+ }
+
+ Sprite {
+ id: s2
+ name: "running"
+ frameCount: 6
+ frameDuration: 80
+ source: "squarefacesprite.png"
+ }
+}