Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo Plugins Support › SlotMachine Plugins : how to customize outcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #23879

    Ruby

    I have a 3×3 slot machine, and the config of symbol is : “model: [“A”,”B”,”C”,”D”,”E”]”

    how do I have a customized outcom such as :

    A   B   E

    C   A   A

    E   A   E

     

    I know that I can use “stopAt” function to specify the outcome for each reel, but it can only control the first index for each reel.

    Is there any function to control all position?

    #23891

    Filippo
    Felgo Team

    Hi, stopAt accepts an array of indexes, so you can exactly control where it will stop, but to achieve what you want you’d need to change the underlying model.

     

    I’d suggest to to build your own component using one 3 SlotMachines and dynamically populate their model depending on what you want to display.

     

    #23905

    Ruby

    Thank you. Do you have any example to update model dynamically?

    #23906

    Filippo
    Felgo Team

    Sure, no problem. I’d do something along these lines:

     

    import Felgo 3.0
    import QtQuick 2.0
    
    App {
      SlotMachine {
        anchors.centerIn: parent
        id: slot
        reelCount: 1
        rowCount: 3
    
        defaultReelWidth: 30
        defaultItemHeight: 30
    
        delegate: Item {
          Text {
            text: modelData
            font.pixelSize: 16
          }
        }
    
        MouseArea {
          anchors.fill: parent
          onClicked: slot.display(["B", "Y", "E"])
        }
    
        function display(array) {
          slot.model = ['X', 'X', 'X'].concat(array.concat(['X', 'X', 'X']))
          slot.spin()
          slot.stopAt([slot.model.indexOf(array[0])])
        }
    
        Component.onCompleted: display(["H", "I", "!"])
      }
    }

     

    You can probably try to make it look less fake by padding the original array with random letters instead of the Xs I’m using here.

     

    If you need to keep the 3X3 structure you can use reels as shown here: https://felgo.com/doc/felgo-slotmachine/, or you can stack three SlotMachines side by side.

     

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.