How do I Create Objects Randomly ? ? ?

Get help using Construct 2

Post » Wed Mar 29, 2017 4:11 pm

Hey guys!!!
How can I create multiple objects randomly?
Example: I have 5 bubbles in five different colors and I want the colors to be created randomly.
right now it's creaing a green bubble every "5" seconds, how can I make all the colors to be created randomly every "5" sec.
once the "5" seconds has passed I want a green bubble and after the next 5 seconds has passed I want for example a red bubble.

I tryed to program one of each color to be created every x second independently but it became a mess, to many bubbles were created and they were overlapping each other all the time.

Is there a better way?
any ideas how to solve this?
keep it simple please I am a beginner.

Tanks
B
11
S
5
G
1
Posts: 23
Reputation: 1,477

Post » Wed Mar 29, 2017 4:29 pm

Make a control object with instance var or a global var (for example color=#) and set it to a different number for each color.
Now somewhere throw up a random number generator that constantly runs.. such as Every X seconds set instance var color to choose(0,1,2,3,4,5) or int(random((0,5)).
Now in your spawner, sub-event down for each color:

(main)Spawn event condition
(sub) instance color=0 - (action) spawn blue bubble
(sub) instance color=1 - (action) spawn red bubble
etc

You could also use Every tick and it will race through 0-5 but your spawn event will still grab whatever current value and use it.
You could also use a Function that chooses and sets the color variable when called and call it in your spawning event and sub to the actual spawn event after.
Last edited by chrisinfinger on Wed Mar 29, 2017 4:54 pm, edited 1 time in total.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
69
S
18
G
8
Posts: 639
Reputation: 9,549

Post » Wed Mar 29, 2017 4:42 pm

seems a Little complicated.
i'll try to figure it out though.
if you could send me a capx of an idea on how to do it it would be fantastic.

thanks alot.
Last edited by Tackla on Wed Mar 29, 2017 4:46 pm, edited 1 time in total.
B
11
S
5
G
1
Posts: 23
Reputation: 1,477

Post » Wed Mar 29, 2017 4:45 pm

Its not as complex as I make it sound :)
I will try and work something up real quick
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
69
S
18
G
8
Posts: 639
Reputation: 9,549

Post » Wed Mar 29, 2017 4:50 pm

I'm new to this and it takes quite some time to understand and to get stuff done :)
but i'm geting there :D

Thanks alot, that would be great!

Thanks!!!
B
11
S
5
G
1
Posts: 23
Reputation: 1,477

Post » Wed Mar 29, 2017 5:21 pm

See if this makes sense.Image
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
69
S
18
G
8
Posts: 639
Reputation: 9,549

Post » Wed Mar 29, 2017 5:54 pm

I think I understand!
I'll try it out!
Thanks for taking your time!
Thanks alot!
B
11
S
5
G
1
Posts: 23
Reputation: 1,477

Post » Thu Mar 30, 2017 5:52 am

if layout have size 500x500
example
every 1 sec ---> create object X or familly (in familly c2 take random object from familly)
(
x: round(random(0,500))
y: round(random(0,500))
)
B
10
S
4
G
1
Posts: 29
Reputation: 898

Post » Thu Mar 30, 2017 5:57 am

screen example in capx http://imgur.com/a/UHBLt
B
10
S
4
G
1
Posts: 29
Reputation: 898

Post » Thu Mar 30, 2017 2:43 pm

Yes using families simplifies it greatly either way you do it.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
69
S
18
G
8
Posts: 639
Reputation: 9,549

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000, Lordshiva1948 and 10 guests