How can I center text?

0 favourites
  • 12 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • I have two text boxes (CoverTitle and CoverDesc) and a tiled background.

    On start of layout I do:

    CoverTitle => Set position to ((LayoutWidth-CoverTitle.Width)/2, 32)

    CoverDesc => Set position to ((LayoutWidth-CoverTitle.Width)/2, CoverTitle.Y+CoverTitle.Height+10)

    [ Replacing with "CoverDesc => Set position to ((CoverTitle.X, CoverTitle.Y+CoverTitle.Height+10)" does the same ]

    TiledBackGround => Set size to CoverTitle.Width, CoverTitle.Height

    TiledBackground => Set position to CoverTitle

    [ Replacing with "TiledBackground => Set Position to )CoverTitle.X, CoverTitle.Y)" does the same]

    The described method DOES NOT center text. Instead, the window is divided in two halves. CoverTitle is centered on first half of the window, and CoverDesc and TiledBackground are centered in the other half.

    Replacing LayoutWidth with WindowWidth seems to do the same. I've tried with Fullscreen "scale mode" also.

    Is this a bug?

  • Use layoutwidth/2 - textbox.width/2

  • According to distributive property, ((A/2)-(B/2))=(A-B)/2

    Despite of that, I've also tried it.

  • Indeed, my bad.

    Post your capx please.

  • Yann,

    Your file works on my computer. But the same does not work when applied to my objects (I tried positioning the focus at the center before I used the other approach).

    I'm sure I've done something wrong when inserting the objects in the layout, as I did last time. I'll post my capx, as Kyatric suggests.

    http://apagada.com/varios/labe3_alpha2/labe3.capx

  • there ya go

    centering.capx

    Basically you had a useless behavior on the title text (anchor)

    And you have to scroll to the center of the layout for your object to be centered.

    And do that every tick in case people resize the window.

  • If I can't use pin, how can I make sure second text is always moved with first text?

  • pin is just a behavior that does the same thing as

    system : every tick
        -> secondText: set position to firstText

    and nobody said you can't use pin

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Now I know how to center text and I know how to get overall width (it took me a month to realize that "hanged" floating window appearing sometimes over Construct 2 was the syntax hint), I can add credit pages to all my creations.

    I am thinking about posting my labrynth generator as an "example", since it is an example on how to make complex conditions using events. What do you think about it?

    Do you think I should post it on the examples section of Scirra Arcade, or in the C2 tests section of "Construct 2 General"?

  • I think that makes me think of the labyrinth generator I did in construct classic

    maze.exe

    I dunno where it's best to post it. I wonder if it's good to flood the arcade with just R&D example. I thought Arcade was more for games...

    Anyway you should translate your capx in english if you want it to be usefullYann2011-12-18 23:24:58

  • Do you think I should post it on the examples section of Scirra Arcade, or in the C2 tests section of "Construct 2 General"?

    Best would be probably in the "Your Creations".

    I think that makes me think of the labyrinth generator I did in construct classic

    http://dl.dropbox.com/u/23551572/exe/maze.exe

    Hey, that's a nice example.

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