Solved - How do I shake a die 10 times?

0 favourites
  • 7 posts
From the Asset Store
80 pieces of loopable game music, 10 game overs and 10 level complete pieces.
  • Here is what I want to have happen:

    - I press the number 5.

    - the Die (a sprite object with 2 behaviors on it: Sine and Timer) shakes for half a second and then changes value.

    - The step above repeats 10 times.

    - After 10 repetitions (5 total seconds) it stops shaking and displays the final value.

    Below is my code, but it's not working (I think it's all happening in an instant before I can even see it).

    BTW, I'm trying to use Timer because when I looked up examples with "wait" or "every x seconds", I kept seeing advice that said to use the Timer instead.

    What am I doing wrong (am I even close)?

    Tagged:

  • Yes, using wait can be tricky and you have to be a little bit careful, but it's fine depending on the case. You're using the timer wrong, the timer doesn't behave like a wait. You're just starting a timer on the dice, that's why this is happening in an instant. I personally wouldn't bother with a timer in this case actually.

    wackytoaster.at/parachute/10dicerolls.c3p

  • WackyToaster, This is awesome - thank you so much!

    One question, I see you're using a custom action instead of a function. I've used functions, but not custom actions. What is the benefit/difference from a function?

  • Custom actions have some advanced uses (overrides), other than that the difference isn't really that big. I mainly like how custom actions help with organisation. The action to roll the dice is now available on the dice object itself, rather than shoved into the function object.

    construct.net/en/make-games/manuals/construct-3/project-primitives/events/custom-actions

  • WackyToasterThanks again for all the help and explanations.

    One last question, in your version wait shows (use time scale: True), but that doesn't appear on my screen.

    Is that important, how do I get that and what is it doing?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Oh that's probably just because I'm on the latest beta version. It will come to the stable version eventually, you don't really have to worry about it. It just means that the wait action takes the timescale of the project into account when waiting. Timescale of 2 would mean everything in the game runs twice as fast, so a wait of 1 second would instead be 0.5 seconds long. It's simply an option to say you don't want timescale to change the duration of the wait.

  • WackyToaster Thanks again for the helpful reply. I am learning so much here!

    Looking forward to the day when I know enough that I can actually help others. :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)