Introduction
This sample shows how to create a "Memory Game" in Intuiface. It's a game where a certain number of matching cards are placed face-down in a random order. The player can flip any two cards at a time. If the cards match, the player scores one point. If they don't match, the cards are flipped face-down. The goal is to uncover all the matching pairs in the shortest amount of time.
There are two versions of this sample experience that you can download in Composer
- Memory Game: This is the latest version, using a TypeScript-based Interface Asset. Use this version with Intuiface Player 8 and above on any of the operating systems supported by Intuiface.
- Memory Game - Player Classic: This is the original version, using a JavaScript-based Interface Asset. Only use this version with Player Classic.
Although the overall principle and rules are the same, there is a slight difference between the two versions in how the cards are dynamically loaded.
Loading Cards - Player 8 & above
In this version, the TypeScript-based Memory Game Interface Asset (IA) has an action named "Add card media" that you need to call once for each pair of cards you wish to add to the game.
The screenshot below shows that the action is called six times, each with a different image, creating a game of 12 cards (six pairs of two cards).
Calling these "Add card media" actions must be done only once and should occur when first launching the experience.
If you want to change the cards, call the "Clear cards list" action, then call "Add card media" to add new card images.
Loading Cards - Player Classic
In this version, the JavaScript-based MemoryGame Interface Asset (IA) will dynamically look for images in a subfolder located next to the IA on the file system.
To change these images, proceed as follows:
- Download the “Memory Game” sample to your PC and save a local copy.
- Locate the “Images” folder associated with the Memory Game interface asset.
Using File Explorer, navigate to the local copy of the “Memory Game” sample. Then, in the project folder, navigate into the folder Files\InterfaceAssets\MemoryGame\Images. For example, the path on your PC may beC:\Users\[YOUR USER NAME]\Documents\Intuiface\Memory Game\Files\InterfaceAssets\MemoryGame\Images
- Replace the images in this Images folder with your own. Add as many images of any size as you like. The experience will automatically create two cards for every image found in the folder, like in this example:
Common mechanisms between the two game versions
In both versions, the Memory Game IA implements logic to do things such as
- set a read-only Board blocked boolean property that enables you to prevent a user from flipping a third card if two non-matching cards are already flipped.
- raise a trigger when two cards have been flipped and are a match.
- raise a trigger when two cards have been flipped and are not a match.
- raise a trigger when all cards have been flipped, and the game is won.
NOTE: If you would like multiple Memory Games in a single experience, please refer to the example in this Intuiface User Community post.
Comments
0 comments
Article is closed for comments.