How do I make a better version of a text box?

Get help using Construct 2

Post » Sat Feb 06, 2016 12:36 am

So, for a school project, I'm programming a math game to help teach kids mental math. What's a good way to make a good looking version of a text box? I've tried to make it myself, but as I am very new to programming it ended up being a buggy mess. Basically, I want to be able to type in a number at the end of a math problem. If it's correct, launch function 'Correct', else, launch 'Incorrect'. I'm having trouble with the first part. Thanks!
B
10
S
2
Posts: 20
Reputation: 622

Post » Sat Feb 06, 2016 1:51 am

See what I could do, I hope it helps you.
https://drive.google.com/drive/folders/ ... DBTU0hnNDg
B
29
S
9
G
3
Posts: 280
Reputation: 4,187

Post » Sat Feb 06, 2016 9:59 am

You don't need a textbox for that.

Say you are waiting for input. Then you can activate the following event (if you only want to accept numbers):
Image

https://drive.bitcasa.com/send/ZoS-vHik ... LYaDLNYOjo

Obviously works just as well with spritefont. You can also easily add a blinking marker at the end or highlight the text, or pretty much do whatever you want.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Sun Feb 07, 2016 8:05 pm

Thanks for the help, @mindfaQ. I found one problem with it: whenever you input a number from the numpad, it enters "numpad [n]". Also, how would I go about setting an integer to the number which has been pressed?
B
10
S
2
Posts: 20
Reputation: 622

Post » Sun Feb 07, 2016 8:57 pm

Oh okay.
Set text to:
Code: Select all
text.Text & RegexMatchAt(Keyboard.StringFromKeyCode(Keyboard.LastKeyCode), "[0-9.]", "gi", 0)

instead.

Edit: if you wanna prevent F-keys to fire off, you'd also have to match differently, because of this (if you think this is a problem).
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Tue Feb 09, 2016 12:19 am

Awesome! Thanks so much, @mindfaQ! When I finish the project I'll send you a link.
B
10
S
2
Posts: 20
Reputation: 622


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests