How do I make a Textbox for a interactive character name

Get help using Construct 2

Post » Fri Jan 09, 2015 11:37 am

Hi there,

I've been working on a platform game with character selection, 10 levels, timer, point score etc.

The only thing i can't seem to make is a textbox where you can put your own players name.
I really would like this to work to make it more interactive with the player.

When the player inserts the name it wil be used further on in te game (Story, highscore).

I've also included a screenshot.

Thanks in advance.

Greetz,
Ruerd

Image
B
5
Posts: 5
Reputation: 235

Post » Fri Jan 09, 2015 1:19 pm

Just get the text in the textbox and set a variable (say playerName) to it. Whenever you want the player's name to show use this variable. If you want it to persist between sessions, use a Webstorage object.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
21
S
6
G
3
Posts: 658
Reputation: 3,843

Post » Fri Jan 09, 2015 1:56 pm

Thanks.But I'm just not sure if I understand, could you make an example?

Do i need to make a global variable or a Instance variable on the TextBox?
And does the variable needs be a Number, Text or Boolean?
B
5
Posts: 5
Reputation: 235

Post » Fri Jan 09, 2015 2:16 pm

RuerdVisser1991 here include this in your code
You do not have the required permissions to view the files attached to this post.
B
257
S
42
G
15
Posts: 1,991
Reputation: 41,411

Post » Fri Jan 09, 2015 2:28 pm

Here. Using Webstorage to make it persistent.

save-name-example.capx


This example only shows the textbox layout if name is not stored. You can reset the storage and refresh the page if you want to go back to the textbox layout.
You do not have the required permissions to view the files attached to this post.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
21
S
6
G
3
Posts: 658
Reputation: 3,843

Post » Fri Jan 09, 2015 2:40 pm

Great! Thanks for the help!
B
5
Posts: 5
Reputation: 235

Post » Fri Dec 02, 2016 7:39 pm

Perfect, just what I need :)

But one question now : how can we use this Name in the middle on a sentence during the game ?

In a RPG for example, at the start we name our character "HERO" and then during the game if some people talk to us, for example : "hey HERO how are you?"

thx
B
19
S
7
G
1
Posts: 38
Reputation: 1,911


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests