How do I Change texts

0 favourites
  • 4 posts
  • Hey guys,

    I want a text to constantly(and randomly) change texts.

    So what i mean is -

    The code will have the words - hello, hi , bye

    One min it shows - hello

    the next min bye

    the next min hello

    the next min hi

    and so on

    So i want it to change every time the user presses a button or so.

    How do i do this?

    Thanks,

    Ashwin

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I want a text to constantly(and randomly) change texts.

    So i want it to change every time the user presses a button or so.

    So which is it?

    It seems you want to know 1 or more of the following:

    Q: How to change text to different words

    A: System:Every tick -> textObject:set text to "hello"

    Q: How to do something randomly

    A:

    System: Every tick -> Set MyVar to random(1, 5) (or choose( 1,2,3,4,5))

    System: MyVar = 1 -> action 1

    Else

    System: MyVar = 2 -> action 2

    (etc)

    Q: How to do something every so often

    A: System: Every 1.0 seconds -> action

    Q: How to do something when the user presses a button/sprite

    A: Touch: On tap gesture on MySprite -> action

    Maybe you can put it all together

    Edit:

    Hint: Use an array to store the words, then use the randomly chosen number as the index into the array

  • Depends on how many choices and how the text is stored. If it's just a few words, then simply do something like:

    On clicked - Text Set Text to choose("Hello", "Goodbye","Booyah!","etc")

  • So i did a quick thing, although i'm a beginner in construct 2 xD.. and i added two methods (by waiting 5 seconds or by pressing "X") well, i hope this is what you wished for:[attachment=0:3lqe6zlv][/attachment:3lqe6zlv]

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