How do I always scroll to middle of screen?

Get help using Construct 2

Post » Tue Oct 27, 2015 2:28 pm

Hello World,

So I'm trying, hard, to finally make my latest game actually work(in all aspects) with scale outer and, as you might have guessed, it's confusing as hell; all my other games I started by saying *Yeah, yeah, I'll make it scale outer* and I eventually gave up and used letterbox instead.

So, one of the dozen problems I have at the moment is how do I make the game always scroll to the middle of the screen?
I tried the following:
on start of layout | scroll to position
x: (ViewportRight(0) - ViewportLeft(0))/2
y: (ViewportBottom(0) - ViewportTop(0))/2

Doesn't work. I tried replacing the 0's with the name of an actual layer, doesn't work. I tried puting the viewports into variables and then doing (var.a - var.b)/2, didn't work.....

I know I'm stupid, but what am I missing guys? How can I get my game to always center on the middle of the screen, regardless of what device it's playing on(resolution, aspect ratio, etc.)?

Thank you.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Tue Oct 27, 2015 2:40 pm

First this question should be asked:

What do you consider the middle of the screen?

Fullscreen in browser Scale-outer should immediately center on the center of your original project-view..
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 » Tue Oct 27, 2015 3:19 pm

Good question @LittleStain . I consider the middle of the screen the middle of my layout size.
So if I have a layout width of 640px(middle=320), but if the user has an otherworldly device with resolution of 30x30, then he should only be able to see from 305 till 335.
Is it wrong to think about it like that?
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Tue Oct 27, 2015 4:10 pm

Sounds like you don't want any scaling..
(if that is the case, you should use fulscreen in browser : Crop )

But anyway, I guess you'd want to scroll to 0.5*layoutwidth, 0.5*layoutheight
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 » Tue Oct 27, 2015 5:12 pm

So what i was trying to achieve all this time is crop? Well, is it better with scaling @LittleStain? And what's the difference, what would I need to do different in one as oposed to the other?
Like I said, I'm very confused about this part, even after reading 3 tutorials....:(
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Wed Oct 28, 2015 12:47 pm

Seriously @LittleStain , I don't wanna have to use crop as that would show too little of the game on certain devices, and having enough space/time to maneuver is kinda important in my game. Plus I would have no idea where to put my HUD&stuff so they don't get cropped.
I've read 3 tutorials and I still don't get it....
Tut1
Tut2
Tut3

Is there really nobody out there that can show me(and other noobs like me) once and for all how to clearly design games with scale outer? For both landscape and portrait situations, how big the safe zone is and where to put it, what window size and layout size to have(as you can see one tutorial says 640, 960, another one says 480 x 640), how to center the screen, how to scale the sprites(if they need scaling, and what size should they originally be created in), what if I want to have different "pages" on one layout like in this example, etc, etc, etc.... :cry:
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Wed Oct 28, 2015 12:57 pm

I understand this:

VIKINGS wrote:Seriously @LittleStain , I don't wanna have to use crop as that would show too little of the game on certain devices


But not after you said this:

but if the user has an otherworldly device with resolution of 30x30, then he should only be able to see from 305 till 335


After all, crop does exactly that..
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 Oct 28, 2015 1:09 pm

The three tutorials you linked seem pretty good at explaining exactly what your question is about, what part of them confuses you?

how big the safe zone is :


The safe zone is exactly your original project size (While scaling outer your whole project will be scaled to fit inside the available space)

what window size and layout size to have :


Your choice completely..

how to center the screen:


scaling will automatically center to the original center of your project view if your layout is set to unbounded scrolling (which is the middle of the dotted rectangle), if you want to scrollto somewhere else use either the scrollto behaviour or the system scrollto action

how to scale the sprites(if they need scaling, and what size should they originally be created in):


The fullscreen option will scale yor sprites for you.. You'd probably want to create them the biggest size they will be shown, for bigger is unnescessary to make them look good..

what if I want to have different "pages" on one layout like in this example:


Like you said, you have an example already, it uses scale outer as far as I can see..
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 Oct 28, 2015 1:43 pm

Here's a simple capx to show how scale-outer works:

Scale Outer Example

The blue rectangle is exactly the project window size..
As you can see this is the save area..
All four sprites in the corners are always on screen, no matter in what way you deform your view..
(just change the size of your browser window to see the effect)
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 Oct 28, 2015 4:26 pm

Well then I still must be doing something wrong/must not be getting something... :(
I'll send you a PM @LittleStain with some files, if you'd be willing to help me further.
B
21
S
11
G
6
Posts: 414
Reputation: 5,335


Return to How do I....?

Who is online

Users browsing this forum: John Cutter and 5 guests