4 paths

Get help using Construct 2

Post » Sun Dec 02, 2012 7:42 pm

How do I get enemies to generate on one of 4 paths?

Want enemies to be generated randomly on either path 1, 2, 3, or 4 moving from right to left. There may be multiple enemies on the same path, but they can not overlap each other.
B
5
Posts: 21
Reputation: 892

Post » Mon Dec 03, 2012 12:20 am

The easiest way is a global variable 'path' = random(floor(4))

If path = 1 create at XY

If path = 2 create at XY

....

A more complex way is to create several invisible Spawn-sprites in advance.

Then just System -> pick Random instance (SpawnSprite)

SpawnSprite -> Spawn Object...

Hope that helps ;)
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Mon Dec 03, 2012 3:22 am

Does someone have an example of this?
B
5
Posts: 21
Reputation: 892

Post » Mon Dec 03, 2012 9:36 am

You really should work through the tutorials if you have trouble understand this.
Made a quick example:

https://dl.dropbox.com/u/34146606/SpriteSpawn_Simple.capx

https://dl.dropbox.com/u/34146606/SpriteSpawn_Complex.capx
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Tue Dec 04, 2012 1:34 am

Perfect for saving me time.
B
5
Posts: 21
Reputation: 892

Post » Thu Dec 06, 2012 3:13 pm

How can I have different enemy sprites to use on the paths? They can not overlap.
B
5
Posts: 21
Reputation: 892

Post » Thu Dec 06, 2012 3:44 pm

i do not know how to stop the overlap. but you can add the same events to all your enemies
B
20
S
8
G
2
Posts: 122
Reputation: 3,202

Post » Fri Dec 07, 2012 12:43 pm

You can add another Global called Enemy_Sprite and make it random with choose(1,2,3,4...)

Then you make if conditions
-------
| IF Enemy_Sprite = 1 -> Spawn Enemy1 at ...
-------
| Else
| IF Enemy_Sprite = 2 -> Spawn Enemy2 at ...
-------
| Else
| IF Enemy_Sprite = 3 -> Spawn Enemy3 at ...
-------
.....

When does the overlapping occur?GameForger2012-12-07 12:44:28
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Fri Dec 07, 2012 10:56 pm

Do you have a sample of the IF statements above? I took care of the overlapping I think, but it is when red box is being displayed I want to make sure either the next red box or blue box is displayed that if it shows on the same path as the other boxes that it does not overlap.
B
5
Posts: 21
Reputation: 892

Post » Sun Dec 09, 2012 1:50 am

Can you show an example where you are stuck?
What do you mean with red box and blue box? Different enemies? Do you mean collision with overlap?
B
4
S
1
G
1
Posts: 49
Reputation: 997

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests