SOLVED// How do I create sums for variables?

0 favourites
  • 6 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I have this mini .capx example of objects placed on screen when buttons are pressed. Each object has a number variable which will be added to the value of another previously added object's variable. Each time I press the specific button, number is added, but when I add the second object, value of first object is replaced with the second object's value. How do I make them to sum when selected, and not replace each other?

  • Not sure if I understand correctly, but there's the action add to variable..

  • I know about the native expressions:

    + (addition)

    • (subtraction)

    * (multiplication)

    / (division)

    But how do I make only the selected objects to be summed(added)? Those which are already placed on screen only. ANd also, if one object will be removed, I need to know how to subtract it's value from the total sum.

  • If I write Blue. point+Red. point+Green. points, they all add at once. But I want them to be added only when placed on screen. What would be the right command?

  • I think you mean something like this:

    On object2 created - object1 add to variable value = object2.value

    On object2 destroyed - object1 subtract from variable value = object2.value

    With multiple objects it would probably be easiest to use the family feature and have the adding event be in a function.

    Maybe using the is on screen - condition, would be an option.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've made it! Thank you for your suggestions!

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