qtdoc/examples/demos/maroon/content/GameOverScreen.qml

78 lines
1.8 KiB
QML
Raw Normal View History

// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Particles
Item {
id: gameOverScreen
width: 320
height: 400
property GameCanvas gameCanvas
Image {
id: img
source: "gfx/text-gameover.png"
anchors.centerIn: parent
}
ParticleSystem {
anchors.fill: parent
ImageParticle {
id: cloud
source: "gfx/cloud.png"
alphaVariation: 0.25
opacity: 0.25
}
Wander {
xVariance: 100;
pace: 1;
}
Emitter {
id: cloudLeft
width: 160
height: 160
anchors.right: parent.left
emitRate: 0.5
lifeSpan: 12000
velocity: PointDirection{ x: 64; xVariation: 2; yVariation: 2 }
size: 160
}
Emitter {
id: cloudRight
width: 160
height: 160
anchors.left: parent.right
emitRate: 0.5
lifeSpan: 12000
velocity: PointDirection{ x: -64; xVariation: 2; yVariation: 2 }
size: 160
}
}
Text {
maroon in trouble: use qt_add_qml_module + fix bugs Use qt_standard_project_setup and qt_add_qml_module in the CMakeLists.txt file. Fix qmllint warnings: * unqualifed access by adding the required id (note that setting the ids fixed some bugs in the game where the towers were placed on the wrong place on the grid, because the root's x and y coordinate were used instead of the sprite's x and y coordinates) * unqualified access by adding required properties where missing * reformulated custom parsed PropertyChanges to not be custom parsed anymore * fix the runtime warning when using injected parameters by explicitly declaring it via "function (mouse)" * setting ComponentBehavior Bound wherever needed Ignore qmllint warnings: * about unresolved method name 'destroy' that seems to be a bug in qmllint * about unknown properties inside of the logic.js: this is a bug in qmllint and can't be fixed in user projects. In addition: fix the paths be relative to SoundEffect instead of being relative to where the SoundEffect was instantiated and remove the SoundEffect proxy to make the sounds work. This has the side-effect that the games lags because of the poor sound implementation it seems: the output prints `Failed wait for getting sink drained; was draining: true` over and over again when a lots of sounds are happening, like lots of fighting for example. Tracking this via QTBUG-127560. Add extra self-imports "import Maroon" where needed to get the qmake version working, as it does not have the fancy nested qml module that was introduced in 6.8 that fixed this in CMake builds. Adapt the documentation to the new Main.qml file name, the code snippets that references the custom parsed PropertyChanges, and removed the explanation about self-importing the module in Main.qml as that is not needed anymore. Also remove the part about implementing a SoundEffect proxy as that is removed and not needed. Remove the .qmlproject file as it does not know about modules and therefore can't load the demo's Maroon QML Module. Move the Main.qml file into a Window to use QQmlApplicationEngine in the main.cpp file. Pick-to: 6.8 Task-number: QTBUG-100100 Task-number: QTBUG-127560 Change-Id: I79c7b18a6159208608ef97b271fc24fc9fc06230 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-07-05 17:41:58 +00:00
visible: gameOverScreen.gameCanvas != undefined
text: "You saved " + gameOverScreen.gameCanvas.score + " fishes!"
anchors.top: img.bottom
anchors.topMargin: 12
anchors.horizontalCenter: parent.horizontalCenter
font.bold: true
color: "#000000"
opacity: 0.5
}
Image {
source: "gfx/button-play.png"
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
MouseArea {
anchors.fill: parent
maroon in trouble: use qt_add_qml_module + fix bugs Use qt_standard_project_setup and qt_add_qml_module in the CMakeLists.txt file. Fix qmllint warnings: * unqualifed access by adding the required id (note that setting the ids fixed some bugs in the game where the towers were placed on the wrong place on the grid, because the root's x and y coordinate were used instead of the sprite's x and y coordinates) * unqualified access by adding required properties where missing * reformulated custom parsed PropertyChanges to not be custom parsed anymore * fix the runtime warning when using injected parameters by explicitly declaring it via "function (mouse)" * setting ComponentBehavior Bound wherever needed Ignore qmllint warnings: * about unresolved method name 'destroy' that seems to be a bug in qmllint * about unknown properties inside of the logic.js: this is a bug in qmllint and can't be fixed in user projects. In addition: fix the paths be relative to SoundEffect instead of being relative to where the SoundEffect was instantiated and remove the SoundEffect proxy to make the sounds work. This has the side-effect that the games lags because of the poor sound implementation it seems: the output prints `Failed wait for getting sink drained; was draining: true` over and over again when a lots of sounds are happening, like lots of fighting for example. Tracking this via QTBUG-127560. Add extra self-imports "import Maroon" where needed to get the qmake version working, as it does not have the fancy nested qml module that was introduced in 6.8 that fixed this in CMake builds. Adapt the documentation to the new Main.qml file name, the code snippets that references the custom parsed PropertyChanges, and removed the explanation about self-importing the module in Main.qml as that is not needed anymore. Also remove the part about implementing a SoundEffect proxy as that is removed and not needed. Remove the .qmlproject file as it does not know about modules and therefore can't load the demo's Maroon QML Module. Move the Main.qml file into a Window to use QQmlApplicationEngine in the main.cpp file. Pick-to: 6.8 Task-number: QTBUG-100100 Task-number: QTBUG-127560 Change-Id: I79c7b18a6159208608ef97b271fc24fc9fc06230 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-07-05 17:41:58 +00:00
onClicked: gameOverScreen.gameCanvas.gameOver = false//This will actually trigger the state change in Main.qml
}
}
}