How do you make a random event?( capx needed )

Get help using Construct 2

Post » Sat Jan 09, 2016 8:58 pm

LittleStain wrote:
Calfuso wrote:
LittleStain wrote:You could also use choose instead of random:

For animations

> sprite set animation to : choose("animation1","animation2") etcetera

For spawning at imagepoints

> sprite spawn object on layer at imagepoint choose(0,1,2,3,4,5)




When i try to make a sprite switch to random animations i write in the words exactly like you did and i keep getting the error message "expression seem to end before here. are you missing something before it. Other then that the information was very helpful.


You didn't write etcetera, did you?





I did now and it still says Syntax error Expression appears to end before here-are you missing something before it? What should i change in the expression?
http://postimg.org/image/jywfrk74d/
B
12
S
2
Posts: 267
Reputation: 1,344

Post » Sat Jan 09, 2016 9:57 pm

When i try to make a sprite switch to random animations i write in the words exactly like you did and i keep getting the error message "expression seem to end before here. are you missing something before it. Other then that the information was very helpful.[/quote]

You didn't write etcetera, did you?[/quote]




I did now and it still says Syntax error Expression appears to end before here-are you missing something before it? What should i change in the expression?
http://postimg.org/image/jywfrk74d/[/quote]


An answer please? I posted a image so it should be clear what you should help me whit.
B
12
S
2
Posts: 267
Reputation: 1,344

Post » Sat Jan 09, 2016 10:00 pm

Throw away everything after the closing bracket. just: choose(...)
ImageImageImage
B
71
S
22
G
248
Posts: 3,761
Reputation: 138,073

Post » Sun Jan 10, 2016 10:21 am

Like this?
http://postimg.org/image/qn6b6fwz7/

In that case it still doesn't work. Just how am i supposed to write it?
B
12
S
2
Posts: 267
Reputation: 1,344

Post » Sun Jan 10, 2016 11:10 am

Calfuso wrote:Like this?
http://postimg.org/image/qn6b6fwz7/

In that case it still doesn't work. Just how am i supposed to write it?


The Choose Expression gives you the correct syntax, which you already had except for the last bit after the closing bracket, as blackhornet had already told you, which was to only remove the
Code: Select all
""etcetera


nonsense from the end.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
87
Posts: 5,490
Reputation: 60,266

Post » Sun Jan 10, 2016 1:16 pm

depends how random u want it to be ... if u want a random event to happen to switch position random is not something u may want since everything u have is a round number try using choose instead and a list of numbers that u set for each "random" action u want to do so for example u got the random string number that u want the engine to choose from like this choose(1,2,3,4,5,6,7,8,9,10)
then add a condition for each number what to happen if number =1 = trigger animation right

and so on its actually pretty easy to understand ... however using random(1,2) it wont do it right ... since random takes any number +-0.00001 and so on so the result will be somewhere between 1 and 2 that means it can also be 1.5 or 1.1 or smth else and if u need a full round number... the system expression random is not something to use unless u really need it ... choose is also similar to random just its more clean.. which i think is even better then random.. takes away some problems ... unless u got a huge list of numbers u want then u use floor(random(1,100000000)) or what ever to get a random number between 1, and 100 mil and floor cuts the 0.001 sub-digits... but i think in this case for ur use best choice is to use the expression choose(n,n) replace n n with any number u want


a poor representation capx Download
B
78
S
23
G
69
Posts: 1,353
Reputation: 44,005

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests