Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

SlotMachineModel

The SlotMachineModel allows to easily generate reels with randomly shuffled items for a SlotMachine. More...

Import Statement: import Felgo 4.0
Inherits:

QtObject

Properties

Detailed Description

When you use the SlotMachineModel as the model for a SlotMachineReel, the reel automatically fills up with randomly ordered items based on your configuration. You can define the available items and their frequency on the reel by using the symbols property.

 import Felgo
 import QtQuick

 SlotMachineModel {
   // syntax: "type": { [frequency: <int>, ][data: <var>] }
   symbols: {
     "symbol1":  { frequency: 3 }, // 3 x symbol1
     "symbol2":  { frequency: 3 }, // 3 x symbol2
     "symbol3":  { frequency: 2 }, // 2 x symbol3
     "symbol4":  { frequency: 2 }, // 2 x symbol4
     "symbol5":  { frequency: 1 }  // 1 x symbol5
   }
 }

The symbols property holds the configuration of the symbol types and their frequencies. It has to be an object that defines the different symbols as properties. You then have the possibility to set the frequency as properties for each symbol object. The syntax "type": { [frequency: <int>, ][data: <var>] } has the following meaning: The symbol type has to appear frequency times on the reel. If the frequency is not set, it will appear only once. You can also add some custom data, that is passed to the delegate that renders the symbols. In the example above, the symbol "symbol1" is placed three times on the reel and there is no additional data set for any of the symbols.

You can use the data property for everything you want to pass on to the delegate. Every type of data is allowed, for example an integer, a string value, an array or even an object. The following example defines a SlotMachine component, that uses the SlotMachineModel and passes on a string that contains the filename for an image. We then display this image by defining a delegate.

 import Felgo
 import QtQuick

 SlotMachine {
   model: SlotMachineModel {
     // syntax: "type": { [frequency: <int>, ][data: <var>] }
     symbols: {
       "symbol1":  { frequency: 3, data: "symbol1.png" },     // 3 x symbol1
       "symbol2":  { frequency: 3, data: "symbol2_new.png" }, // 3 x symbol
       "symbol3":  { frequency: 2, data: "symbol3.png" },     // 2 x symbol3
       "symbol4":  { frequency: 2, data: "symbol4.jpg" },     // 2 x symbol4
       "symbol5":  { frequency: 1, data: "sym5.png" }         // 1 x symbol5
     }
   }
   delegate: Image {
     source: modelData.data
   }
 }

The data property contains the filename of each symbol. We want to use this filename as the source for our images. You can access the data of your symbol configuration by using the modelData.data property in the delegate. The available properties are:

  • modelData.type - contains the symbol name, e.g. "symbol1", "symbol2", "symbol3", ...
  • modelData.frequency - holds the frequency value of the symbol.
  • modelData.data - contains the custom user data of the symbol.

Also, when you use the SlotMachineModel, the symbols are placed on the reel in a random order per default. You can deactivate this feature with the shuffle property.

For a more detailed description and examples on how to set up a SlotMachine please visit the documentation page of the SlotMachine component. The section How to Make a Slot Machine for Slot Games especially focuses on the usage of the SlotMachineModel to make casino slot games.

Property Documentation

shuffle : bool

If set to true, the symbols of the slot machine reel are randomly shuffled. By default, this feature is activated.


symbols : var

The symbols property holds configuration of the different symbols and their frequencies on a reel. It is expected to be a JavaScript object that defines the symbols as properties that contain objects for the symbol data. The special symbol data property frequency defines the number of occurrences of the symbol on each reel. The symbol property data may be used to pass additional data to the delegate.


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded