1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the Declarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qquicksprite_p.h"
48 \qmlclass Sprite QQuickSprite
49 \inqmlmodule QtQuick 2
50 \brief The Sprite element represents a sprite animation
54 \qmlproperty int QtQuick2::Sprite::duration
59 \qmlproperty int QtQuick2::Sprite::durationVariation
61 The time between frames can vary by up to this amount.
67 \qmlproperty string QtQuick2::Sprite::name
69 The name of this sprite, for use in the to property of other sprites.
72 \qmlproperty QVariantMap QtQuick2::Sprite::to
74 A list of other sprites and weighted transitions to them,
75 for example {"a":1, "b":2, "c":0} would specify that one-third should
76 transition to sprite "a" when this sprite is done, and two-thirds should
77 transition to sprite "b" when this sprite is done. As the transitions are
78 chosen randomly, these proportions will not be exact. With "c":0 in the list,
79 no sprites will randomly transition to "c", but it wll be a valid path if a sprite
82 If no list is specified, or the sum of weights in the list is zero, then the sprite
83 will repeat itself after completing.
86 \qmlproperty int QtQuick2::Sprite::frames
88 Number of frames in this sprite.
91 \qmlproperty int QtQuick2::Sprite::frameHeight
93 Height of a single frame in this sprite.
96 \qmlproperty int QtQuick2::Sprite::frameWidth
98 Width of a single frame in this sprite.
101 \qmlproperty url QtQuick2::Sprite::source
103 The image source for the animation.
105 If frameHeight and frameWidth are not specified, it is assumed to be a single long row of square frames.
106 Otherwise, it can be multiple contiguous rows or rectangluar frames, when one row runs out the next will be used.
108 Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
109 Q_PROPERTY(int durationVariation READ durationVariance WRITE setDurationVariance NOTIFY durationVarianceChanged)
110 Q_PROPERTY(QVariantMap to READ to WRITE setTo NOTIFY toChanged)
111 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
112 Q_PROPERTY(qreal speedModifiesDuration READ speedModifer WRITE setSpeedModifier NOTIFY speedModifierChanged)
113 Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY framesChanged)
114 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
115 //If frame height or width is not specified, it is assumed to be a single long row of square frames.
116 //Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used.
117 Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged)
118 Q_PROPERTY(int frameWidth READ frameWidth WRITE setFrameWidth NOTIFY frameWidthChanged)
120 QQuickSprite::QQuickSprite(QObject *parent) :
121 QQuickStochasticState(parent)
122 , m_generatedCount(0)