For Loop Example

  • I am trying a simple for loop example in construct 2?If any one can help ?

    Thanks.

    I created a for ""from i to 10    Textbox set text to i

                                      System Add 1 to i

                                      System stop loop.

    But the loop is not breaking after reaching 10.

    Where did i go wrong.

    Thanks in advance.

  • more info and this should be on how do I

  • I just want to see the loop starting from 0 and ending 9 and i should see the 9 in the textbox at the end.

    for(i=0;i<10;i++)

    {

    printf(i);

    }

  • Texbox doesn't have "append option" you should use writeable text or sprite font

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I understood that joan.But i just need to rotate the loop for 10 times and stop and i am not able to do that can u help me if u have any idea.Because i am not able to upload the screen shot.

  • Hello,

    For this:

    for(i=0;i<10;i++)

    {

    printf(i);

    }

    The equivalent in C2 would be this:

    for "" from 0 to 9    

    ----Textbox set text to loopindex

    Or if you want a named loop variable:

    for "i" from 0 to 9    

    ----Textbox set text to loopindex("i")

    Lastly your initial event setup in your first post would look like this in c:

    int i;

    for(int loopindex=i; loopindex<=10; ++loopindex)

    {

    ++i;

    break;

    }

    -cheers

  • Hound thanks. One more thing i want to know is i have a string and i am trying to getting the values to array the string is some thing like this

    tempString={what is ur name?,option1,option2,option3,option4,answer,what is ur name?,option1,option2,option3,option4,answer,what is ur name?,option1,option2,option3,option4,answer

    }

    Now i want store this in an array and show one after the other on the screen.

    Can you please guide how can i store all the 3 questions and answers and after a right or wrong answer i will i have another question.

    Please help me

  • Hi,

       How can i create a session with arrays?

    Thanks

  • kiran

    To do it quickly with arrays, I would use a bidimensional array:

    A[0,0] = "What is your name?"

    A[0,1] = Option 1

    A[0,2] = Option 2

    A[0,3] = Option 3

    A[1,0] = Second question

    A[1,1] = Option 1

    A[1,2] = Option 2

    A[1,3] = Option 3

    A[2,0] = Third question

    A[2,1] = Option 1

    A[2,2] = Option 2

    A[2,3] = Option 3

    And so on.

    To move from one question to another, it depends on how you will implement the game.

    What do you mean with "a session with arrays"?

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