Why does the event brokes?

Get help using Construct 2

Post » Thu May 14, 2015 7:38 pm

Image

I want player to buy kielbasa from the store for 500zl. When he does it, layer with kielbasa being visible, +1 kielbasa adds to the kielbasa global value. When player buys it again, another layer with kielbasa being visible, ect. Everything works with 500zl, but if you will buy it when you have 1000+ zl, you will instanly buy 2 kielbasas and the money system dies. What I did wrong?
B
6
Posts: 20
Reputation: 266

Post » Thu May 14, 2015 8:36 pm

This is a common mistake. Don't break everything out into separate events, try to group them in a tree. The problem is when event 15 runs, you add one to Kielbasa. Then event 17 runs, sees that Keilbasa is 1 so adds another one, and again in event 18! Break the Keilbasa checks into subevents using Else, so only one gets evaluated at a time.

On-touch
Layer 6 visible
Zloty>=500
--> Keilbasa=0
-->else
--> Keilbasa=1
-->else
--> Keilbasa=2
ImageImageImage
B
71
S
21
G
221
Posts: 3,651
Reputation: 124,231

Post » Fri May 15, 2015 7:48 pm

blackhornet wrote:This is a common mistake. Don't break everything out into separate events, try to group them in a tree. The problem is when event 15 runs, you add one to Kielbasa. Then event 17 runs, sees that Keilbasa is 1 so adds another one, and again in event 18! Break the Keilbasa checks into subevents using Else, so only one gets evaluated at a time.

On-touch
Layer 6 visible
Zloty>=500
--> Keilbasa=0
-->else
--> Keilbasa=1
-->else
--> Keilbasa=2


I can't add Else
B
6
Posts: 20
Reputation: 266

Post » Fri May 15, 2015 8:47 pm

Select the event (not just the condition), right-click->Add->Add 'Else' (or select the event/condition and press X).
ImageImageImage
B
71
S
21
G
221
Posts: 3,651
Reputation: 124,231

Post » Fri May 22, 2015 1:38 pm

blackhornet wrote:Select the event (not just the condition), right-click->Add->Add 'Else' (or select the event/condition and press X).


It's worked, thanks
B
6
Posts: 20
Reputation: 266


Return to How do I....?

Who is online

Users browsing this forum: digitalsoapbox and 1 guest