How do I position all the multiple object at the center?

0 favourites
  • 8 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hi guys,

    I've got this objects on my level layout selection, like lock and unlocked, I've been figuring out how I can automatically position them in the center if it will be viewed by different mobile screen devices?

    Thank you in advance for the help.

  • LaroTaio Not sure what you mean.

    You can align objects simply by right-clicking the object and find the "Center horizontal" or "Center vertical" options. You can also use system expressions like "WindowHeight", "WindowWidth", "LayoutWidth", or "LayoutHeight" and divide them by 2 in your object positions.

  • LaroTaio Not sure what you mean.

    You can align objects simply by right-clicking the object and find the "Center horizontal" or "Center vertical" options. You can also use system expressions like "WindowHeight", "WindowWidth", "LayoutWidth", or "LayoutHeight" and divide them by 2 in your object positions.

    I mean is like with html, you have 3 images horizontally aligned, when you insert the center tag code, what ever the screen size of the browser it will keep the 3 images at the center. that sort of thing is what I want to happen. coz when I view my game on other android screen devices specially with large width screen, all are objects are placed on the left side of the screen. I want my entire layout objects positioned at the center.

  • LaroTaio You could create an object that will act as a container for your 3 images. Then, that container will be centered in the layout/screen and the 3 images will be "pinned" to the container.

  • arthology

    My windwo size is 640 by 480, I followed your instruction

    [quote:1co24sf5]You can align objects simply by right-clicking the object and find the "Center horizontal" or "Center vertical" options. You can also use system expressions like "WindowHeight", "WindowWidth", "LayoutWidth", or "LayoutHeight" and divide them by 2 in your object positions.

    then I copied the position of the object from the properties window and paste it on the system expression LayoutWidth and LayoutHeight, I also tested it on the WindowHeight and WindowWidth expression, still the object is positioned at the upper left corner.

  • LaroTaio

    Divide the LayoutWidth or LayoutHeight by "2" , which will put the 'Sprite' object based on its "origin point" in the center of your layout, like this:

    Sprite | Set position to (LayoutWidth/2, LayoutHeight/2)

    Note: if your origin point is in the center of your object, then the object's center will be aligned with the layout's center. If your origin point is in the top left corner, then the object's corner will be aligned on top of the layout's center.

    Here's what 'LayoutWidth/2' means: if you folded a piece of paper from the left edge all the way to the right edge and unfolded it, you'll get an vertical crease exactly in the middle of the paper with two equal left and right halves. You're essentially finding the layout's exact middle point along the x-coordinate (width-wise).

    Here's what 'LayoutHeight/2' means: if you folded a piece of paper from the top edge all the way to the bottom edge and unfolded it, you'll get a horizontal crease exactly in the middle of the paper with two equal top and bottom halves. Now, you have the layout's exact middle point along the y-coordinate (height-wise).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Assuming these sprites are not supposed to be movable by the user (they are HUD sprites) you don't need to anchor or do any math for centering... just place your sprites on a layer with parallax set to 0,0 and they center them selves to the point you placed them.

  • arthology

    Finally got it working, I thought of dividing the actual size of the window screen by two, but by 2 as you mentioned, silly me

    troublesum

    Thank you for helping out as well, but these sprites are movable, they are objects for level selection to be exact there are 20 rows and 4 columns about 80 levels.

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