Slot Machine in Qt Quick
Unsolved
QML and Qt Quick
-
Hello, can I make slot game with QML? Is there an example of this, I found something like this, but I need to use Felgo for this, can't we do this with pure QML?
-
Any idea ?
-
Hi @NullByte,
Perhaps you can start by investigating the use of the tumbler component to make your slot machibe: https://doc.qt.io/qt-5/qml-qtquick-controls2-tumbler.html
Regards
-
@NullByte : I don't have any example implementing thins. But, with little effort, you can generate a random number and set the currentIndex for every Tumbler component.
But I'm not sure how you can increase the speed to have a movement effect when incrementing the currentIndex.
he movement effect can also be done by quickly incrementing the currentIndex.import QtQuick import QtQuick.Window import QtQuick.Controls ApplicationWindow { property var numItens: 5 Rectangle { anchors.fill: parent Row { Tumbler { id: tumbler1 model: numItens wrap: true } Tumbler { id: tumbler2 model: numItens wrap: true } Tumbler { id: tumbler3 model: numItens wrap: true } } Timer { id: incTimer1 property var counter: 0 property var frequency: 2 interval: 1000 / frequency repeat: true running: counter != 0 onTriggered: { tumbler1.currentIndex = counter % numItens; counter = counter-1 console.debug(incTimer1.counter + " " + tumbler1.currentIndex) } } MouseArea { id: playArea anchors.fill: parent onPressed: { incTimer1.startIndex = incTimer1.counter incTimer1.counter = 5*incTimer1.frequency + Math.floor(Math.random() * numItens) // 5 seconds + X variable time console.debug(incTimer1.counter) } } } }