Calculator

Get help using Construct 2

Post » Sun Jul 08, 2012 4:19 pm

I'm trying to make a calculator type of thing where you use buttons to make numbers in a form of an equation. I'm having trouble making the numbers appear double digit though. My setup is as follows: text 1, text 2, text 3, equals sign text 4. Global Variable ='s 0 and number clicked (I have all the numbers as buttons at the bottem of the screen) it appears in text 1. When that happens Global Variable = 1 and then when you hit a equation sign(Ex add subtract) and another number that replaces text 3. And same thing for text 4. This makes me only able to input single digits. I want for example if I hit 2 and 3 that it shows in one text or text 1. If you want me to explain it better I'll try but this is the best way I can put it in words for now.
B
3
Posts: 23
Reputation: 396

Post » Sun Jul 08, 2012 11:00 pm

what O.o ?
B
18
S
3
G
4
Posts: 46
Reputation: 3,873

Post » Mon Jul 09, 2012 3:48 pm

Sorry let me try explaining it better.

gordon1011122012-07-09 15:57:49
B
3
Posts: 23
Reputation: 396

Post » Mon Jul 09, 2012 3:48 pm

My layout is as follows:


gordon1011122012-07-09 15:56:59
B
3
Posts: 23
Reputation: 396

Post » Mon Jul 09, 2012 3:56 pm

Text 1 Text 2 Text 3 = Text 4



(Numbered Buttons set for touch/click)
1 2 3 4..... + - / x


________________________________________________________________________
I have a global variable set to 0

When 1 clicked set text 1 to 1 then add one to global variable.

When addition sign clicked and global variable is 1, set text to to addition symbol.

When global variable is 2 and 3 is clicked then set text 3 to 3.

When global variable is 3 and four is clicked set text 4 to 4.
______________________________________________________________________
That's an example in my event sheet. This works but only allows me to use single digits. I want like numbers 1-99. Also I'd like to make a correct or incorrect option. This is basicly like a calcultor but I want to incorperate it into a game situation. Using buttons to create double digit numbers.gordon1011122012-07-09 15:58:58
B
3
Posts: 23
Reputation: 396

Post » Mon Jul 09, 2012 4:44 pm

can you post your .capx so we can look at it? I still have no idea what you mean.
B
14
S
5
G
4
Posts: 121
Reputation: 3,938

Post » Mon Jul 09, 2012 7:15 pm

I have no idea how plus I have other layouts in my project like the cacluator is just a sub thing.

Are you confused on my concept? If so, just think of a calculator. There is buttons labeled 0-9 and plus, minus, divided by, times and other minor buttons. When you hit the 1 it appears in the bar at the top and you hit a 7 it appears as 17. I'm trying to make it do that. When I hit 1 and 7 it appears in text 1. I can't make double digits, I'm not sure what set up to use or how to do it.

One Button clicked. Condition global variable is Zero. Set text1 to 1 and add one to global variable. Plus button clicked condition that global variable is one. Set text 2 to + and add one to global variable. I'm making an equation.

Ex. 1 + 2 = 3 gordon1011122012-07-09 19:20:53
B
3
Posts: 23
Reputation: 396

Post » Mon Jul 09, 2012 8:44 pm

[QUOTE=gordon101112]When you hit the 1 it appears in the bar at the top and you hit a 7 it appears as 17. I'm trying to make it do that. When I hit 1 and 7 it appears in text 1. I can't make double digits, I'm not sure what set up to use or how to do it.[/QUOTE]

To make multi-digit numbers when you press the buttons, simply have it multiply a variable by 10 then add the value of the button to the variable, you then set the Text to this variable.

For example, you press the buttons 1, 3, 7 so you want it to display 137

Variable = 0
Press 1
Variable = (Variable * 10) + 1 = (0 * 10) + 1 = 0 + 1 = 1
Press 3
Variable = (Variable * 10) + 3 = (1 * 10) + 3 = 10 + 3 = 13
Press 7
Variable = (Variable * 10) + 7 = (13 * 10) + 7 = 130 + 7 = 137

Example capx
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
27
S
7
G
4
Posts: 314
Reputation: 4,928

Post » Mon Jul 09, 2012 9:05 pm

Thanks so much, exactly what I needed.
B
3
Posts: 23
Reputation: 396

Post » Tue Jul 10, 2012 6:32 pm

Umm sorry to bother you again but for some reason I get an error when I try to open the example file. First error I got was to install version 95 of contruct 2 which I did. Then now it says the file is missing or something like that. Reason I'm trying to open the example is because I attached all the text to the global variables to produce the numbers visually but I have it as every tick so it makes the numbers go really fast until it reaches infinity. What did you use to show your numbers because every tick isn't working out for me.
B
3
Posts: 23
Reputation: 396

Next

Return to How do I....?

Who is online

Users browsing this forum: Artpunk, NRABrazil, PixelatedTrip and 26 guests