How do I Change texts

Get help using Construct 2

Post » Sun Aug 10, 2014 7:53 am

Hey guys,

I want a text to constantly(and randomly) change texts.
So what i mean is -
The code will have the words - hello, hi , bye
One min it shows - hello
the next min bye
the next min hello
the next min hi
and so on
So i want it to change every time the user presses a button or so.

How do i do this?

Thanks,
Ashwin
B
15
S
3
G
1
Posts: 111
Reputation: 1,664

Post » Sun Aug 10, 2014 8:27 am

ashwin2000 wrote:I want a text to constantly(and randomly) change texts.


ashwin2000 wrote:So i want it to change every time the user presses a button or so.


So which is it? :)

It seems you want to know 1 or more of the following:

Q: How to change text to different words
A: System:Every tick -> textObject:set text to "hello"

Q: How to do something randomly
A:
System: Every tick -> Set MyVar to random(1, 5) (or choose( 1,2,3,4,5))
System: MyVar = 1 -> action 1
Else
System: MyVar = 2 -> action 2
(etc)

Q: How to do something every so often
A: System: Every 1.0 seconds -> action

Q: How to do something when the user presses a button/sprite
A: Touch: On tap gesture on MySprite -> action

Maybe you can put it all together :)

Edit:
Hint: Use an array to store the words, then use the randomly chosen number as the index into the array
Last edited by codah on Sun Aug 10, 2014 8:31 am, edited 2 times in total.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Aug 10, 2014 8:27 am

Depends on how many choices and how the text is stored. If it's just a few words, then simply do something like:

On clicked - Text Set Text to choose("Hello", "Goodbye","Booyah!","etc")
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,393
Reputation: 58,468

Post » Sun Aug 10, 2014 8:29 am

So i did a quick thing, although i'm a beginner in construct 2 xD.. and i added two methods (by waiting 5 seconds or by pressing "X") well, i hope this is what you wished for:
ChangingTexts.capx
You do not have the required permissions to view the files attached to this post.
B
21
S
6
Posts: 244
Reputation: 2,665


Return to How do I....?

Who is online

Users browsing this forum: amazingdream and 25 guests