How to arrange an array of words (as Text objects) into centered rows within a container?

Not favoritedFavorited Favorited 0 favourites
  • 1 posts
From the Asset Store
Match the rows with tofus to clear the rows before you pass the cook.
  • Hi everyone,

    I have an array of words, for example: ["Harmony", "Venture", "Illuminate", "Catalyst", "Whisper", "Resolve", "Ember", "Ascent", "Heaven"].

    I want to display these words inside a container (e.g., a Sprite). Each word from the array will be its own Text object.

    The desired layout is as follows (inspired by how answers are sometimes displayed in word search games, see image below for an example):

    Row Formation:

    The Text objects (words) should be arranged into rows.

    Each row should accommodate as many words as possible from the array without the combined width of the Text objects in that row (plus a defined horizontal spacing between them) exceeding the container's width.

    When adding the next word would exceed the container's width, that word should start a new row.

    If a single word (a single Text object) is wider than the container, it should occupy its own row.

    Horizontal Centering of Rows: Each complete row of Text objects should be horizontally centered within the container.

    Vertical Centering of the Entire Block: The entire resulting block of rows (all the Text objects collectively) should be vertically centered within the container.

    https://drive.google.com/file/d/1b6TN_BRHcA2dXvGLn0NE_EgNGF5pgf-T/view?usp=sharing

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)