Random Angle

Get help using Construct 2

Post » Wed Feb 18, 2015 1:29 pm

Hi

How can I set a random angle to a family instances = ( in this I got 4 sprites ) arrows



Cheers
B
33
S
17
G
11
Posts: 350
Reputation: 8,695

Post » Wed Feb 18, 2015 2:03 pm

for each [family] -> [family] set angle to random(360) ?
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Wed Feb 18, 2015 2:57 pm

I want them to point .. 0 - 90 - 180 - 270

:-)
B
33
S
17
G
11
Posts: 350
Reputation: 8,695

Post » Wed Feb 18, 2015 3:05 pm

round(random(3))*90
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Wed Feb 18, 2015 3:15 pm

This is what I got ...

Now I somehow has to get it stop .. since it keeps rotate

RotateAngle.capx
You do not have the required permissions to view the files attached to this post.
B
33
S
17
G
11
Posts: 350
Reputation: 8,695

Post » Wed Feb 18, 2015 5:27 pm

Like this ?
You do not have the required permissions to view the files attached to this post.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Wed Feb 18, 2015 5:52 pm

choose(0,90,180,270) ??
B
15
S
4
Posts: 77
Reputation: 1,030

Post » Wed Feb 18, 2015 6:04 pm

Oh, nice, I didn't know this expression :D
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Wed Feb 18, 2015 6:26 pm

Nice! I also don't know this expression - thanks! :)
But in this case, the object will chose one of this directions/angles.

But you want to create 4 objects and the first one should have angle 0 dagrees, the second one 90 dagrees, the third 180 dagrees and the fourth one have 270 dagrees, right?
Then make:

Code: Select all
On ?-Event (pressing button, collision,  start of layout, or anything you want):
 + Repeat 4 times = Create Object at X,Y

On Object created = Set angle to Object.Count * 90

When you create 8 Objects, then set the Angle to Object.Count*45.
With 16 Objects, set Angle to Object.Count*22.5.
32 Objects = Objects.Count*11.25.
And so on ... ;)

I don't know if this is what you realy need, but i hope it will help :)
B
22
S
6
G
2
Posts: 185
Reputation: 3,632

Post » Wed Feb 18, 2015 6:30 pm

It also work with families.
I make a .capx
You do not have the required permissions to view the files attached to this post.
B
22
S
6
G
2
Posts: 185
Reputation: 3,632

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 52 guests