How do I create dice behaviour

Just started using Construct 2? Post your questions here

Post » Sun Apr 27, 2014 11:28 am

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?
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 4
Reputation: 183

Post » Sun Apr 27, 2014 7:01 pm

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.
B
17
S
2
Posts: 29
Reputation: 779

Post » Mon Apr 28, 2014 2:39 pm

thank you, i'll have a look at that tonight!
B
3
Posts: 4
Reputation: 183

Post » Mon Apr 28, 2014 6:24 pm

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".
B
3
Posts: 4
Reputation: 183

Post » Tue Apr 29, 2014 6:23 am

Try adding a for next loop :
You do not have the required permissions to view the files attached to this post.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Sat May 03, 2014 8:19 am

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?
B
3
Posts: 4
Reputation: 183

Post » Sun May 04, 2014 3:13 pm

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)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892


Return to Beginner's Questions

Who is online

Users browsing this forum: warmty and 1 guest