choosing different text for text boxes

Get help using Construct 2

Post » Sun Nov 20, 2016 11:20 pm

I want to set and change a text object based on several different choices. Something like this:

Image

But, I want to have a lot more choices, say 100 for each blank. What would be a good way to go about doing this? I thought about using arrays but I don't know where to start.

Thank you.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,986

Post » Mon Nov 21, 2016 2:04 am

I'd go with a dictionary.

It works like this:

  • Add the Dictionary object (obviously)
  • At the start of the layout (or whereever you prefer), add values to the dictionary
  • each value has a key, meaning you can get the value by inputting the key
  • this way you have multiple variants.

Also, I'd be happy if you would provide the project context, so we know what object suits your purpose the most.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Mon Nov 21, 2016 3:42 am

@randomly I've been playing around with dictionaries but I can't get it to work properly. Can you show me an example? Let's say that I want to have a text object, and each time I press a key it will change the text in the box for the size, color etc just like it would in my example image above using choose.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,986

Post » Mon Nov 21, 2016 4:29 pm

Here you go:
(had much fun while doing this)

Download .capx
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Mon Nov 21, 2016 5:15 pm

Burvey wrote:I want to set and change a text object based on several different choices. Something like this:

Image

But, I want to have a lot more choices, say 100 for each blank. What would be a good way to go about doing this? I thought about using arrays but I don't know where to start.

Thank you.



Here is a Version using an Array, it should be easy to understand 3 Events 1 project file.

The only advantage in using an array is that you can change the data on your server easily, as it is only a data file.

http://www.sizzle-games.com/choose_array.capx

I used this method for the levels in my game https://play.google.com/store/apps/details?id=com.sizzgames.BushyBall&hl=en_GB, to set the positions, width and size of the platforms e.t.c

To edit the project file just double click it, it should open with notepad, then you can change the file data, just make sure if you change the size, to specify it in the file.
Bushy Ball\Boatman Bill\Sticky Web\Snake

Image ImageImageImage

During the gold rush it was a good time to be in the pick and shovel business
B
46
S
14
Posts: 252
Reputation: 5,352

Post » Mon Nov 21, 2016 7:10 pm

Thank you both. These have gotten me on the right track.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,986


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests