How do I spawn ONLY 1 out of 3 sprites?

Get help using Construct 2

Post » Sun Sep 04, 2016 11:17 pm

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. :)
B
25
S
6
G
2
Posts: 84
Reputation: 2,611

Post » Mon Sep 05, 2016 12:04 am

dimitriosfl wrote: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. :)


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. :mrgreen:
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Mon Sep 05, 2016 7:50 am

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.
B
25
S
6
G
2
Posts: 84
Reputation: 2,611

Post » Mon Sep 05, 2016 2:42 pm

Still nothing.. :(
B
25
S
6
G
2
Posts: 84
Reputation: 2,611

Post » Mon Sep 05, 2016 3:53 pm

You're welcome, dimitriosfl. :mrgreen:

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
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Mon Sep 05, 2016 4:49 pm

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!
B
25
S
6
G
2
Posts: 84
Reputation: 2,611

Post » Mon Sep 05, 2016 4:54 pm

Oh, that's great! :mrgreen:

You're always welcome, dimitriosfl. (Thank you..!!) :mrgreen:
B
11
S
6
G
15
Posts: 256
Reputation: 9,207


Return to How do I....?

Who is online

Users browsing this forum: 25games, Ashley and 21 guests