Spawn object only on game window

Get help using Construct 2

Post » Tue Dec 10, 2013 11:48 pm

How can i spawn objects randomly but always only on visible game window?delgado2013-12-10 23:54:45
B
110
S
27
G
47
Posts: 1,887
Reputation: 35,799

Post » Wed Dec 11, 2013 11:28 am

bump
B
110
S
27
G
47
Posts: 1,887
Reputation: 35,799

Post » Wed Dec 11, 2013 11:58 am

create object :
on layer (0)
x : random(viewportleft(0),viewportright(0))
y : random(viewporttop(0),viewportbottom(0))
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Dec 11, 2013 11:59 am

if you want the whole object to be within the viewport you should add or subtract object width and height to those values.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Dec 11, 2013 12:02 pm

@LittleStain thanks for reply delgado2013-12-11 12:03:13
B
110
S
27
G
47
Posts: 1,887
Reputation: 35,799

Post » Wed Dec 11, 2013 12:04 pm

So you only have to use the x-position and set the y to viewportbottom(0)+0.5*objectheight.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Dec 11, 2013 12:05 pm

Yeah that is progress for me thanks :D
B
110
S
27
G
47
Posts: 1,887
Reputation: 35,799


Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], Kin, ratboy3, tinhofiel, totoe and 40 guests