Create random object every X seconds

Get help using Construct 2

Post » Tue Sep 20, 2011 11:41 pm

Hey,

I'm making this little game to teach my self C2.

http://dl.dropbox.com/u/26785144/CreateRandom.capx

Explanation:

You move the mouse to move the piece and press Space to change its color.

You have to catch the colored blocks falling from the sky, but to do that you will have to catch it with the right color in the animation.

What I can't find out is how to create a random object every X seconds?

The idea I had was to make a global number variable, f.ex "randomObject"
and make c2 check:
randomObject = 1 = create Blue
randomObject = 2 = create Yellow
randomObject = 3 = create Red
randomObject = 4 = create Green

and every X seconds I would set the value of randomObject to random(1,5).

If I do this, nothing happens.
And I realize if this would work C2 would create multiple objects.
I am pretty much stuck. :/

edit: formattingDabbijo2011-09-20 23:42:36
B
14
S
3
G
2
Posts: 37
Reputation: 1,893

Post » Wed Sep 21, 2011 12:05 am

Here's an example. Set a local variable to a random number, then create an object depending on the number.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Wed Sep 21, 2011 12:10 am

Thanks so much!
B
14
S
3
G
2
Posts: 37
Reputation: 1,893

Post » Wed Sep 21, 2011 12:15 am

http://dl.dropbox.com/u/36472942/construct/forumhelp/catchcolor.capx

Edit: Darn ninja'd by Ash Kyatric2011-09-21 00:16:06
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Post » Wed Sep 21, 2011 12:42 am

Thanks Kyatric :)
B
14
S
3
G
2
Posts: 37
Reputation: 1,893

Post » Sat Jan 21, 2012 7:45 am

Int! Kyatric you saved my night.
B
203
S
37
G
13
Posts: 136
Reputation: 29,523

Post » Mon Nov 05, 2012 12:58 am

Hi Everyone!

I'm new to C2, and I'm trying to make a game for my master thesis.
Basically, it's about a chipmunk that has diabetes type1, and the user has to take care of him. Feed him when he asks, give him the insulin injection, etc.

So, when the chipmunk is hungry, a thinking balloon appears telling you that he's hungry, and all the user needs to do is, click on the food icon and feed him.
When he needs the insulin injection, the process is the same.

What I want is the insulin balloon and the food balloon to appear in random, and then when I click the right button,the thinking balloon dissapears, and then in x seconds it appears again, and so on.

I was handeling this with the 'Every X seconds' event, and then playing arround with the opacity, but what happens is that the hungry balloon appears every 10 seconds and the insulin balloon every 35. But when I click on the food icon, I feed the chipmunk, the ballon dissapears, and 10 seconds later the food balloon appears again, and the insulin button never shows up. It looks like when the action is executed, the timer just restarts....

Any help is welcome...
B
2
Posts: 1
Reputation: 252


Return to How do I....?

Who is online

Users browsing this forum: selaus, Yahoo [Bot] and 0 guests