Storing Value from different buttons

Get help using Construct 2

Post » Sat May 11, 2013 6:31 pm

Hi everyone, I need your help.
Here's my problem. I'm making a math game where the player has to press some buttons to reach certain predetermined score. For example:

? + ? = 7            -----> text

[1] [2] [3] [4] [5]   ---->buttons

the number in bracket is the button, and each has the corresponding score to number. Let's say if i press 4 and then 3, the score first obtained should go to the first "?" and the second should go to the second "?".

Can anyone help me to do this? Thanks
nothaseo2013-05-11 19:09:10
B
41
S
9
G
4
Posts: 100
Reputation: 6,211

Post » Sat May 11, 2013 6:47 pm

You can add Instance Variable to each button to store the numbers.
In your eventsheet you can access them for example:

ButtonA : on clicked => TextA : set text = ""&ButtonA.yourVarName

Prox2013-05-11 18:50:02
B
7
S
1
G
1
Posts: 32
Reputation: 1,016

Post » Sat May 11, 2013 7:03 pm

[QUOTE=Prox] You can add Instance Variable to each button to store the numbers.
In your eventsheet you can access them for example:

ButtonA : on clicked => TextA : set text = ""&ButtonA.yourVarName

[/QUOTE]

Thanks @Prox. I did use variables, but the problem is how to make the text shows the value of each variable in sequence. So if i press ButtonA and then ButtonC the text will show in sequence ButtonA.yourVarName+ButtonC.yourVarName.
But if i press ButtonCand then ButtonA the text will show in sequence ButtonC.yourVarName+ButtonA.yourVarName.

The var of the first pressed button shows first and then the sceond and so on.
nothaseo2013-05-11 19:07:58
B
41
S
9
G
4
Posts: 100
Reputation: 6,211

Post » Sat May 11, 2013 7:42 pm



Here an example .capx http://tinyurl.com/bpt8p5oProx2013-05-11 20:10:08
B
7
S
1
G
1
Posts: 32
Reputation: 1,016

Post » Sat May 11, 2013 8:41 pm

Thanks @Prox. That's great. It works and is Exactly what I wanted.
B
41
S
9
G
4
Posts: 100
Reputation: 6,211


Return to How do I....?

Who is online

Users browsing this forum: Megavolt, selaus and 0 guests