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
56 Time between frames. Use -1 to indicate one sprite frame per rendered frame.
59 \qmlproperty int QtQuick2::Sprite::durationVariation
61 The time between frames can vary by up to this amount. Variation will never decrease the time
62 between frames to less than 0.
68 \qmlproperty string QtQuick2::Sprite::name
70 The name of this sprite, for use in the to property of other sprites.
73 \qmlproperty QVariantMap QtQuick2::Sprite::to
75 A list of other sprites and weighted transitions to them,
76 for example {"a":1, "b":2, "c":0} would specify that one-third should
77 transition to sprite "a" when this sprite is done, and two-thirds should
78 transition to sprite "b" when this sprite is done. As the transitions are
79 chosen randomly, these proportions will not be exact. With "c":0 in the list,
80 no sprites will randomly transition to "c", but it wll be a valid path if a sprite
83 If no list is specified, or the sum of weights in the list is zero, then the sprite
84 will repeat itself after completing.
87 \qmlproperty int QtQuick2::Sprite::frames
89 Number of frames in this sprite.
92 \qmlproperty int QtQuick2::Sprite::frameHeight
94 Height of a single frame in this sprite.
97 \qmlproperty int QtQuick2::Sprite::frameWidth
99 Width of a single frame in this sprite.
102 \qmlproperty url QtQuick2::Sprite::source
104 The image source for the animation.
106 If frameHeight and frameWidth are not specified, it is assumed to be a single long row of square frames.
107 Otherwise, it can be multiple contiguous rows or rectangluar frames, when one row runs out the next will be used.
110 QQuickSprite::QQuickSprite(QObject *parent) :
111 QQuickStochasticState(parent)
112 , m_generatedCount(0)