0 Favourites

How do I create dice behaviour

  • Hello!

    (first post here, Hello to all the forumers!)

    I have been dabbling with Construct 2 for a while and getting to grips with the basics.

    I thought I would share one of my experiments to get feedback on.

    It is a Die Simulator, 6 sides (currently colours). When clicked, it should cycle through its frames and then pick a colour at the end. And then go through the process with every click thereafter. I have (hopefully) attached a working .capx. All quite new to me this

    1) Is there a way to make the animation frames it cycles through random? (its currently running through its "default" cycle, starting from "current frame") it doesn't look bad but would be nice to make it random.

    2) Do you think there is there a more efficient way to simulate a die behaviour, than what you see in my event sheet?

  • Its easy to set frames to random just use the 'Random' function. Something like. Every 0.10 seconds set animation.frame to random(5). Not had chance to look at your capx yet to see if there is a better way.

  • thank you, i'll have a look at that tonight!

  • hi Dhillyard,

    I am not sure how to make that work. If it is a sub event of the Mouse "click" event it will only run once per click. If it is an event on its own it will run through frames randomly quite happily but obviously won't be attached to the mouse "click".

  • Try adding a for next loop :

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Thanks RamPackWobble that definitely makes it random!

    Its not an expression i've come across up to now. Just to make sure i've understood it, does this essentially "repeat" the action of setting the frame (randomly) every quarter second, and this will happen up to 10 times?

  • Yes that is what it does - you could replace the (for "" 1 to 10) with (repeat 10) for the same effect.

    It would also probably be better to set the frame with choose(0,1,2,3,4,5) rather than random(0,5)

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