How do I spawn ONLY 1 out of 3 sprites?

0 favourites
  • 7 posts
From the Asset Store
Build your map with these isometric objects and terrains
  • Hi.

    On start of layout i want to randomly spawn 1 out of 3 sprites, stay for random 5-10 seconds, then destroy it and instantly spawn again 1 of the 3 sprites an so on.

    I also want ONLY 1 of the 3 sprites to be on screen at any given time.

    Im sure its something very simple but i struggle for 3h now and getting no results.

    Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi.

    On start of layout i want to randomly spawn 1 out of 3 sprites, stay for random 5-10 seconds, then destroy it and instantly spawn again 1 of the 3 sprites an so on.

    I also want ONLY 1 of the 3 sprites to be on screen at any given time.

    Im sure its something very simple but i struggle for 3h now and getting no results.

    Thanks in advance. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Check this example game I made for you, dimitriosfl.

    https://www.dropbox.com/s/vr84dgx18m4fd ... .capx?dl=0

    This is what's happening in the game

    1. There are 3 UFOs; Red, Green and Blue.

    2. Only one of three are randomly spawned in every 3 to 5 seconds upon destruction.

    3. UFOs can be destroyed by Player's plasma projectile or when it goes out of the layout screen.

    4. When you press [Space], you'll be able to shoot a projectile to destroy UFOs.

    5. When a UFO gets hit by the Player's bullet, it will explode.

    6. Player can freely move around on the map but limited to the layout.

    7. Only one UFO will spawn per screen, and the next will spawn only when the previous one gets destroyed.

    Technical explanation

    1. Double click the UFO sprite.

    2. Notice there are 3 animation frames.

    3. Notice animation speed is set to 0.

    4. Frame #1 is Red, Frame #2 is Green and the last frame is Blue.

    5. Go to Event Sheet and look at Line 1.

    6. It says Set Frame - random(3).

    7. This means we're requesting Construct 2 to spawn a random UFO out of 3 possible choices. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

  • Wow! Thank you for the detailed info!

    But i got one more problem. I want them to spawn and despawn every random x seconds on their own without my interaction.

    Example. If red ship is on screen and i shoot red aliems, +1 point, if i shoot green or blue. -1 point. The ship will be like a signal on what color aliens to shoot.

  • Still nothing..

  • You're welcome, dimitriosfl. <img src="{SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green">

    I have created a new example with added features.

    1. Red UFO will give 1 point.

    2. Green UFO will give -1 point.

    3. Blue UFO will give -1 point.

    4. Player has less than 5 seconds to shoot down UFOs, because they'll disappear on their own after 4 to 5 seconds.

    https://www.dropbox.com/s/reh8j7g3xpvz1 ... .capx?dl=0

  • Thanks once again!

    I actually did it 5 minutes ago putting my 3 sprites in a family, creating the family every 5sec (that creates 1 of 3 sprites at a time) and used behavior fade (duration 5sec) for despawn.

    That way, a random one is created every 5sec right after the previus one despawned!

    I know its not the right way, but since it works, im keeping it.

    Thank you again for your help.

    People like you keep this comunity healthy!

  • Oh, that's great!

    You're always welcome, dimitriosfl. (Thank you..!!)

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