Hi! I have 4 pairs of cards arranged in a matrix like a memory game. I would like that every time that the match starts, the cards take a different place inside that matrix. I know the Shuffle option in a form but I would like to use that outside a form.
Does someone knows how to shuffle images in the beginning of a scene?
I've created some games where I need to shuffle elements. The way I always do this is to place my elements in an array, and then shuffle the order of the array. Of course, you have to use javascript to do this.
Here is the function I wrote to shuffle the array:
function shuffle(array) { var elementsRemaining = array.length, temp, randomIndex; while (elementsRemaining > 1) { randomIndex = Math.floor(Math.random() * elementsRemaining--); if (randomIndex != elementsRemaining) { temp = array[elementsRemaining]; array[elementsRemaining] = array[randomIndex]; array[randomIndex] = temp; } } return array; }
Sounds interesting Pierre and I'd defer to Dave's expertise here as it's a bit outside the normal scope of Storyline. I hope that once you get it set up you're able to share here! We love to see new examples of how folks accomplish things like this!
2 Replies
I've created some games where I need to shuffle elements. The way I always do this is to place my elements in an array, and then shuffle the order of the array. Of course, you have to use javascript to do this.
Here is the function I wrote to shuffle the array:
function shuffle(array) {
var elementsRemaining = array.length, temp, randomIndex;
while (elementsRemaining > 1) {
randomIndex = Math.floor(Math.random() * elementsRemaining--);
if (randomIndex != elementsRemaining) {
temp = array[elementsRemaining];
array[elementsRemaining] = array[randomIndex];
array[randomIndex] = temp;
}
}
return array;
}
Sounds interesting Pierre and I'd defer to Dave's expertise here as it's a bit outside the normal scope of Storyline. I hope that once you get it set up you're able to share here! We love to see new examples of how folks accomplish things like this!
This discussion is closed. You can start a new discussion or contact Articulate Support.