case statements for actions?

Get help using Construct 2

Post » Sat Aug 24, 2013 1:43 pm

hey all,

noob to c2 here.. just wondering if there is some way to do this:

when the player shoots a rock, the rock explodes and sometimes either gold, silver or bronze pieces appear (all different sprites).

I first check a random number (1,20) and compare with a constant (10, let's say)

           if Rand = Constant then spawn object (which works for one object)

but I need:

           case Rand:
                    
                  ConstantA: then spawn objectA
                  ConstantB: then spawn objectB
                  ConstantC: then spawn objectC
                  ConstantD: then spawn objectD

            end case

Thanks!
                   
B
97
S
32
G
15
Posts: 1,194
Reputation: 16,170

Post » Sat Aug 24, 2013 1:54 pm

system compare two values - rand = contanta - spawn object a
system compare two values - rand = contantb - spawn object b
etc

Set these as subevents of the event that sets the random number and you should be good to go..


I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Aug 24, 2013 2:11 pm

aaaaahhh.. I saw sub-events in the manual, but thought you just dragged it until you got the >--- and when I tried to drag another event up there it didn't give me the >----

looks like I have to right-click to add it.. nice..

THANKS! I appreciate it!
B
97
S
32
G
15
Posts: 1,194
Reputation: 16,170


Return to How do I....?

Who is online

Users browsing this forum: ajcoppersmith, blue visionary and 5 guests