RhythmGame 1.4.3
Loading...
Searching...
No Matches
6. Show what is about to play

Previous | Tutorial | Next: Gameplay

Goal: Show the selected chart or course and let the player start or cancel.

Install docs/examples/theme-tutorial/06-decide/ and choose it for Decide.

Download 06-decide or open the source folder.

Receive the play data

The game supplies a GameplayContext as gameplay. Declare it as a required property on the root object.

required property GameplayContext gameplay

gameplay.chartData describes the current chart. gameplay.course contains the course definition when playing a course and is undefined for a single chart. Check if (gameplay.course) before using its name or other course data.

Label {
Layout.fillWidth: true
text: screen.gameplay.course
? screen.gameplay.course.name : screen.gameplay.chartData.title
font.pixelSize: 32
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
}

Decide and gameplay receive the same context object. In a course, the current chart and players change as stages advance.

Accept or cancel with the standard flow

Pass the supplied context to StandardDecideFlow. It starts gameplay after five seconds. Enter or a bound play key also starts, while Escape or START+SELECT cancels.

StandardDecideFlow {
id: flow
gameplay: screen.gameplay
pointerEnabled: false
}

pointerEnabled: false disables the flow's whole-screen mouse area because the example has explicit buttons. The buttons call start() and cancel(), so they share the flow's protection against duplicate transitions.

1import QtQuick
2import QtQuick.Controls.FluentWinUI3
3import QtQuick.Layouts
4import RhythmGameQml
5
6Pane {
7 id: screen
8
9 // [context]
10 required property GameplayContext gameplay
11 // [context]
12
13 // [decide-flow]
14 StandardDecideFlow {
15 id: flow
16 gameplay: screen.gameplay
17 pointerEnabled: false
18 }
19 // [decide-flow]
20
21 ColumnLayout {
22 anchors.centerIn: parent
23 width: Math.max(0, parent.width - 48)
24 spacing: 16
25
26 // [title]
27 Label {
28 Layout.fillWidth: true
29 text: screen.gameplay.course
30 ? screen.gameplay.course.name : screen.gameplay.chartData.title
31 font.pixelSize: 32
32 wrapMode: Text.Wrap
33 horizontalAlignment: Text.AlignHCenter
34 }
35
36 // [title]
37
38 Button {
39 Layout.alignment: Qt.AlignHCenter
40 text: qsTr("Start")
41 onClicked: flow.start()
42 }
43
44 Button {
45 Layout.alignment: Qt.AlignHCenter
46 text: qsTr("Back")
47 onClicked: flow.cancel()
48 }
49 }
50}

Set timeoutMillis to 0 to wait for input. You can change the layout while keeping the flow. Override startAction or cancelAction only when you need to replace the whole transition.

Understand which screens remain open

The game keeps selection in memory while you play, which preserves its current folder and focus. Starting play replaces decide with gameplay. The game later shows a result above gameplay, then resumes gameplay after the result closes so the flow can advance or return to selection.

Arena rounds open gameplay directly, without decide. StandardMultiplayerFlow handles that transition when the session prepares a round.

If you add shortcuts or audio players yourself, bind their behavior to the screen's enabled state. They don't inherit it like child Items do.

Try starting and cancelling

Try starting once by button and once by waiting for the timeout. Then select another chart and cancel. Check a course too, if one is available in your tables. The title should describe the course before its first stage starts.