Forum Discussion
Help Needed: Block Third Card Click and Same Card Re-Click Before Matching is Complete
Hi everyone š
Iāve been working on a memory game project in Storyline for quite a while, and Iām stuck on an issue thatās holding me back from completing it.
Iād love your help with this:
How can I prevent the user from either:
- Clicking a third card before the two selected cards are checked for a match, or
- Clicking again on the same card they just opened before completing the pair?
I tried handling this using a variable called lock_clicks, but unfortunately I couldnāt get it to work as expected. š
Iāve created variables and triggers to control card states and feedback (match/mismatch), and everything works fineāexcept for this part.
š Iāve attached my project file here, in case it helps to review the setup.
Thanks so much in advance! Your support would really help me finish this project š
3 Replies
- MathNotermans-9Community Member
Your approach using image states has a big issue. The only way to disable an image from being clickable is setting it to disabled ( or blocking it with some element on top ). Seeing if i can get that done in an easy ( non javascript ) approach.
- MathNotermans-9Community Member
First step in getting this working properly is removing the states and just use plain images and add triggers to them. Front ( brown shape ) side of the card has a trigger to hide itself.
The image is hidden below the brown shape. So becomes visible then.
That image has a trigger to show the appropriate brown shape.As you see i name all elements. Making it easier to get things organized.
RULE 1: Always NAME layers properlyNext step is adding a variable 'cardsClicked'.
Then we add a trigger to both the all front and all cards.On the front the variable gets 1 added and on the card itself 1 is subtracted.
Now we have a value we can use as a condition to prevent clicking a third card. - NedimCommunity Member
You can approach this issue from multiple angles. Math provided valuable suggestions worth considering when starting the project from scratch to simplify the process.
There's no need to create a custom 'Active' state for the cards; instead, utilize the built-in 'Selected' state. This approach eliminates the necessity for triggers that change the card's state to 'Active' upon selection, as the 'Selected' state will automatically activate.
Create a variable (e.g., cardsRevealed) to count the number of cards currently selected based on their 'Selected' state. When matching cards are selected, hide them. Use another layer 1 second long for some sort a delay, allowing time to display other messages and process actions on the base layer. Reset the cardsRevealed variable to 0 to restart the process.
The primary challenge was ensuring the correct state changes for feedback messages. I addressed this by implementing triggers that immediately activate the 'One card clicked' state when any card is selected. Subsequently, additional triggers display the 'You found a match' message when two matching cards are selected and the 'cardsRevealed' variable equals 2. If the conditions are not met, the 'Nope, try again' state is activated on another layer when the timeline starts and the Normal state is activated when the timeline ends.Please refer to the attached story file for more details.