Create random object every X seconds

0 favourites
  • 7 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • Hey,

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

    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: formatting

  • Here's an example. Set a local variable to a random number, then create an object depending on the number.

  • Thanks so much!

  • catchcolor.capx

    Edit: Darn ninja'd by Ash Kyatric

    2011-09-21 00:16:06

    2017-01-04

  • Thanks Kyatric :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Int! Kyatric you saved my night.

  • 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... <img src="smileys/smiley1.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)