How do I Center graphics

1 favourites
From the Asset Store
Over 1700 16x16 pixel art RPG icons for item and skills
  • 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!

  • 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...

  • this appears to work..

    set x to (ViewportLeft("Layer 0") + ViewportRight("Layer 0")) / 2

  • 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?

  • 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

  • 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.

  • 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?

  • Never mind I figured it out

  • 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

  • Aphrodite lol I forgot about the anchor.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Aphrodite lol I forgot about the anchor.

    If you are using Intel XDK Crosswalk compiling your APK try and use the beta build it should solve the orientation problem.

  • Phuzz I'm stuck using CocoonJS on this project since I can't upload a XDK APK when I have already used CocoonJS APK cause they have separate signings.

  • bremen your game supports both orientations?

  • Phuzz Well it was just portrait view originally, but I been getting request for landscape also so I set both orientations on but when you view the game in landscape the buttons and score are all the the left side like there still in portrait view. But I think I may have corrected the buttons, but I can't get the score and text to line up correctly in the corners even with anchor. Sigh if it not one thing its another... lol

  • Phuzz Well it was just portrait view originally, but I been getting request for landscape also so I set both orientations on but when you view the game in landscape the buttons and score are all the the left side like there still in portrait view. But I think I may have corrected the buttons, but I can't get the score and text to line up correctly in the corners even with anchor. Sigh if it not one thing its another... lol

    The anchor behavior needs you to place them in the corners in the layout view accordingly to the window size set in C2, the LeftEdge and TopEdge will help you, since it means that the left and top edges of your object will still be at the ame position relative to the chosen corner for every aspect ratio.

    Hope that helps

    Also : https://www.scirra.com/manual/88/anchor

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)