Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Text and textboxs

    Help
    3
    7
    316
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • poof92
      poof92 last edited by

      I'm making a 2d rpg and I want it so that when I touch a sprite and press the A button then text will appear in a text box also I would like it so I can press A and then another line of text will appear I'd like it as simple as possible not a strong coder and thanks for the help

      1 Reply Last reply Reply Quote 0
      • pico8-jihem
        pico8-jihem F last edited by pico8-jihem

        Hi,
        I made a text console to display values and messages. I use it to debug my programs. You have only to copy/paste the code to use it with the new functions (cout, coutln, ... see sample). It’s a shared program (so let’s be friend). I have posted my code on the forum (in the thread ‘who am I’).
        Regards,
        jihem

        N 1 Reply Last reply Reply Quote 0
        • N
          Nisse5 F @pico8-jihem last edited by

          @pico8-jihem You can put the friend code in the signature as well, so it will easily be accessed whenever you post about shared projects.

          1 Reply Last reply Reply Quote 1
          • pico8-jihem
            pico8-jihem F last edited by

            Done :-)
            Thanks a lot @Nisse5, I haven't seen this feature on my profil before...

            1 Reply Last reply Reply Quote 0
            • N
              Nisse5 F last edited by MikeDX

              @poof92 Here's some code. I put some comments in, to document what's going on.

              // This function displays text in a box, one line at a time
              function DisplayTextBox(textarray)
                 // Wait until A button is up
                 while controls(0).a loop repeat
                 // Calculate how many lines the text is
                 textrowcount = len(textarray)
                 // Process one line at a time
                 for i = 0 to textrowcount loop
                    // Draw a black box to the screen buffer (box is 150 pixels high)
                    box(100,500, 700, 150, black, false)
                    // Draw a single row of text in white to the screen buffer (text is 50 pixels high)
                    drawText(120, 520, 50, white, textarray[i])
                    // Draw instruction text in white and with a smaller text size
                    drawText(120, 600, 30, white, "Press A")
                    // Display the screen buffer content on the screen
                    update()
                    // Wait for A button to be pressed down
                    while !controls(0).a loop repeat 
                    // Wait until A button is up
                    while controls(0).a loop repeat
                 repeat
              return void
              
              text = [
              "First line",
              "Second line"
              ]
              
              // Main loop
              loop
                  clear(green)
                  print("Press A to display text box")
                  c = controls
                  if c.a then
                     DisplayTextBox(text)
                  endif
                  update()
              repeat
              
              1 Reply Last reply Reply Quote 3
              • poof92
                poof92 last edited by MikeDX

                Thanks for the help everyone.

                @Nisse5 I added you.

                N 1 Reply Last reply Reply Quote 0
                • N
                  Nisse5 F @poof92 last edited by

                  @poof92 I also shared the sample code now (as "Text Box Sample").

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post