User Set Text

Get help using Construct 2

Post » Fri Sep 30, 2011 4:06 pm

I may just be talking out my ass here, but I think it would make sense to edit your exported html file to include a form (or have your game open a pop-up form when text is needed). Then you could have the Javascript for the game get the text from a good ole text input. You'd have to actually edit the code though after exporting your game. I haven't tried it yet and it's been too long since I've played with Javascript so it's still just a theory at this point.
B
20
S
9
G
2
Posts: 15
Reputation: 2,594

Post » Fri Sep 30, 2011 4:18 pm

@ScottP, that might work if you made a plugin with the Javascript SDK, but otherwise it's probably too hard to edit the code by hand - it's all auto generated and not easy to work out.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sat Oct 01, 2011 12:29 pm

It appears I need to jump back into javascript and see if I can make a Text Input plugin. If anyone wants to help....or if anyone beats me to it, lemme know.
B
20
S
9
G
2
Posts: 15
Reputation: 2,594

Post » Sat Dec 10, 2011 6:17 am

I believe all you have to do is set up an event that passes the value in the text box into a variable.

pseudo code e.g. "on keyboard:shift.pressed >> system >> set value

select the variable e.g. worldName1
set the value e.g. str(yourTextBoxName.Text)

::: the str() converts the text into a string value. You could use str() if you wanted your worlds to be named using words.

or

int() / float to convert the input to an integer or floating point value! For naming worlds with numbers.

From there you can use the general text object to render the text on canvas: e.g. Add event: system >> every_tick >> set text >> "This world is called "& worldName1

B
7
S
1
G
2
Posts: 10
Reputation: 1,802

Post » Sun Dec 11, 2011 9:22 am

My 2-Cent....there is an object called Text-Box and another just for Text. If I need some "work-around" to retrieve the user entered text, why have to seperate objects?
...or, differently phrased, will there be a "get text" method in the near future?
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Wed Dec 04, 2013 1:16 pm

HI @simwhi

Ive tried your virtual keyboard and it works nice

BUT on android it triggers the key-letters twice ...
also the DEL and SPACE

Is there a workaround, I use the on touch object

Regards
Flemmingflemmig2013-12-04 13:17:27
B
23
S
12
G
10
Posts: 323
Reputation: 7,382

Post » Wed Dec 04, 2013 1:21 pm

I would go with the Text Box object, like Jubalicious87 described.
B
17
S
4
G
5
Posts: 41
Reputation: 4,254

Post » Sun Dec 08, 2013 10:53 am

@flemmig

I have never noticed that before. We have used a virtual keyboard in all of our games without any issues. Which version of C2 are you using? I will check it out.
B
26
S
5
G
5
Posts: 151
Reputation: 6,279

Post » Sun Jun 08, 2014 5:37 am

Links work fine
B
206
S
27
G
13
Posts: 1,846
Reputation: 35,822

Post » Fri Jul 22, 2016 11:25 am

@simwhi - Link not working anymore...
Stay tuned on SONAR Games at Twitter and SONAR Games at Facebook for daily updates!
B
96
S
24
G
10
Posts: 685
Reputation: 12,166

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Mohicano and 26 guests