SOLVED// How do I create sums for variables?

Get help using Construct 2

Post » Mon Apr 13, 2015 11:52 am

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?
drive.google.com/file/d/0B09lLdP7JoIAZ1hHYjFlRms4OXc/view?usp=sharing
Last edited by MangoPolo on Mon Apr 13, 2015 11:22 pm, edited 1 time in total.
B
8
S
2
Posts: 110
Reputation: 923

Post » Mon Apr 13, 2015 11:55 am

Not sure if I understand correctly, but there's the action add to variable..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Apr 13, 2015 12:07 pm

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.
B
8
S
2
Posts: 110
Reputation: 923

Post » Mon Apr 13, 2015 12:22 pm

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?
B
8
S
2
Posts: 110
Reputation: 923

Post » Mon Apr 13, 2015 12:28 pm

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Apr 13, 2015 11:21 pm

I've made it! Thank you for your suggestions!
B
8
S
2
Posts: 110
Reputation: 923


Return to How do I....?

Who is online

Users browsing this forum: LaroTaio and 3 guests