How do I randomly spawn enemies?

Get help using Construct 2

Post » Wed Mar 12, 2014 2:56 pm

Hi,

I am trying to randomly spawn the enemies at the borders of the screen. In the create object action I put

X: random(0,1024)
Y: random(0, 576)

but the enemies spawn all over the place. What am I doing wrong?

Thanks
@StylianosArts
Game studio with a portfolio of 4 Apple Featured games.
B
31
S
7
G
2
Posts: 112
Reputation: 2,429

Post » Wed Mar 12, 2014 3:30 pm

skozax wrote:X: random(0,1024)
Y: random(0, 576)


It's because you ARE spawning it all over the place.
0 to 1024 on x-axis, and 0 to 576 on y-axis
I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Wed Mar 12, 2014 3:36 pm

What should I write then?
@StylianosArts
Game studio with a portfolio of 4 Apple Featured games.
B
31
S
7
G
2
Posts: 112
Reputation: 2,429

Post » Wed Mar 12, 2014 3:44 pm

You want to spawn on all the four borders?If so,

Condition: -Spawn object on X -Random(1024) ,Y- 1 (Upper Border)
-Spawn object on X -Random(1024) ,Y- 576 (Lower border)
-Spawn object on X -1 ,Y- Random(576) (Left border)
-Spawn object on X -1024 ,Y- Random(576 (Right Border)
I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Wed Mar 12, 2014 3:48 pm

I wrote you an .capx example.
You do not have the required permissions to view the files attached to this post.
B
10
S
2
Posts: 135
Reputation: 1,090

Post » Wed Mar 12, 2014 4:06 pm

Thank you very much both of you! This worked as I wanted!
@StylianosArts
Game studio with a portfolio of 4 Apple Featured games.
B
31
S
7
G
2
Posts: 112
Reputation: 2,429


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests