How do I display a random text at the end of the game?

0 favourites
  • 8 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • I am a newbie, in fact this is my first day in gaming development so I need your help guys. I want to know how to add a list of phrases for example:

    "great job"

    "you are awesome"

    "no doubt you are the best"

    and display one randomized phrase in the Game Over screen. For example each time the gamer finish the game the gamer will see a different phrase in the gameover screen.

    I have in mind a large list.

    Please remember that I am a new corner.

    Thanks for your help and also for this great opportunity to become a game developer.

  • Make a new number variable, we'll call it randomText. Then on gameover we set the value of it to floor(random(10)) - that will allow us to put in 10 random phrases, just change that number if you want more or less.

    Then:

    if randomText = 0: set text to "great job"

    if randomText = 1: set text to "you are awesome"

    if randomText = 2: set text to "no doubt you are the best"

    etc.

    Just bear in mind that with floor(random(10)), your ten possibilities are stored in 0-9, value 10 will never come up, because the floor() function is rounding numbers for you

  • Thanks but how can I do it? I mean I dont know how to create the Number Variable in "Contructs 2" .

    Make a new number variable, we'll call it randomText. Then on gameover we set the value of it to floor(random(10)) - that will allow us to put in 10 random phrases, just change that number if you want more or less.

    Then:

    if randomText = 0: set text to "great job"

    if randomText = 1: set text to "you are awesome"

    if randomText = 2: set text to "no doubt you are the best"

    etc.

    Just bear in mind that with floor(random(10)), your ten possibilities are stored in 0-9, value 10 will never come up, because the floor() function is rounding numbers for you

  • romanos8

    You should take a look into the tutorial section

    https://www.scirra.com/tutorials

    But the easiest way is "choose"

    choose("Hello", "Hi", "Great", "Goodbye")

    https://www.scirra.com/manual/126/system-expressions

  • Dont forget to add in trigger once when using choose or random....Ive experience melt down of contruct two when i forgot that and cause liek 20 event plus the random number to try to run at the same time lol

  • romanos8

    You should take a look into the tutorial section

    https://www.scirra.com/tutorials

    But the easiest way is "choose"

    choose("Hello", "Hi", "Great", "Goodbye")

    https://www.scirra.com/manual/126/system-expressions

    Where do I find the "choose". I am using Construct 3.

  • Where do I find the "choose". I am using Construct 3.

    It's an Expression that you add to the Set Text Parameters...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • choose is a system expression. You have to type it.

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