0 Favourites

Calculator

  • 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.

  • what O.o ?

  • Sorry let me try explaining it better.

  • My layout is as follows:

  • 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.

  • can you post your .capx so we can look at it? I still have no idea what you mean.

  • 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

  • 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

  • Thanks so much, exactly what I needed.

  • 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.

  • The example works fine for me, did you try downloading the file again? Or maybe you need the latest beta release? (r98)

    Or, if you could tell us more about the error you're getting, someone might be able to help. "File is missing or something like that" doesn't really help.

  • Sorry about that, I just downloaded the version 98 of contruct 2 and tried opening the example file and I got the same message. The first paragraph in the box says that it could not open the project and then it says the location in this format c:owner/app/... Then the secound paragraph says Layout c:Owner/app/... is missing. Was it deleted or renamed outside of construct?

    I didn't touch any settings or anything. I just clicked open the first time and tried opening it and it didn't work. Then I clicked save the secound time and it didn't work. And I just clicked open every time after that.

  • No idea why you're getting errors with the example. Try downloading it again.

    Definitely don't do x10 every tick, just update the text when the buttons are pressed <img src="smileys/smiley17.gif" border="0" align="middle" />

    <img src="http://i841.photobucket.com/albums/zz338/perpetual_noob/Construct/Multi-digit_numbers.png" border="0" />

  • I see now. Thanks again you guys were really helpful. Sorry for being a bother.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • It's no bother, it just sounds a bit strange and I thought I might be a bug. If it is, you should report it in the bugs forum so it can be fixed.

    (PS: Make sure you have a look the "how to report bugs" thread first if you do)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)