Center text

0 favourites
  • 4 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Hey, i've been trying to get this done for like 2 hours now, and i've read a bunch of forum posts that come close but none explains it the way i want it.

    So here is what i want to do:

    For example, i'd like a text saying something like 'copyright 2012' on the bottom center of a menu or splashscreen. How do I do that. I want to center the buttons in the menu as well for that matter...

    Thanks for any help!


  • My preferred approach is to use WindowWidth and WindowWidth to arrange objects:

    Set the text object's horizontal alignment to center in the properties panel and then in the event sheet, if you want the text object to be on the bottom center of the window:

    On start of layout, set text object's position to:

    x: (WindowWidth - self.Width)/2

    y: WindowHeight - self.Height

    This works for any object, not just text. If you wanted the object right in the middle of the screen both vertically and horizontally,

    x: (WindowWidth - self.Width)/2

    y: (WindowHeight - self.Height)/2

    For the buttons, check out part 2 of my tutorial on Creating a Memory Match Game. It shows how you can arrange a layout of cards that resizes and rearranges if the window size changes, but the technique would work just as well for buttons.

    EDIT: You can read about the Anchor behavior in the manual, but I don't think it works well for centering.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Great, that's exactly what i needed. I don't know why I haven't found that solution before. Thanks

    I tried using anchor before this, but that only works for keeping an object at the bottom, top, left or right not the center.

    And thanks for the link to you're tutorial, that'll probably help me a good bit on my way.

  • kittiewan OMG I'm sooo happy I click through these how do I's

    I was trying to figure that out the other day.

    x: (WindowWidth - self.Width)/2

    y: (WindowHeight - self.Height)/2

    I couldn't figure out how to center text or objects with command, I tryed WindowWidth/Hight, LayoutHight/Width etc.. but didn't succeed.


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