1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the examples of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
20 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 ** the names of its contributors may be used to endorse or promote
22 ** products derived from this software without specific prior written
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
42 import QtQuick.Particles 2.0
44 import "content/logic.js" as Logic
50 property var gameState: Logic.newGameState(canvas);
51 property bool passedSplash: false
54 source:"content/gfx/background.png"
55 anchors.bottom: view.bottom
65 source: "content/gfx/catch.png"
82 anchors.bottom: parent.bottom
83 anchors.bottomMargin: 3
89 acceleration: PointDirection{ y: -6; xVariation: 2; yVariation: 2 }
102 GameOverScreen { gameCanvas: canvas }
110 height: childrenRect.height
114 source:"content/gfx/wave.png"
118 source:"content/gfx/wave.png"
120 NumberAnimation on x { from: 0; to: -(wave.width); duration: 16000; loops: Animation.Infinite }
121 SequentialAnimation on y {
122 loops: Animation.Infinite
123 NumberAnimation { from: y - 2; to: y + 2; duration: 1600; easing.type: Easing.InOutQuad }
124 NumberAnimation { from: y + 2; to: y - 2; duration: 1600; easing.type: Easing.InOutQuad }
133 source: "content/gfx/wave.png"
137 source: "content/gfx/wave.png"
139 NumberAnimation on x { from: -(wave2.width); to: 0; duration: 32000; loops: Animation.Infinite }
140 SequentialAnimation on y {
141 loops: Animation.Infinite
142 NumberAnimation { from: y + 2; to: y - 2; duration: 1600; easing.type: Easing.InOutQuad }
143 NumberAnimation { from: y - 2; to: y + 2; duration: 1600; easing.type: Easing.InOutQuad }
148 source: "content/gfx/sunlight.png"
151 anchors.horizontalCenter: parent.horizontalCenter
152 transformOrigin: Item.Top
153 SequentialAnimation on rotation {
154 loops: Animation.Infinite
155 NumberAnimation { from: -10; to: 10; duration: 8000; easing.type: Easing.InOutSine }
156 NumberAnimation { from: 10; to: -10; duration: 8000; easing.type: Easing.InOutSine }
161 source: "content/gfx/sunlight.png"
164 anchors.horizontalCenter: parent.horizontalCenter
165 transformOrigin: Item.Top
166 SequentialAnimation on rotation {
167 loops: Animation.Infinite
168 NumberAnimation { from: 10; to: -10; duration: 8000; easing.type: Easing.InOutSine }
169 NumberAnimation { from: -10; to: 10; duration: 8000; easing.type: Easing.InOutSine }
174 source: "content/gfx/grid.png"
180 anchors.bottom: parent.bottom
181 anchors.bottomMargin: 20
186 InfoBar { anchors.bottom: canvas.top; anchors.bottomMargin: 6; width: parent.width }
192 running: root.countdown < 5
194 onTriggered: root.countdown++
197 model: ["content/gfx/text-blank.png", "content/gfx/text-3.png", "content/gfx/text-2.png", "content/gfx/text-1.png", "content/gfx/text-go.png"]
199 visible: root.countdown <= index
200 opacity: root.countdown == index ? 0.5 : 0.1
201 scale: root.countdown >= index ? 1.0 : 0.0
203 Behavior on opacity { NumberAnimation {} }
204 Behavior on scale { NumberAnimation {} }
210 onStartButtonClicked: root.passedSplash = true
214 property int countdown: 10
220 onTriggered: Logic.startGame(canvas);
225 name: "gameOn"; when: gameState.gameOver == false && passedSplash
226 PropertyChanges { target: view; y: -(height - 960) }
227 StateChangeScript { script: root.countdown = 0; }
228 PropertyChanges { target: gameStarter; running: true }
231 name: "gameOver"; when: gameState.gameOver == true
232 PropertyChanges { target: view; y: 0 }
236 transitions: Transition {
237 NumberAnimation { properties: "x,y"; duration: 1200; easing.type: Easing.OutQuad }