SlotMachineModel

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

Import Statement: import VPlay 2.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 VPlay 2.0
 import QtQuick 2.0

 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 VPlay 2.0
 import QtQuick 2.0

 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.


Videos

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support