[SOLVED]How do I determine visible area?

Get help using Construct 2

Post » Sun Aug 09, 2015 1:31 pm

Helo World,

This next game that I'm gonna be working on would be perfect for using scale outer. However I'm having trouble figuring out how to set up my game based only on the area that the player can actually see on his particular device.
For example lets say my layout is 640x480(and lets assume everyone can see all of it) and that I have an object(size 30x30, origin at 15x15) that I want to spawn in random locations. Normally I would have some events like:
1. on start of layout | system scroll to
x: 320
y: 240
2. every x seconds | create object at
x: random(40,610)
y: random(40,440)
So in that scenario I know the starting x/y and the ending x/y of what the player can see. And I know that I have to add 40 to the starting x/y and substract 40 from the ending x/y, that way the object will be created at random positions but will always be fully withing the layout and will have a little space between it and the layout edge.

However if I use scale outer I would need something like(let's call it visible.area, I don't know what the proper term is):
1. on start of layout | system scroll to
x: 320
y: 240
2. every x seconds | create object at
x: random(visible.area.start+40,visible.area.end-40)
y: random(visible.area.start+40,visible.area.end-40)

And it's not just for randomly spawned objects, that was just an example, I would olso need to always keep my HUD elements at a certain distance from the visible.area edge, etc. So, in conclusion, how do I make sure that my entire game is always within the part of the layout that the player can actually see on his device?

Thank you.
Last edited by VIKINGS on Mon Aug 10, 2015 12:46 am, edited 1 time in total.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Sun Aug 09, 2015 2:18 pm

Image
those system expressions will probably do the job
Image
B
28
S
11
G
2
Posts: 139
Reputation: 3,299

Post » Sun Aug 09, 2015 4:06 pm

K, thank you @Fidasx , so viewport means the actual visible part of the layout, correct?
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Mon Aug 10, 2015 12:06 am

yea exactly
Image
B
28
S
11
G
2
Posts: 139
Reputation: 3,299

Post » Mon Aug 10, 2015 12:46 am

Ok, thank you @Fidasx . Then I guess I can just save the viewport values in some variables on start of layout, and then I can use those variables later for the random positions and stuff.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests