How to display random phrases in random time in a framework

Get help using Construct 2

Post » Tue Sep 08, 2015 11:10 pm

buenas, necesito hacer lo siguiente..he rebuscado ya durante varias horas pero no...ni idea.

En fin, tengo un marco donde quiero que vayan apareciendo frases cada x y al azar.

quería crear algo como que el sistema fuera añadiendo a ese marco cada x tiempo jugando con variables...pero no tengo idea de como hacerlo.

supongo que podría hacer una orden para cada frase , que se cree cada x segundos después de la otra....pero quería saber si se puede crear como una base de datos, donde se vayan mostrando en un display o hud , datos de esa base, de manera random y cada x tiempo....

voy a intentar traducirlo con google por si algún giri me puede ayudar.....


well, I need to do the next ..i already fetched for several hours but no ... no idea .

Anyway, I have a framework where I want they appear random sentences each xy .

I wanted to create something like the system to be added to that frame each time playing with variables x ... but I have no idea how.

I suppose I could make an order for each phrase , believed every x seconds after the other .... but wanted to know if you can create a database, where they will show on a display or HUD , the data base, random way and each x time ....
B
6
Posts: 10
Reputation: 270

Post » Tue Sep 08, 2015 11:25 pm

You can store the sentences in an array. Just drop the object in your layout. Then at start of layout set x 0 = "This is the first sentence", x 1 = "this is the second sentence."

You can use a for each loop under the cog for the array.

You can also use dictionaries. I find them to be easier. They work with keys.

start of layout set key 1 = "first question" value = "this is the first question."

Then use a foreach under the cog wheel to loop through the dictionary.
sub event
compare two values.

if the first field Dictionary.CurrentKey
the second = "first question"

Then in the actions you can set text position, random x,y using layout width and height.
set text = dictionary.CurrentValue
B
7
S
2
Posts: 92
Reputation: 663

Post » Tue Sep 08, 2015 11:30 pm

thank you very much ! i test tomorrow ! thz !!!
B
6
Posts: 10
Reputation: 270

Post » Wed Sep 09, 2015 6:44 am

well sorry i cant understand that....i dont know how to add sentences to the dictionary or array, and how to call to appear in the display....
B
6
Posts: 10
Reputation: 270

Post » Wed Sep 09, 2015 9:31 am

ok i know how to give some values to the array but i dont know how to make a call for display the values....
B
6
Posts: 10
Reputation: 270

Post » Wed Sep 09, 2015 9:33 am

Well it is unclear what you refer to as "framework".
To display a sentence, you need to have some display object in your project such as Text or Spritefont.

From there, you either fill an array/dictionnary on start of the first layout of your game, the array being global you can access it from any layout in the game.

Here is a simple example using an array.
Execute the project starting from layout 1, or it won't work.

On startup of Layout 1 an array is filled with various sentences.
Then, in layout 2 every second, a sentence is picked out of the array and displayed in the text object.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Wed Sep 09, 2015 9:52 am

ok thz let me check
B
6
Posts: 10
Reputation: 270

Post » Wed Sep 09, 2015 11:15 am

I could apply to my game! really thz !!!!! <3
B
6
Posts: 10
Reputation: 270


Return to How do I....?

Who is online

Users browsing this forum: marc254 and 10 guests