left or right

Get help using Construct 2

Post » Tue Feb 05, 2013 10:56 pm

Hi all! i want that the system create a sprite every x seconds in left or right of the layout..
what condition i've to use?
my layout in this game is 800x600
left spawn
every random(x,x) sec----> create object on layer x at X(random(-400,0))

right spawn
every random(x,x) sec----> create object on layer x at X(random(800,1200)

As I said, i want to create this object on left or right, so how can i combine these two conditions?

Thanks
B
17
S
5
G
3
Posts: 76
Reputation: 2,948

Post » Thu Feb 07, 2013 9:48 pm

Up! I need a condition to create a object in random position on the left or right of layout, please help me!
B
17
S
5
G
3
Posts: 76
Reputation: 2,948

Post » Thu Feb 07, 2013 10:06 pm

By having them one after another you are doing just that,

its creating on on the left, then one on the right.

to make your events a bit cleaner you could change it to

create object on layer 1 at -100, random(0, windowHeight)
and
create object on layer 1 at windowWidth +100, random(0, windowHeight)

this way if you change your game resolution you won't have to go update it later.justifun2013-02-07 22:09:00
B
50
S
21
G
8
Posts: 844
Reputation: 10,299

Post » Thu Feb 07, 2013 10:08 pm

use the choose function. random creates a random number between 0 and say 800, choose chooses, so create at X = choose(0,800) will pick one: 0 or 800.

cheersranma2013-02-07 22:08:38
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Thu Feb 07, 2013 10:11 pm

Create object at X:
choose(random(-400, 0), random(800, 1200))
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,020

Post » Thu Feb 07, 2013 10:52 pm

Ok thanks!
B
17
S
5
G
3
Posts: 76
Reputation: 2,948

Post » Thu Feb 07, 2013 10:59 pm

Ah!!! The oobject when is created go in direction of layout with bullet behavior... maybe i can't use this :(
B
17
S
5
G
3
Posts: 76
Reputation: 2,948


Return to How do I....?

Who is online

Users browsing this forum: BipolarMike, totoe and 15 guests