Calculator

Forum Home Forum Home > Construct 2 General > How do I....?
 Post Reply Post Reply Page  12>
Author
371 Rep
Post Options Post Options   Quote gordon101112 Quote  Post ReplyReply Direct Link To This Post Topic: Calculator
    Posted: 08 Jul 2012 at 4:19pm
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.
Back to Top
1,557 Rep
Post Options Post Options   Quote Goury Quote  Post ReplyReply Direct Link To This Post Posted: 08 Jul 2012 at 11:00pm
what O.o ?
Back to Top
371 Rep
Post Options Post Options   Quote gordon101112 Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jul 2012 at 3:48pm
Sorry let me try explaining it better.



Edited by gordon101112 - 09 Jul 2012 at 3:57pm
Back to Top
371 Rep
Post Options Post Options   Quote gordon101112 Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jul 2012 at 3:48pm
My layout is as follows:




Edited by gordon101112 - 09 Jul 2012 at 3:56pm
Back to Top
371 Rep
Post Options Post Options   Quote gordon101112 Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jul 2012 at 3:56pm
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.

Edited by gordon101112 - 09 Jul 2012 at 3:58pm
Back to Top
2,237 Rep
Post Options Post Options   Quote ptbcomposer Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jul 2012 at 4:44pm
can you post your .capx so we can look at it? I still have no idea what you mean.
Back to Top
371 Rep
Post Options Post Options   Quote gordon101112 Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jul 2012 at 7:15pm
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

Edited by gordon101112 - 09 Jul 2012 at 7:20pm
Back to Top
1,775 Rep
Post Options Post Options   Quote OddConfection Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jul 2012 at 8:44pm
Originally posted by gordon101112 gordon101112 wrote:

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.


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
Back to Top
371 Rep
Post Options Post Options   Quote gordon101112 Quote  Post ReplyReply Direct Link To This Post Posted: 09 Jul 2012 at 9:05pm
Thanks so much, exactly what I needed.
Back to Top
371 Rep
Post Options Post Options   Quote gordon101112 Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jul 2012 at 6:32pm
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.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down