Text and textboxs
-
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
-
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 -
@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.
-
Done :-)
Thanks a lot @Nisse5, I haven't seen this feature on my profil before... -
@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
-
Thanks for the help everyone.
@Nisse5 I added you.
-
@poof92 I also shared the sample code now (as "Text Box Sample").