How do I Center graphics

Get help using Construct 2

Post » Mon Mar 24, 2014 4:03 pm

Ive tested my app on my phone and tablet each is different dimensions. I had to enlarge my background image to accommodate no white or black space. This has messed with my layout and things are off center.

I tried this (System on start of layout - Graphic set x to (windowwidth/2)
This hasn't solved the issue. How do i center it on any device?

My project is 480, 854. I export in cocoonjs as scale to fit.
My project is set to fulscreen in browser - scale outer.

Thanks for the help!
B
8
S
1
Posts: 62
Reputation: 660

Post » Mon Mar 24, 2014 5:33 pm

Hi im not sure theres a special way to do this, I had to just use trial and error. Everytime I loaded my game on android and it was off I just went and moved it and updated it "Several Times" till I got it were I wanted it, Now I just have a problem with them staying in portrait mode when I flip my phone to Landscape...
Please Support Ocean Explorer.
http://igg.me/p/735007/x/6915815
B
14
S
4
G
3
Posts: 125
Reputation: 2,645

Post » Mon Mar 24, 2014 6:34 pm

this appears to work..

set x to (ViewportLeft("Layer 0") + ViewportRight("Layer 0")) / 2
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,832

Post » Tue Mar 25, 2014 5:08 am

@RamPackWobble does this work for both portrait and landscape, for example if I start in portrait and its centered and then I rotate my phone will it recenter in in landscape?
Please Support Ocean Explorer.
http://igg.me/p/735007/x/6915815
B
14
S
4
G
3
Posts: 125
Reputation: 2,645

Post » Tue Mar 25, 2014 5:13 am

bremen wrote:@RamPackWobble does this work for both portrait and landscape, for example if I start in portrait and its centered and then I rotate my phone will it recenter in in landscape?


Yup, since the viewport expressions update every tick , it should work
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Tue Mar 25, 2014 5:39 am

@Aphrodite Thanks I must give this a try cause currently when the game starts all the buttons are lined up for portrait so it looks kinda funny in landscape view.
Please Support Ocean Explorer.
http://igg.me/p/735007/x/6915815
B
14
S
4
G
3
Posts: 125
Reputation: 2,645

Post » Tue Mar 25, 2014 6:15 am

ok quick question what if I want the score and heath at the top to change position according to landscape, I'm trying to use the ViewportTop("Layer 0")) / 2 but it keeps cutting off half the sprites and score?
Please Support Ocean Explorer.
http://igg.me/p/735007/x/6915815
B
14
S
4
G
3
Posts: 125
Reputation: 2,645

Post » Tue Mar 25, 2014 6:37 am

Never mind I figured it out :-)
Please Support Ocean Explorer.
http://igg.me/p/735007/x/6915815
B
14
S
4
G
3
Posts: 125
Reputation: 2,645

Post » Tue Mar 25, 2014 7:02 am

bremen wrote:Never mind I figured it out :-)


Also in some cases, when unbounding scrolling is On, you don't have to worry a lot about those things (since the center of the screen is always centered when it is not limited by the layout borders)

And for elements that needs to be placed relative to the corners, you can take a look at the anchor behaviour
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Tue Mar 25, 2014 7:17 am

@Aphrodite lol I forgot about the anchor.
Please Support Ocean Explorer.
http://igg.me/p/735007/x/6915815
B
14
S
4
G
3
Posts: 125
Reputation: 2,645

Next

Return to How do I....?

Who is online

Users browsing this forum: lukewasthefish and 13 guests