I am working on a board game where I have set up a dice with a random number generator. However I have a very demanding client who want the dice to simulate a rolling effect. Is there a way that jarva script could be written to make the dice roll through states then show the random number.
You can achieve that with JS by following some simple steps.
1) Create a dice with all the states (normal (1), 2, 3, 4, 5. 2) Map states to a number variable (say dice1) - create 6 triggers in the form of Change state of dice to x when variable dice1 changes on condition that dice1(var) is 1, etc. 3) Create a layer (say roll dice 1) and execute a JS trigger to randomly select a number from 1 to 6 (seeĀ Storyline's JS practices for the code on how to achieve that). Make 10-15 copies of the JS trigger and use different time events to fire those actions - i.e. JS trigger 2 starts when timeline reaches 0.25 sec, trigger 3 at 0.5 sec, trigger 4 at .75, and so on.
Do the same for the second dice (using a different variable, this time dice2 and assign a 2nd layer for that dice.
Create an extra closing trigger (hide layer) on both layers in the end and uncheck the "hide other slide layers" option on both.
Then all you have to do is fire up(show) both layers at the same time when user presses a button.
I've attached the files. Basically we draw a random number from 1-6 and replace the graphic when the die stops. The die is moving on an animation line from off screen.
12 Replies
Hi Sam,
You can achieve that with JS by following some simple steps.
1) Create a dice with all the states (normal (1), 2, 3, 4, 5.
2) Map states to a number variable (say dice1) - create 6 triggers in the form of Change state of dice to x when variable dice1 changes on condition that dice1(var) is 1, etc.
3) Create a layer (say roll dice 1) and execute a JS trigger to randomly select a number from 1 to 6 (seeĀ Storyline's JS practices for the code on how to achieve that). Make 10-15 copies of the JS trigger and use different time events to fire those actions - i.e. JS trigger 2 starts when timeline reaches 0.25 sec, trigger 3 at 0.5 sec, trigger 4 at .75, and so on.
Do the same for the second dice (using a different variable, this time dice2 and assign a 2nd layer for that dice.
Create an extra closing trigger (hide layer) on both layers in the end and uncheck the "hide other slide layers" option on both.
Then all you have to do is fire up(show) both layers at the same time when user presses a button.
Hope this helps,
Alex
Hi Sam! Looks like you are getting some great assistance here and good luck on your project.
Here is a rolling die with animation, sound and image state change.
https://360.articulate.com/review/content/9d4ac28b-87fa-41eb-90c2-bbc242be4673/review
Here is a pair of rolling dice with animation, sound and image state change. Total of dice shows on base layer.
https://360.articulate.com/review/content/0b768e90-8e29-4022-8a00-a84f831163ac/review
Any chance of getting the .story file for this?
Ron Katz: very cool! Will you please explain how your die has both bounce AND spin animations? I'd love to see the .story file for this, too!
Here you go.
Here is the Storyline file
For two dice just dupiicate efforts for one.
I've attached the files. Basically we draw a random number from 1-6 and replace the graphic when the die stops. The die is moving on an animation line from off screen.
I really like this, Ron. Thanks for sharing!
Thank you for sharing your work