How do I Pick random animation

Get help using Construct 2

Post » Fri Oct 30, 2015 4:38 pm

I have a butterfly animation 1 is orange butterfly flying animation 2 is yellow butterfly flying animation three is purple butterfly flying animation I want to do this Event(On start of the layout) Action(Pick random animation) How do I do it?
B
10
S
1
Posts: 93
Reputation: 722

Post » Fri Oct 30, 2015 4:47 pm

Choose("Animation1","Animation2","Animation3","Animation4","Animation5","Animation6","Animation7","Animation8","Animation9","Animation10","Animation11")
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Fri Oct 30, 2015 7:34 pm

Choose works very well.
You can also do it by randomizing a variable and depending on the variable value play an animation.
Ie. butterflyVAR=random(0,10) (number of animations) then set each animation to a number butterflyVAR=1 play animation1, etc.

You could use an arrays if you had lots of butterflies.

For what your describing choose is probably best.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 635
Reputation: 9,331

Post » Fri Oct 30, 2015 9:01 pm

Another way is to build a string with expressions:

Animation to play: "animationName"&int(random(1,200))

substitute the 200 with the total amount of animations.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Oct 31, 2015 3:26 am

@jojoe @chrisinfinger I can't find choose?
B
10
S
1
Posts: 93
Reputation: 722

Post » Sat Oct 31, 2015 3:30 am

You can find more on choose here :
https://www.scirra.com/manual/126/system-expressions

Rather than putting the animation name in the play animation action you would use one of the Choose or random expressions.

Hope that helps.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Sat Oct 31, 2015 7:02 am

You will find that unlike many software manuals, Construct2's manual is your friend. It is very comprehensive!
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 635
Reputation: 9,331


Return to How do I....?

Who is online

Users browsing this forum: combotg, Lancifer and 8 guests