How do I Add different values using same buttons?

  • So in the capx example, I have 2 sprite buttons. BUT, they are copy/pasted.

    How would I add 1 to the variable "points" by clicking the left (+1) button and add 2 by clicking on the right (+2) button. As far as the events go, both buttons register as +1 clicks.

    Thanks in advance.

    capx:

    drive.google.com/file/d/0BzM_Ir0LBMx_Q01rQ1ZrRGNzT0E/view?usp=sharing

  • I haven't looked at your capx but if the two buttons are instances of the same type, then you could give them an instance variable, call it value and set one to 1 and the other 2. Finally when you click on it add button.value.

  • I haven't looked at your capx but if the two buttons are instances of the same type, then you could give them an instance variable, call it value and set one to 1 and the other 2. Finally when you click on it add button.value.

    How do I set one to "1" and the other to "2", when they are the same sprite/has the same instance variables?

    BTW here's the print screen of the 2 sprite buttons. They are copy/pasted (as shown by only 1 sprite object in the project bar).

  • Different instances can have a different values for an instance variable (the variable name is ofcourse the same)..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Different instances can have a different values for an instance variable (the variable name is ofcourse the same)..

    I do not get how to set this up in the events. Both sprites still add the same amount when clicked.

    EDIT: Never mind, just got it

    Thanks

    @R0J0hound

    @LittleStain

  • In editor click on "+1" sprite and set the instance variable (eg value) to 1

    In editor click on "+2" sprite and set the instance variable (value) to 2

    In event sheet:

    On left click on "sprite" : -> system add sprite.value

  • In editor click on "+1" sprite and set the instance variable (eg value) to 1

    In editor click on "+2" sprite and set the instance variable (value) to 2

    In event sheet:

    On left click on "sprite" : -> system add sprite.value

    Already sorted it, but thanks though. Good for future reference.

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